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

Re: git diff: add option for omitting the contents of deletes

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 28, 2011, 23:28 UTC
Message-ID
<7vfwr7hh7f.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20110228222352.GC5854@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 8 quoted lines
> Yeah, I guess I am just curious whether "similar enough" is really
> relevant with file deletion. Obviously if you have the sha1 then
> everything applies, no problem. But if you don't, how useful is the
> patch text? The patch application will error out with a conflict. You
> know in either case that the person wanted the file deleted. The patch
> text shows you what _their_ version of the file looked like. But that's
> not likely to be useful; what you really care about is what's in _your_
> version of the file, and whether that should be deleted or not.

Exactly; in order to intelligently decide if that should be deleted or not, you need to be able to judge if the deletion makes sense in the context of _your_ tree. Hopefully proposed commit log message alone may clarify if the change applies to your situation, or you need to be able to see if their version and yours are still serving similar purposes in the system (e.g. you don't want to lose the definition of a function they didn't have when they decided to remove the file saying "nobody calls any function in this library anymore").

> If you did really care about what was in their file, the giant deletion
> diff is almost certainly not interesting. What you really care about is
> what's different in their version versus yours.

Correct; the deletion diff has half of the necessary information (the other half being what you have).

> I'm not quite sure what lossage you mean. On the recipient's end? They
> can just "git revert", no?

No, I was not particularly interested in limiting the discussion to git-using population. As I said, just like rename patch can be manually applied by first moving and then eyeballing, you can see "an instruction to delete--ok, 'rm'" to apply it and the file is gone (unlike the case where you manually did "mv"). That is what I meant by "additionally -D has lossage".

Show 25 quoted lines
>> It may make sense to show such a patch still with a bit of context,
>> perhaps like this:
>> 
>>      README |   54 ------------------------------------------------------
>>      1 files changed, 0 insertions(+), 54 deletions(-)
>> 
>>     diff --git -D a/README b/README
>>     deleted file mode 100644
>>     index 67cfeb2..0000000
>>     --- a/README
>>     +++ /dev/null
>>     @@ -1,54 +0,0 @@
>>     -////////////////////////////////////////////////////////////////
>>     -
>>     -	GIT - the stupid content tracker
>>     -...
>>     -the discussion following them on the mailing list give a good
>>     -reference for project status, development direction and
>>     -remaining tasks.
>> 
>> so that the reader can have some warm and fuzzy feeling that the correct
>> file is being deleted, though.
>
> Hmm. I think that is even worse. It's _still_ spammy, and it's broken as
> a diff (the sha1 in the index line doesn't match the preimage that the

That is very much intentional; I don't think we want the format to apply mechanically. I was not talking about patch application safety at all in this thread; I already dismissed "-D" as too unreliable as a patch format to be used for conveying a change for mechanical consumption, didn't I? When you want to do so, you just generate the output without -D.

The suggestion to give some context is only for people who want to eyeball their own patches, helping them to make sure that they are removing what they wanted to remove. If they can tell from the filename alone, that is just as fine. I am not interested that deeply here; the only thing I care about is to make sure we don't have to keep carrying crappy options as if they are sane.

Previous: Jeff KingNext: Junio C Hamano
Message 18 of 32 in “git diff: add option for omitting the contents of deletes”
  1. Mart SõmermaaFeb 26, 2011
  2. Junio C HamanoFeb 26, 2011
  3. Michael J GruberFeb 27, 2011
  4. Mart SõmermaaFeb 27, 2011
  5. Michael J GruberFeb 28, 2011
  6. Mart SõmermaaFeb 28, 2011
  7. Junio C HamanoFeb 27, 2011
  8. Junio C HamanoFeb 27, 2011
  9. Michael J GruberFeb 28, 2011
  10. Jeff KingFeb 28, 2011
  11. Jeff KingFeb 28, 2011
  12. Michael J GruberFeb 28, 2011
  13. Jeff KingFeb 28, 2011
  14. Michael J GruberFeb 28, 2011
  15. Jeff KingFeb 28, 2011
  16. Junio C HamanoFeb 28, 2011
  17. Jeff KingFeb 28, 2011
  18. Junio C HamanoFeb 28, 2011
  19. Junio C HamanoMar 1, 2011
  20. Mart SõmermaaMar 7, 2011
  21. Michael J GruberMar 8, 2011
  22. Junio C HamanoMar 8, 2011
  23. Mart SõmermaaMar 8, 2011
  24. Jeff KingMar 8, 2011
  25. symling diff driver (Was: Re: git diff: add option for omitting the contents of deletes)Michael J Gruber, Feb 28, 2011
  26. Jeff KingFeb 28, 2011
  27. attr: make attributes depend on file typeMichael J Gruber, Feb 28, 2011
  28. Jeff KingFeb 28, 2011
  29. Junio C HamanoFeb 28, 2011
  30. Michael J GruberMar 1, 2011
  31. Mart SõmermaaFeb 28, 2011
  32. Michael J GruberFeb 28, 2011

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.