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

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:44

Mart Sõmermaa [off-list ref] writes:
On Tue, Mar 1, 2011 at 2:11 AM, Junio C Hamano [off-list ref] wrote:
quoted
In any case, a minimum patch to give what Mart wanted to see would
probably look like this.  I'll leave bugfixes, documentation and tests to
the readers ;-).
The minimum looks to be the optimum -- IMHO this is entirely sufficient,
I suspect not, as I don't think I ever did anything to the codepath for -B
output, and I also recall spending some time thinking about this issue in
an earlier message that I mentioned -B besides "deletion", none of the
suggestions in which I don't think I tried to implement.

I also vaguely recall that I suspected that the output may not have the
usual "index deadbeaf..000000 mode" line and that I chose to ignore it.

So, no, not good enough ;-).

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

From: Mart Sõmermaa <hidden>
Date: 2016-06-15 22:50:44

On Tue, Mar 8, 2011 at 9:49 PM, Junio C Hamano [off-list ref] wrote:
Mart Sõmermaa [off-list ref] writes:
quoted
On Tue, Mar 1, 2011 at 2:11 AM, Junio C Hamano [off-list ref] wrote:
quoted
In any case, a minimum patch to give what Mart wanted to see would
probably look like this.  I'll leave bugfixes, documentation and tests to
the readers ;-).
The minimum looks to be the optimum -- IMHO this is entirely sufficient,
I suspect not, as I don't think I ever did anything to the codepath for -B
output, and I also recall spending some time thinking about this issue in
an earlier message that I mentioned -B besides "deletion", none of the
suggestions in which I don't think I tried to implement.
Your suggestion is as follows:

"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?
I also vaguely recall that I suspected that the output may not have the
usual "index deadbeaf..000000 mode" line and that I chose to ignore it.
'deadbeaf' is present:

$ ../git/bin-wrappers/git diff -D HEAD
diff --git a/foo.txt b/foo.txt
deleted file mode 100644
index 257cc56..0000000
Can we perhaps consider the -B behavior orthogonal to -D (unless I am missing
something very important here)?

Best regards,
MS

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

From: Jeff King <hidden>
Date: 2016-06-15 22:50:44

On Tue, Mar 08, 2011 at 11:25:04PM +0200, Mart Sõmermaa wrote:
quoted hunk
"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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help