Support multiple %base arguments with refs/for/

Multiple %base arguments are necessary when pushing a merge commit
in order to mark the uninteresting part of the TreeWalk for each
parent line.

Example:
  $ git push origin HEAD:refs/for/master%base=commitId1,base=commitId2

Change-Id: Ie291e7eb2d5755d7c69b5625662af03561de1386
This commit is contained in:
Sasa Zivkov 2013-11-07 16:08:31 +01:00
parent af3c04a08e
commit bc011a109f
2 changed files with 32 additions and 17 deletions

View File

@ -366,6 +366,15 @@ by setting the merge base SHA-1 using the '%base' argument:
git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%base=$(git rev-parse origin/master) git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%base=$(git rev-parse origin/master)
==== ====
It is also possible to specify more than one '%base' argument.
This may be useful when pushing a merge commit. Note that the '%'
character has only to be provided once, for the first '%base'
argument:
====
git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%base=commit-id1,base=commit-id2
====
repo upload repo upload
----------- -----------

View File

@ -981,10 +981,10 @@ public class ReceiveCommits {
RefControl ctl; RefControl ctl;
Set<Account.Id> reviewer = Sets.newLinkedHashSet(); Set<Account.Id> reviewer = Sets.newLinkedHashSet();
Set<Account.Id> cc = Sets.newLinkedHashSet(); Set<Account.Id> cc = Sets.newLinkedHashSet();
RevCommit baseCommit; List<RevCommit> baseCommit;
@Option(name = "--base", metaVar = "BASE", usage = "merge base of changes") @Option(name = "--base", metaVar = "BASE", usage = "merge base of changes")
ObjectId base; List<ObjectId> base;
@Option(name = "--topic", metaVar = "NAME", usage = "attach topic to changes") @Option(name = "--topic", metaVar = "NAME", usage = "attach topic to changes")
String topic; String topic;
@ -1135,20 +1135,24 @@ public class ReceiveCommits {
RevWalk walk = rp.getRevWalk(); RevWalk walk = rp.getRevWalk();
if (magicBranch.base != null) { if (magicBranch.base != null) {
try { magicBranch.baseCommit = Lists.newArrayListWithCapacity(
magicBranch.baseCommit = walk.parseCommit(magicBranch.base); magicBranch.base.size());
} catch (IncorrectObjectTypeException notCommit) { for (ObjectId id : magicBranch.base) {
reject(cmd, "base must be a commit"); try {
return; magicBranch.baseCommit.add(walk.parseCommit(id));
} catch (MissingObjectException e) { } catch (IncorrectObjectTypeException notCommit) {
reject(cmd, "base not found"); reject(cmd, "base must be a commit");
return; return;
} catch (IOException e) { } catch (MissingObjectException e) {
log.warn(String.format( reject(cmd, "base not found");
"Project %s cannot read %s", return;
project.getName(), magicBranch.base.name()), e); } catch (IOException e) {
reject(cmd, "internal server error"); log.warn(String.format(
return; "Project %s cannot read %s",
project.getName(), id.name()), e);
reject(cmd, "internal server error");
return;
}
} }
} }
@ -1288,7 +1292,9 @@ public class ReceiveCommits {
Set<ObjectId> existing = Sets.newHashSet(); Set<ObjectId> existing = Sets.newHashSet();
walk.markStart(walk.parseCommit(magicBranch.cmd.getNewId())); walk.markStart(walk.parseCommit(magicBranch.cmd.getNewId()));
if (magicBranch.baseCommit != null) { if (magicBranch.baseCommit != null) {
walk.markUninteresting(magicBranch.baseCommit); for (RevCommit c : magicBranch.baseCommit) {
walk.markUninteresting(c);
}
assert magicBranch.ctl != null; assert magicBranch.ctl != null;
Ref targetRef = allRefs.get(magicBranch.ctl.getRefName()); Ref targetRef = allRefs.get(magicBranch.ctl.getRefName());
if (targetRef != null) { if (targetRef != null) {