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
Jeff King <peff@peff.net>
Date
Mar 8, 2011, 21:31 UTC
Message-ID
<20110308213133.GA5786@sigill.intra.peff.net>
In-Reply-To
<AANLkTim9juvhBJKraHBkV8AC=zY75xt_1BnyhTDTcoUZ@mail.gmail.com>
On Tue, Mar 08, 2011 at 11:25:04PM +0200, Mart Sõmermaa wrote:
Show 21 quoted lines
> "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."
> 
> I have to admit that I've never used -B, only -M, so please don't mind that
> its semantics and exact behavior are a bit foreign to me.
> 
> After running t/t4130-apply-criss-cross-rename.sh,
> `git diff -M -B` outputs the following:
> 
> diff --git a/file2 b/file1
> similarity index 100%
> rename from file2
> rename to file1
> diff --git a/file1 b/file2
> similarity index 100%
> rename from file1
> rename to file2
> 
> Can you bring a similar example of changes in the output after
> the above-mentioned similar principle has been implemented for -B?
Try:
  $ git init
  $ perl -e 'print "a\n" for (1 .. 1000)' >file
  $ git add file && git commit -m one
  $ perl -e 'print "b\n" for (1 .. 1000)' >file
Now you can see that -B breaks notes it as a rewrite:
  $ git diff --stat --summary -B
   file | 2000 +++++++++++++++++++++++++++----------------------------
   1 files changed, 1000 insertions(+), 1000 deletions(-)
   rewrite file (100%)
And the diff is long:
  $ git diff -B
  diff --git a/file b/file
  dissimilarity index 100%
  index 5cfafaa..a7b871a 100644
  --- a/file
  +++ b/file
  @@ -1,1000 +1,1000 @@
  -a
  -a
  [... x 1000]
  +b
  +b
  [... x 1000]

But we could perhaps drop the actual 1000-line hunks (or maybe even just the deletion half).

-Peff
Previous: Mart SõmermaaNext: Michael J Gruber
Message 24 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.