Skip also target branch history when using the %base option with push

The %base option marked only the base commit as uninteresting when doing
the tree walk to find the commits for which to create changes. It didn't
mark the (top of) the target branch as uninteresting. This is an issue
when, in the following scenario, we want to push the commit M (which was
already pushed to the foo branch) to the master branch for review:

  $ git push origin M:refs/for/master%base=c

              M  (foo)
             /|
            / |
  (master) b  c
           | /
           |/
           a

The tree walk would reach commit "b", find out that the change where it
was reviewed is already closed and the push will fail. While it makes
sense to push "M" to master for review it doesn't make sense to push "b"
as it was already reviewed on that branch.

Therefore, excluding the target branch from the tree walk makes sense
and it also doesn't contradict the original purpose of the %base option.

Change-Id: Ie8c22a43b111772a6f4abb5dc237823dc1df0911
This commit is contained in:
Sasa Zivkov
2013-09-18 15:45:59 +02:00
parent cb0fcc2f79
commit 9f1db5860f

View File

@@ -1253,6 +1253,11 @@ public class ReceiveCommits {
walk.markStart(walk.parseCommit(magicBranch.cmd.getNewId()));
if (magicBranch.baseCommit != null) {
walk.markUninteresting(magicBranch.baseCommit);
assert magicBranch.ctl != null;
Ref targetRef = allRefs.get(magicBranch.ctl.getRefName());
if (targetRef != null) {
walk.markUninteresting(walk.parseCommit(targetRef.getObjectId()));
}
} else {
markHeadsAsUninteresting(
walk,