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
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jun 3, 2009, 22:17 UTC
Message-ID
<alpine.LFD.2.01.0906031504080.4880@localhost.localdomain>
In-Reply-To
<7v8wk96knh.fsf@alter.siamese.dyndns.org>
On Wed, 3 Jun 2009, Junio C Hamano wrote:
Show 20 quoted lines
> Linus Torvalds <torvalds@linux-foundation.org> writes:
> 
> > The original problem was:
> >
> >  - create new file 'x' in branch 'a'
> >
> >  - merge branch 'a' into branch 'b', but because of a merge conflict and 
> >    confurion in the merge, the merge result doesn't contain 'x' any more.
> >
> >  - try to find out what happened to 'x' after-the-fact.
> >
> > Try it. Git really doesn't make it very easy, because git will notice that 
> > 'x' didn't exist before the branch either (in branch 'b'), so there will 
> > be _no_ sign of 'x' actually going away.
> 
> That is true.  The "crude attempt" patch I just sent actually catches
> this, but it does not show the lossage of "new" in the "diff/diffstat"
> part of the merge, when run with "git log --stat -- x".  Besides, it shows
> too many other uninteresting "merged two branches, resolving to lossage of
> the path the same way as all the previous merges" to be really useful.
Yes.

Thinking more about it, we always did have fairly good workarounds for the "we optimized away the history too aggressively" (ie the original --full-history, and then the newer and nicer --simplify-merges).

So I'm starting to suspect that I was just wrong in looking at the revision history simplification. Yes, that can cause simplification that we don't want, but on the other hand, it's reasonably easy to work around.

Maybe what we want is a better model for showing diffs from merges.

For example, right now there is _no_ way to get even a "show diff relative to first parent". You can do "-m", which will show it relative to _both_ parents, but nobody ever wants that. And you can do "-c" or "--cc", but that simplifies away all the paths that match in one.

So here's a challenge: in the git repository, get a nice view of what your merges looked like. The closest I can get is

	git log -c --stat --grep="Merge branch '"

which is actually very non-intuitive ("-c" on its own gives no useful output, but "-c --stat" gives nice diffstat against the first parent, which in this case is what we want).

But I can't actually get git to generate the _patch_ that the --stat describes. You'd have to do something like

	git rev-list --parents --grep="Merge branch '" HEAD |
		while read a b c; do git show -s $a ; git diff $b..$a; done | less -S
which is pretty ugly.
			Linus
Previous: Junio C HamanoNext: Junio C Hamano
Message 15 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.