threads / bug / 49089

Bug? Git won't apply a split hunk that went through a text editor

Subject: Bug? Git won't apply a split hunk that went through a text editor

## tl;dr

3 messages between Aug 10, 2018 and Aug 10, 2018.

replies: 2people: 3as markdown or json

Philip White· Aug 10, 2018, 03:17 UTC · lore
Hello, git enthusiasts,
I’d like to report what I suspect is a bug in Git, tested in 2.18 and 2.14. (I’d be delighted to be corrected if it is my own misunderstanding.) I’m reporting it here based on guidance from https://git-scm.com/community.
I created a minimal testcase with a detailed README here: https://github.com/philipmw/git-bugreport-2018-hunk-fail
Overview of the bug:
When interactively selecting hunks to apply, using `git checkout -p <tree> <file>`, git will correctly apply an unmodified hunk, but will refuse to apply a hunk that went through a text editor ("e" command), even when I made no changes in the text editor.
Thanks for any advice or attention you can give to this matter.

— Philip

Jeff King· Aug 10, 2018, 18:27 UTC · re: Philip White · lore

Re: Bug? Git won't apply a split hunk that went through a text editor

On Thu, Aug 09, 2018 at 08:17:36PM -0700, Philip White wrote:
Show 16 quoted lines
> I’d like to report what I suspect is a bug in Git, tested in 2.18 and
> 2.14. (I’d be delighted to be corrected if it is my own
> misunderstanding.) I’m reporting it here based on guidance from
> https://git-scm.com/community.
> 
> I created a minimal testcase with a detailed README here:
> https://github.com/philipmw/git-bugreport-2018-hunk-fail
> 
> Overview of the bug:
> 
> When interactively selecting hunks to apply, using `git checkout -p
> <tree> <file>`, git will correctly apply an unmodified hunk, but will
> refuse to apply a hunk that went through a text editor ("e" command),
> even when I made no changes in the text editor.
> 
> Thanks for any advice or attention you can give to this matter.
This sounds like the bug discussed in:
  https://public-inbox.org/git/be321106-2f10-e678-8237-449d2dd30fee@talktalk.net/
(that message and the surrounding thread).

The fix is in f4d35a6b49 (add -p: fix counting empty context lines in edited patches, 2018-06-11), which is in the current tip of 'master', but not yet any released version.

-Peff
Phillip Wood· Aug 10, 2018, 19:14 UTC · re: Jeff King · lore

Re: Bug? Git won't apply a split hunk that went through a text editor

Hi Philip
Thanks for CC'ing me Peff.
On 10/08/18 19:27, Jeff King wrote:
Show 22 quoted lines
> On Thu, Aug 09, 2018 at 08:17:36PM -0700, Philip White wrote:
> 
>> I’d like to report what I suspect is a bug in Git, tested in 2.18 and
>> 2.14. (I’d be delighted to be corrected if it is my own
>> misunderstanding.) I’m reporting it here based on guidance from
>> https://git-scm.com/community.
>>
>> I created a minimal testcase with a detailed README here:
>> https://github.com/philipmw/git-bugreport-2018-hunk-fail
>>
>> Overview of the bug:
>>
>> When interactively selecting hunks to apply, using `git checkout -p
>> <tree> <file>`, git will correctly apply an unmodified hunk, but will
>> refuse to apply a hunk that went through a text editor ("e" command),
>> even when I made no changes in the text editor.
>>
>> Thanks for any advice or attention you can give to this matter.
> 
> This sounds like the bug discussed in:
> 
>    https://public-inbox.org/git/be321106-2f10-e678-8237-449d2dd30fee@talktalk.net/

Looking at the bug report Philip linked to I think this is a long standing bug where splitting a patch and then editing one of the subhunks can fail because git-add--interactive.perl doesn't know how to stitch the subhunks back together when one of them has been edited. There's a failing test in t3701-add-interactive.sh to document this. It is on my radar to fix this (at least in simple cases) but I haven't got round to it yet.

Thanks Philip for the detailed report
Best Wishes
Phillip
Show 8 quoted lines
> (that message and the surrounding thread).
> 
> The fix is in f4d35a6b49 (add -p: fix counting empty context lines in
> edited patches, 2018-06-11), which is in the current tip of 'master',
> but not yet any released version.
> 
> -Peff
> 

← back to recent threads