Re: characterizing commits
- From
Jeff King <peff@peff.net>
- Date
- Dec 13, 2008, 08:52 UTC
- Message-ID
- <20081213085228.GA20282@coredump.intra.peff.net>
- In-Reply-To
- <4943721C.7070200@gmail.com>
On Sat, Dec 13, 2008 at 08:28:12AM +0000, William Pursell wrote:
Show 13 quoted lines
> A lot of commits in any given project can be grouped into > different types. eg, looking at the history for git, > there are a lot of merge commits, a lot of commits > that only touch gitk, a lot of 'auto-generated manpages', > a lot of 'typo in documentation' etc. In my own > projects, I have a fairly high percentage of commits > that are trivial (eg whitespace only, typos, etc). > What I'm after is the ability to do something like: > > git log --group=!trivial > git log --group=importance:3+ > > [...]
> Is there already a mechanism for filtering > commits that I could extend to accomplish this?
Generally you would put a pseudo-header into your commit message, like:
Status: trivial Importance: 3
and then use --grep to filter matching commits:
git log --grep="Status: trivial" git log --grep="Importance: [3-9]"
Obviously the syntax is a little bit clunkier. You could fix that with an option to parse arbitrary pseudo-headers (and even support numeric relations), something like:
git log --filter='importance > 3'
which would be converted internally to a grep of the commit message like this:
/^importance: (\d+)/i
and compare the result to 3.
The nice thing about that approach is that the storage remains the same: text in the commit message. That means it gets displayed when you look at the commit, people with older versions of git can still read it, etc.
One thing this _doesn't_ get you is annotating commits after the fact. This has been discussed in the past; try searching the list for "notes".
-Peff