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

Correctly detecting modified paths in merge commits?

From
Dun Peal <dunpealer@gmail.com>
Date
Dec 16, 2010, 16:54 UTC
Message-ID
<AANLkTimsHZ543B7XWS6taa0w2Vc4huznx3UMs4Ejg3af@mail.gmail.com>
Hi.

We wrote a post-receive hook that alerts users (via email) when specific paths are modified by their peers. The implementation is pretty simple: whenever a new commit is made, we ask git for the full list of files modified by that commit:

  git diff --name-only <COMMIT HASH>^!
This works well for regular commits, but breaks for merge commits.
For example, suppose we have the following basic merge scenario:
  B
 / \
A   D
 \ /
  C
Root A was branched to B and C, then merged into commit D.
Problem is, the diff for D^! will include all the changes introduced by C.
One obvious solution is to simply ignore merge commits, by parsing
`git cat-file commit D` and discarding all commits with parent count >
1. But merge commits may actually contain legitimate modified files if
there were any conflict resolutions.
So what's the best solution for this problem, oh wise Git wizards?
Thanks, D.
Next: Jakub Narebski
Message 1 of 2 in “Correctly detecting modified paths in merge commits?”
  1. Dun PealDec 16, 2010
  2. Jakub NarebskiDec 16, 2010

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.