Skip to contentSkip to conversation

git format-patch --break-rewrites broken in 2.9.3

DISCUSSION Olaf Hering 7 participants 11 messages Aug 18, 2016 – Aug 19, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

This command used to create a diff which can be consumed by patch. But at least with 2.9.3 it just gives a rename output:

 git format-patch \
        --no-signature \
        --stdout \
        --break-rewrites \
        --keep-subject \

95fa0405c5991726e06c08ffcd8ff872f7fb4f2d^..95fa0405c5991726e06c08ffcd8ff872f7fb4f2d

What must be done now to get a usable patch?

Olaf

#1 lore raw

Hi Olaf,

Quoted 8 lines · Olaf Hering

This command used to create a diff which can be consumed by patch. But at least with 2.9.3 it just gives a rename output:

 git format-patch \
        --no-signature \
        --stdout \
        --break-rewrites \
        --keep-subject \
Quoted 4 lines

95fa0405c5991726e06c08ffcd8ff872f7fb4f2d^..95fa0405c5991726e06c08ffcd8ff872f7fb4f2d

What must be done now to get a usable patch?

Maybe --no-renames? BTW this behavior was not introduced in 2.9.3, but in 2.9.0:

https://github.com/git/git/blob/v2.9.0/Documentation/RelNotes/2.9.0.txt#L7-L9

Ciao,
Johannes

#2 lore raw
Quoted 6 lines · Johannes Schindelin

Hi Olaf,

Quoted 4 lines
        --break-rewrites \
        --keep-subject \

95fa0405c5991726e06c08ffcd8ff872f7fb4f2d^..95fa0405c5991726e06c08ffcd8ff872f7fb4f2d

Quoted 6 lines
Quoted 1 line

What must be done now to get a usable patch?

Maybe --no-renames? BTW this behavior was not introduced in 2.9.3, but in 2.9.0:

https://github.com/git/git/blob/v2.9.0/Documentation/RelNotes/2.9.0.txt#L7-L9

I think that is one half of the story.

The other half is a long/well known bug that lets "diff -B -M" to produce incorrect/broken patch that cannot be applied. It was documented in the thread that begins at:

public-inbox.org/git/[email protected]

but still hasn't been solved.

#3 lore raw
Quoted 9 lines · Junio C Hamano

I think that is one half of the story.

The other half is a long/well known bug that lets "diff -B -M" to produce incorrect/broken patch that cannot be applied. It was documented in the thread that begins at:

public-inbox.org/git/[email protected]

but still hasn't been solved.

The problem report actually starts here:

public-inbox.org/git/[email protected]/

#4 lore raw
In reply to Olaf Hering
Quoted 8 lines · Olaf Hering

This command used to create a diff which can be consumed by patch. But at least with 2.9.3 it just gives a rename output:

 git format-patch \
        --no-signature \
        --stdout \
        --break-rewrites \
        --keep-subject \
Quoted 4 lines

95fa0405c5991726e06c08ffcd8ff872f7fb4f2d^..95fa0405c5991726e06c08ffcd8ff872f7fb4f2d

What must be done now to get a usable patch?

Probably --no-renames.

Renames were enabled by default by 5404c11 (diff: activate diff.renames by default, 2016-02-25), which is in v2.9.0.

I wonder if we should consider undoing that for format-patch, whose output may be consumed by non-git endpoints.

-Peff

#6 lore raw
In reply to a message not in the archive
Quoted 22 lines · Matthieu Moy
Quoted 20 lines · Jeff King
Quoted 8 lines · Olaf Hering

This command used to create a diff which can be consumed by patch. But at least with 2.9.3 it just gives a rename output:

 git format-patch \
        --no-signature \
        --stdout \
        --break-rewrites \
        --keep-subject \
Quoted 4 lines

95fa0405c5991726e06c08ffcd8ff872f7fb4f2d^..95fa0405c5991726e06c08ffcd8ff872f7fb4f2d

What must be done now to get a usable patch?

Probably --no-renames.

Renames were enabled by default by 5404c11 (diff: activate diff.renames by default, 2016-02-25), which is in v2.9.0.

Quoted 8 lines
Quoted 2 lines

I wonder if we should consider undoing that for format-patch, whose output may be consumed by non-git endpoints.

I would say no (or more precisely: we should consider, but we should reject the idea ;-) ), since patches with renames are useful and can be used even outside Git's scope. GNU patch, which is probably the most widely used implementation of patch supports git-style renames since 2.7, released in September 2012.

Ah, OK; I didn't realize GNU patch had picked up rename support. I agree that makes it less-bad for format-patch to start using them by default. Olaf, what version of patch are you using?

-Peff

#9 lore raw
In reply to Jeff King
Quoted 15 lines · Jeff King
Quoted 8 lines · Olaf Hering

This command used to create a diff which can be consumed by patch. But at least with 2.9.3 it just gives a rename output:

 git format-patch \
        --no-signature \
        --stdout \
        --break-rewrites \
        --keep-subject \
Quoted 4 lines

95fa0405c5991726e06c08ffcd8ff872f7fb4f2d^..95fa0405c5991726e06c08ffcd8ff872f7fb4f2d

What must be done now to get a usable patch?

Quoted 7 lines

Probably --no-renames.

Renames were enabled by default by 5404c11 (diff: activate diff.renames by default, 2016-02-25), which is in v2.9.0.

I wonder if we should consider undoing that for format-patch, whose output may be consumed by non-git endpoints.

By the way, this probably has nothing to do with --break-rewrites in particular. It would come up for any case where git finds a rename. In the absence of --break-rewrites, that requires a path being deleted and one being added. But in this particular case, --break-rewrites turns a large change into a delete/add pair, which lets git find the rename.

So it's a necessary option to show the problem in _this_ instance, but there are other cases that would not need it.

-Peff

#8 lore raw
In reply to Olaf Hering
Quoted 7 lines · Olaf Hering
Quoted 1 line · Jeff King

Olaf, what version of patch are you using?

Mostly 2.7.x, but also add 2.5.x to the mix.
So far I did not try what the tools dealing with the resulting patch file would actually do with such a stripped down variant.

I think the way to go is --no-renames until you stop using patch <2.7. If you don't want to specify it each time, you can revert to the pre-2.9 behavior by setting

[diff]
renames = false

in ~/.gitconfig.

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#7 lore raw
In reply to Jeff King
Quoted 1 line · Jeff King

Olaf, what version of patch are you using?

Mostly 2.7.x, but also add 2.5.x to the mix.
So far I did not try what the tools dealing with the resulting patch file would actually do with such a stripped down variant.

Olaf

#10 lore raw
In reply to Olaf Hering
Quoted 9 lines · Olaf Hering

This command used to create a diff which can be consumed by patch. But at least with 2.9.3 it just gives a rename output:

 git format-patch \
        --no-signature \
        --stdout \
        --break-rewrites \
        --keep-subject \
Quoted 4 lines

95fa0405c5991726e06c08ffcd8ff872f7fb4f2d^..95fa0405c5991726e06c08ffcd8ff872f7fb4f2d

What must be done now to get a usable patch?

As an aside, the range can be shortened to

95fa0405c5991726e06c08ffcd8ff872f7fb4f2d^!

It's something I picked up when doing the doc update on 'specifying revisions'.

--

Philip

#11 lore raw
Quoted 11 lines · Philip Oakley
Quoted 9 lines · Olaf Hering

This command used to create a diff which can be consumed by patch. But at least with 2.9.3 it just gives a rename output:

 git format-patch \
        --no-signature \
        --stdout \
        --break-rewrites \
        --keep-subject \
Quoted 8 lines
Quoted 4 lines

95fa0405c5991726e06c08ffcd8ff872f7fb4f2d^..95fa0405c5991726e06c08ffcd8ff872f7fb4f2d

What must be done now to get a usable patch?

As an aside, the range can be shortened to

95fa0405c5991726e06c08ffcd8ff872f7fb4f2d^!

In the context of format-patch you can also use -1 to select the topmost commit from the list.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."