grgit icon indicating copy to clipboard operation
grgit copied to clipboard

LogOp: Support for --first-parent and --no-merges

Open nikolauskrismer opened this issue 9 years ago • 5 comments

Hi,

first I have to write a big "THANK YOU" for this plugin. It helps me a lot dealing with git in gradle.

However, there is one thing that's missing that I would need. Is it possible to get a result from LogOp that's identical to "git log myTag --first-parent --no-merges"?

By now I get all commit messages, but in fact I only want those from the master branch without merge commit messages. The "--first-parent --no-merges" options are also explained here (that's why I found them): http://stackoverflow.com/questions/10248137/git-how-to-list-commits-on-this-branch-but-not-from-merged-branches

nikolauskrismer avatar Sep 05 '15 11:09 nikolauskrismer

I don't think JGit has direct support for those options (see LogCommand). Since I try to stick to JGit's porcelain commands, I'd suggest filing an issue with JGit to see if that could be enhanced.

ajoberstar avatar Sep 05 '15 13:09 ajoberstar

Ok... I understand. Thanks for the support so far.

I filled a bug for jgit (Bug 476697 here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=476697). Let's see if they are willing to extend LogCommand. If so, it would be great to have these options in grgit also (and if not you can close this bug :-)

nikolauskrismer avatar Sep 05 '15 13:09 nikolauskrismer

Yeah, if they patch it let me know and this can be enhanced.

ajoberstar avatar Sep 06 '15 15:09 ajoberstar

Confirming that the JGit bug is still open as of 10/22/2017.

ajoberstar avatar Oct 22 '17 20:10 ajoberstar

As workaround for --no-merges you could use the following approach:

grgit.log(maxCommits: 10).find { it.parentIds.size() == 1 }

which is nearly the same as --no-merges. Unfortunately, as filtering happens after the log command has been executed, it is more likely that the result of find is null (I emphasized this in the example by using maxCommits = 10 as we may end up with 10 log entries in a row, which are all merge commits...).

While it seems to be unlikely that JGit will support --no-merges directly, it may be possible to use the option RevFilter in LogCommand. As can be seen in JavaDoc of RevFilter, we then have the option to filter for example by no-merges as well as only-merges.

mmichaelis avatar Mar 13 '19 07:03 mmichaelis