Fix incoming diff with merges from target branch.

Taking the git history example below, the previous version only computed
commits 'b3' upward for log of 'b' with ancestor 'master' and missed
commits 'b1', 'b2' and the first merge.

* 86e9ca0 (HEAD -> b) b5
*   d69edb3 Merge branch 'master' into b
|\
| * 946a8db (master) f
| * b19b9cc e
* | 3d6109c b4
* | 6330653 b3
* |   a49a28e Merge branch 'master' into b
|\ \
| |/
| * 0235584 d
| * 20251c5 c
* | 5023b85 b2
* | 201ecc1 b1
|/
* 36b19e4 b
* c2190a9 a
This commit is contained in:
René Pfeuffer
2018-12-19 13:33:57 +01:00
parent eaeb95077e
commit a9300df7f4
2 changed files with 106 additions and 5 deletions

View File

@@ -205,7 +205,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
ObjectId ancestorId = null;
if (!Strings.isNullOrEmpty(request.getAncestorChangeset())) {
ancestorId = computeCommonAncestor(request, repository, startId, branch);
ancestorId = repository.resolve(request.getAncestorChangeset());
}
revWalk = new RevWalk(repository);
@@ -225,16 +225,15 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
revWalk.markStart(revWalk.lookupCommit(branch.getObjectId()));
}
if (ancestorId != null) {
revWalk.markUninteresting(revWalk.lookupCommit(ancestorId));
}
Iterator<RevCommit> iterator = revWalk.iterator();
while (iterator.hasNext()) {
RevCommit commit = iterator.next();
if (commit.getId().equals(ancestorId)) {
break;
}
if ((counter >= start)
&& ((limit < 0) || (counter < start + limit))) {
changesetList.add(converter.createChangeset(commit));