gitextensions
gitextensions copied to clipboard
Filtering git log to exclude commit messages by regex
I am looking for the correct regex to use in the Filter box in git extensions (v3.3) to exclude all commits containing a certain phrase, i.e., "[Automation]" To remove the visual clutter of commits I don't care about. Is there a way?
Exactly
[Automation]
Or
Automation
?
Provide a sample commit message you would expect to match.
Start with https://regexr.com/5601t and play with it to see what regex would work.

I want to see all commits EXCEPT those containing the string "[Automation]". Positive matches are working fine, it is coming up with the EXCLUSION regex that is puzzling me.
That's what the regex does. Look at the tests I wrote. Did you follow the regexr link?
Thank you, yes. But that regex, when put inside the Filter box of Git Extensions, results in an empty list.
We might need to adjust the options of the Regex object in our code.
You do know you only include what is between the /'s right?
^((?![Automation]).)*$
Yes, I did know that. Looks like maybe the negative lookahead option is not understood by the GitExtensions regex object?
Looks like maybe the negative lookahead option is not understood by the GitExtensions regex object?
that seems to me too. The commit list is empty if
using: ^(?!.*\[\bbot\b\]).*$
or: ^((?!\[bot\]).)*$
to exlude: [bot]
for author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
repo: [email protected]:dotnet/samples.git
verified this testcase at regex101.com and regexr.com/5601t @vbjay ;-)
Git uses Posix BRE by default, any regex in regex101 will not work. https://gist.github.com/CMCDragonkai/6c933f4a7d713ef712145c5eb94a1816
You can use other regex engines https://git-scm.com/docs/git-log#Documentation/git-log.txt---perl-regexp
@gerhardol Could you give a working example because even with the documentation, I don't succeed.
Personally, to only exclude a pattern, I found it easier to pass something like that to the filter box --invert-grep --grep="\[bot\]"
--invert-grep is a much better option than to use a negative filter, even if it should be possible.
There is no GUI for the options. I hope that is not needed and that the dropdown history is sufficient. The box to edit in should be improved though.
Personally, to only exclude a pattern, I found it easier to pass something like that to the filter box
--invert-grep --grep="\[bot\]"
ty for the hint @pmiossec , but this string is also leading to an empty window. Maybe Iam using it wrong, we're talking about to place it there, right ? :
Use Commit message , add string "--invert-grep --fixed-strings --author="[bot]"" (without testing)
Use Commit message , add string "--invert-grep --fixed-strings --author="[bot]"" (without testing)
I have made my testing on commit message (it was working well) but didn't know that for author it is no more working since git 2.35 See https://stackoverflow.com/a/70644305/717372
So the solution to exclude an author is to let filtering on "Commit message" in the "filter type" and pass the value --perl-regexp --author="^(?!.*\[bot\]).*$"
Use Commit message , add string "--invert-grep --fixed-strings --author="[bot]"" (without testing)
this does not filter, but ty for the idea.
So the solution to exclude an author is to let filtering on "Commit message" in the "filter type" and pass the value
--perl-regexp --author="^(?!.*\[bot\]).*$"
that works, ty ! ..... how expected, what a difference in readability
Use Commit message , add string "--invert-grep --fixed-strings --author="[bot]"" (without testing)
this does not filter, but ty for the idea.
Yes, as it is described in the link provided, since git v2.35, --invert-grep is working only on commit message (so on --grep="" parameter) whereas it was working on other parameter --author, committer, ...-- before. But it could still be used to exclude based on commit message because the syntax is a lot easier! (and that's even the answer for the original request.