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

Re: Am able to delete a file with no trace in the log

From
Jeff King <peff@peff.net>
Date
Jun 2, 2009, 21:34 UTC
Message-ID
<20090602213439.GA7584@coredump.intra.peff.net>
In-Reply-To
<EB2D87B9-3B03-431A-B204-C7799F9BA291@ausperks.net>
On Tue, Jun 02, 2009 at 02:33:14PM -0500, Graham Perks wrote:
Show 6 quoted lines
> # File b.txt deleted! Woah! How did that happen?
> # gitk and git log show nothing about the deletion.
> # There seems to be no evidence about who, how, why, or when the file got 
> deleted.
> # So it's hard to track down which user mis-used the system and educate 
> them.

I think this is a funny interaction with the way the diffs for merge commits are shown. The diff you are looking for is definitely available. In your example:

  # compare the second parent of the merge to the merge result
  $ git diff-tree HEAD^2 HEAD
  :100644 100644 31e0fce560e96c8b357f5b8630c7d8fbeb0a3ec8 2dc6d98afe942589307d7c0166971b3a2ec8706d M      a.txt
  :100644 000000 b023018cabc396e7692c70bbf5784a93d3f738ab 0000000000000000000000000000000000000000 D      b.txt

But it doesn't show up in "git log". I believe this is because the rule for what to show in a merge commit is "if content is exactly the same as one of the parents, it's not interesting". That is, deleting "b.txt" from the second parent ends up being exactly as it is in the first parent -- nonexistent. So git has no idea that you deleted "b.txt" accidentally, and it was not simply part of the conflict resolution.

So I think this is working as intended, and is not a bug exactly. But certainly the behavior leaves something to be desired for actually tracking down the source of the change later on. I don't think there is a way to get "git show $merge" to show the deletion, and nor does it show up under "git log -- b.txt". Even worse, the latter produces no output at all for your example (you need "--full-history" to tell it to follow both parents of a merge).

I wonder if we need some kind of "--verbose-merges" option to tell the diff engine that we really are interested in all of the changes that happened in a merge. But maybe we even have something and I don't know about it.

-Peff
Previous: Tony FinchNext: Linus Torvalds
Message 3 of 26 in “Am able to delete a file with no trace in the log”
  1. Graham PerksJun 2, 2009
  2. Tony FinchJun 2, 2009
  3. Jeff KingJun 2, 2009
  4. Linus TorvaldsJun 2, 2009
  5. Sitaram ChamartyJun 3, 2009
  6. Linus TorvaldsJun 3, 2009
  7. Clean up and simplify rev_compare_tree()Linus Torvalds, Jun 3, 2009
  8. Junio C HamanoJun 3, 2009
  9. Linus TorvaldsJun 3, 2009
  10. Junio C HamanoJun 3, 2009
  11. Linus TorvaldsJun 3, 2009
  12. Linus TorvaldsJun 3, 2009
  13. Avery PennarunJun 3, 2009
  14. Junio C HamanoJun 3, 2009
  15. Linus TorvaldsJun 3, 2009
  16. Junio C HamanoJun 3, 2009
  17. Jeff KingJun 3, 2009
  18. Linus TorvaldsJun 3, 2009
  19. Jeff KingJun 3, 2009
  20. Linus TorvaldsJun 3, 2009
  21. Jeff KingJun 3, 2009
  22. Linus TorvaldsJun 4, 2009
  23. Junio C HamanoJun 4, 2009
  24. Linus TorvaldsJun 3, 2009
  25. Junio C HamanoJun 3, 2009
  26. Junio C HamanoJun 3, 2009

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.