Re: [PATCH 2/4] Tweak diff output further to make it a bit less distracting.

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

Re: [PATCH 2/4] Tweak diff output further to make it a bit less distracting.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:41:57

quoted
quoted
quoted
quoted
"LT" == Linus Torvalds [off-list ref] writes:
LT> There's also a real technical reason for this: since the rename format
LT> would not be a valid patch for a traditional "patch" program, and if we
LT> ever want to actually teach "patch" to handle it, we really need to be
LT> explicit. There are tons of traditional patches around that say

LT> 	diff -Nur a/kernel/sched.c.old b/kernel/sched.c
LT> 	--- a/kernel/sched.c.old
LT> 	+++ b/kernel/sched.c
LT> 	...

LT> and clearly the above is _not_ a rename from "sched.c.old" to "sched.c",
LT> so if we want to teach "patch" about the magic git rules, we'd have to
LT> have something unambiguous that a GNU patch maintainer might be willing to
LT> trigger on. The combination of the "diff -git " and "rename" markers might
LT> be such a thing.

LT> So it's a combination of clarity, canonical names, and "patch" issues.

I've been thinking about doing some rename detection in
diff-helper for some time.  Here is what that would produce in
your proposed file format (BTW, wouldn't the earlier patch ready
for merge already?), if you move file frotz to file nitfol and
at the same time do some edits:

    diff -git a/frotz b/frotz
    rename old frotz
    rename new nitfol
    delete file mode 100644
    --- a/frotz
    +++ /dev/null
    @@ -1,2 +0,0 @@
    -xyzzy
    -rezrov
    diff -git a/nitfol b/nitfol
    rename old frotz
    rename new nitfol
    new file mode 100644
    --- /dev/null
    +++ b/nitfol
    @@ -0,0 +1,2 @@
    +xyzzy
    +rezrov
    diff -git a/nitfol b/nitfol
    rename old frotz
    rename new nitfol
    --- a/nitfol
    +++ b/nitfol
    @@ -1,2 +1,3 @@
     xyzzy
     rezrov
    +gnusto

The basic idea is to express the pure rename with traditional
two patches against /dev/null, plus optionally contents patch on
top after pure rename patches.

I am still debating myself where rename lines should be, though.
I cannot decide so I placed them in all three in the above
example.

Re: [PATCH 2/4] Tweak diff output further to make it a bit less distracting.

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:41:57


On Tue, 17 May 2005, Junio C Hamano wrote:
I've been thinking about doing some rename detection in
diff-helper for some time.  Here is what that would produce in
your proposed file format (BTW, wouldn't the earlier patch ready
for merge already?), if you move file frotz to file nitfol and
at the same time do some edits:
This has the advantage of working with any old "patch" version, but it has 
the disadvantage of being human-unreadable, and big. 

To me, there really are only two reasons to do rename diffs:
 - smaller diffs
 - human readability (you can actually see what changed)

and if you want to have compatibility with a "patch" program that doesn't
support the feature (like your example), you basically lose both of those
advantages. You have _some_ human-readability, but it basically boils down
to "ignore all those deletes/creates".

So I'd really suggest having just a flag that says "pure old diff format"  
or "new diff format with renames", and if the latter is selected, then do
_just_ the changes, ie the rename+change case would really boil down to
getting just
    diff -git a/nitfol b/nitfol
    rename old frotz
    rename new nitfol
    --- a/nitfol
    +++ b/nitfol
    @@ -1,2 +1,3 @@
     xyzzy
     rezrov
    +gnusto
(except I think it would be nice to have the renamed names show up in the 
"diff" and "---/+++" lines too)

		Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help