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
Mart Sõmermaa <mrts.pydev@gmail.com>
Date
Feb 28, 2011, 10:45 UTC
Message-ID
<AANLkTim-vyWhgmFuewbd5e5iJiTC-EHz7g=efr2Sz-RH@mail.gmail.com>
In-Reply-To
<7v39n9uldp.fsf@alter.siamese.dyndns.org>
Why not just make it reversible then?
$ git diff -M
diff --git a/foo b/bar
similarity index 100%
rename from foo
rename to bar

is nonreversible without git already (i.e. does not work with plain
patch AFAIK).

Adding

$ git diff -D
diff --git a/foo b/foo
deleted file mode 100644
delete foo

would be neither less nor more reversible -- it would also only work
with git apply
(assuming that apply is amended accordingly).

Cognitive burdens aside, the "delete foo" output is both
more explicit and shorter anyway. Occam's razor FTW :)!

Junio, I won't push this further, so it's a final call -- if you give -1,
then let -D fall to the colourless abyss of oblivion :), if +1 or +0,
I'll see if I can come up with a patch.

Best regards,
MS

On Mon, Feb 28, 2011 at 1:07 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Michael J Gruber <git@drmicha.warpmail.net> writes:
>>
>>> Wasn't the pager invented for sifting through output which has to be
>>> several pages, but not not for that which could be more concise? ;)
>>>
>>> In fact, -D would be quite analogous to -M and -C in that respect.
>>
>> There is a big difference: -M and -C lets your recipient reproduce the
>> state using the change you are trying to convey with the diff output in
>> either direction (iow, "apply -R" works), but your "-D" would not have
>> that property.
>
> Having said that we have always valued "reversibility" and a casual -D is
> not in line with that principle, I don't have a strong objection if the
> new mode of operation is marked clearly as "nonusable if you are trying to
> produce appliable diff (iow, don't send such a patch to mailing list--it
> is for viewing purposes only)", treating it just like the --color-words
> and the --stat options (there isn't even need to mark these as unusable
> for that purpose, as people with common sense would be able to guess).
>
> If we were to do this, it probably is a good idea to apply that for a
> typechange patch (the one that is produced when a symlink turns into a
> regular file and vice versa) as well.  It also might make sense to apply
> the similar principle to shorten the output with -B when a rewrite patch
> is expressed as a single hunk patch that removes everything old and then
> adds everthing new.
>
Previous: Michael J GruberNext: Michael J Gruber
Message 31 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.