git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: William Pursell
Message 2 of 2 in “characterizing commits”
  1. William PursellDec 13, 2008
  2. Jeff KingDec 13, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.