diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitLogCommand.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitLogCommand.java index ffed8c5ad4..7f10948ad8 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitLogCommand.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitLogCommand.java @@ -132,7 +132,9 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand { converter = new GitChangesetConverter(gr, revWalk); - if (request != null && !Strings.isNullOrEmpty(request.getBranch())) { + if (request != null && + !Strings.isNullOrEmpty(request.getBranch()) && + revWalk.isMergedInto(commit, findTipCommitForRequestBranch(request, gr, revWalk))) { changeset = converter.createChangeset(commit, request.getBranch()); } else { changeset = converter.createChangeset(commit); @@ -163,6 +165,10 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand return changeset; } + private RevCommit findTipCommitForRequestBranch(LogCommandRequest request, Repository gr, RevWalk revWalk) throws IOException { + return revWalk.parseCommit(GitUtil.getCommit(gr, revWalk, gr.findRef(request.getBranch()))); + } + /** * Method description *