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

Finding all commits which modify a file

From
NGNeal Groothuis <ngroot@lo-cal.org>
Date
Jan 20, 2012, 21:35 UTC
Message-ID
<46043.208.70.151.129.1327095331.squirrel@mail.lo-cal.org>
Hello,

I'm trying to find /all/ commits that change a file in the repository...and its proving to be trickier than I thought. :-)

The situation that we were dealing with is this:
- Person A and person B both pull from the same central repository.
- Person A makes a change to file foo.txt and bar.txt, commits, and pushes
to the central repository.
- Person B makes a similar change to bar.txt and commits it.
- Person B does a fetch and merge.  Since both A and B made changes to
bar.txt, this requires conflicts to be resolved manually.
- B reverts A's changes to foo.txt. (If B is coming from a different
revision control system, this may happen due to confusion about how merges
are handled.)
- B commits the changes.
- B makes more changes to bar.txt, commits them, and pushes to the central
repository.
At this point, A's changes to foo.txt have been undone.
Graphically:
    A1
   /  ^
  v    \
  C1   B2<-B3
  ^    /
   \  v
    B1
B1, B2, and B3 have the same version of foo.txt as C1, A1 modifies it.

Person A discovers that his changes are missing and wants to know what happened.

git log foo.txt doesn't help; it won't even show commit A1, due to history simplification.

git log --full-history foo.txt will show commit A1. It still won't show commit B2, though, which we'd also like to show (because that's where the change to foo.txt got removed).

I would think that git log --simplify-merges foo.txt would have done what I'd wanted, but it still does not show commit B2. Based on what I'm reading in the man page, I would expect the simplification to go like this:

    A1
    | ^
    |  \
    |  B2<-B3
    |  /
    v v
    C1
(since B1 is TREESAME as C1 if we're only considering foo.txt)
    A1
    | ^
    |  \
    |  B2<-B3
    |
    v
    C1
(since C1 is an ancestor of A1)
However, the actual output only includes A1, not B2.
 - Can someone explain this, and/or
 - can someone offer a command to display all commits (including merges)
in which ANY parent is not TREESAME?
Thanks!
- Neal
Next: Neal Kreitzinger
Message 1 of 14 in “Finding all commits which modify a file”
  1. Neal GroothuisJan 20, 2012
  2. Neal KreitzingerJan 21, 2012
  3. Neal GroothuisJan 23, 2012
  4. Santi BéjarJan 24, 2012
  5. Santi BéjarJan 24, 2012
  6. Linus TorvaldsJan 24, 2012
  7. Santi BéjarJan 24, 2012
  8. Santi BéjarJan 24, 2012
  9. Junio C HamanoJan 24, 2012
  10. Neal GroothuisJan 24, 2012
  11. Santi BéjarJan 24, 2012
  12. Neal GroothuisJan 25, 2012
  13. Junio C HamanoJan 26, 2012
  14. Tay Ray ChuanJan 22, 2012

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.