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)
====
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
-----------

View File

@ -981,10 +981,10 @@ public class ReceiveCommits {
RefControl ctl;
Set<Account.Id> reviewer = Sets.newLinkedHashSet();
Set<Account.Id> cc = Sets.newLinkedHashSet();
RevCommit baseCommit;
List<RevCommit> baseCommit;
@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")
String topic;
@ -1135,8 +1135,11 @@ public class ReceiveCommits {
RevWalk walk = rp.getRevWalk();
if (magicBranch.base != null) {
magicBranch.baseCommit = Lists.newArrayListWithCapacity(
magicBranch.base.size());
for (ObjectId id : magicBranch.base) {
try {
magicBranch.baseCommit = walk.parseCommit(magicBranch.base);
magicBranch.baseCommit.add(walk.parseCommit(id));
} catch (IncorrectObjectTypeException notCommit) {
reject(cmd, "base must be a commit");
return;
@ -1146,11 +1149,12 @@ public class ReceiveCommits {
} catch (IOException e) {
log.warn(String.format(
"Project %s cannot read %s",
project.getName(), magicBranch.base.name()), e);
project.getName(), id.name()), e);
reject(cmd, "internal server error");
return;
}
}
}
// Validate that the new commits are connected with the target
// branch. If they aren't, we want to abort. We do this check by
@ -1288,7 +1292,9 @@ public class ReceiveCommits {
Set<ObjectId> existing = Sets.newHashSet();
walk.markStart(walk.parseCommit(magicBranch.cmd.getNewId()));
if (magicBranch.baseCommit != null) {
walk.markUninteresting(magicBranch.baseCommit);
for (RevCommit c : magicBranch.baseCommit) {
walk.markUninteresting(c);
}
assert magicBranch.ctl != null;
Ref targetRef = allRefs.get(magicBranch.ctl.getRefName());
if (targetRef != null) {