{"thread":{"id":"49089","subject":"Bug? Git won't apply a split hunk that went through a text editor","startedAt":"2018-08-10T03:17:39Z","lastAt":"2018-08-10T19:15:01Z","messageCount":3,"participants":["Philip White","Jeff King","Phillip Wood"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"355076","messageId":"43C90F94-C9B8-49E4-A9E9-C1D652B52E2F@mailworks.org","threadId":"49089","inReplyTo":null,"subject":"Bug? Git won't apply a split hunk that went through a text editor","fromName":"Philip White","fromEmail":"philip@mailworks.org","sentAt":"2018-08-10T03:17:36Z","receivedAt":"2018-08-10T03:17:39Z","isPatch":false,"sender":{"key":"philip@mailworks.org","avatar":null},"body":"Hello, git enthusiasts,\n\nI’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.\n\nI created a minimal testcase with a detailed README here: https://github.com/philipmw/git-bugreport-2018-hunk-fail\n\nOverview of the bug:\n\nWhen 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.\n\nThanks for any advice or attention you can give to this matter.\n\n— \nPhilip"},{"id":"355125","messageId":"20180810182745.GA8876@sigill.intra.peff.net","threadId":"49089","inReplyTo":"43C90F94-C9B8-49E4-A9E9-C1D652B52E2F@mailworks.org","subject":"Re: Bug? Git won't apply a split hunk that went through a text editor","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-08-10T18:27:45Z","receivedAt":"2018-08-10T18:27:49Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Aug 09, 2018 at 08:17:36PM -0700, Philip White wrote:\n\n> I’d like to report what I suspect is a bug in Git, tested in 2.18 and\n> 2.14. (I’d be delighted to be corrected if it is my own\n> misunderstanding.) I’m reporting it here based on guidance from\n> https://git-scm.com/community.\n> \n> I created a minimal testcase with a detailed README here:\n> https://github.com/philipmw/git-bugreport-2018-hunk-fail\n> \n> Overview of the bug:\n> \n> When interactively selecting hunks to apply, using `git checkout -p\n> <tree> <file>`, git will correctly apply an unmodified hunk, but will\n> refuse to apply a hunk that went through a text editor (\"e\" command),\n> even when I made no changes in the text editor.\n> \n> Thanks for any advice or attention you can give to this matter.\n\nThis sounds like the bug discussed in:\n\n  https://public-inbox.org/git/be321106-2f10-e678-8237-449d2dd30fee@talktalk.net/\n\n(that message and the surrounding thread).\n\nThe fix is in f4d35a6b49 (add -p: fix counting empty context lines in\nedited patches, 2018-06-11), which is in the current tip of 'master',\nbut not yet any released version.\n\n-Peff\n"},{"id":"355135","messageId":"b487318b-0746-e00b-f088-bfc5bd086ed5@talktalk.net","threadId":"49089","inReplyTo":"20180810182745.GA8876@sigill.intra.peff.net","subject":"Re: Bug? Git won't apply a split hunk that went through a text editor","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-08-10T19:14:40Z","receivedAt":"2018-08-10T19:15:01Z","isPatch":false,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Philip\n\nThanks for CC'ing me Peff.\n\nOn 10/08/18 19:27, Jeff King wrote:\n> On Thu, Aug 09, 2018 at 08:17:36PM -0700, Philip White wrote:\n> \n>> I’d like to report what I suspect is a bug in Git, tested in 2.18 and\n>> 2.14. (I’d be delighted to be corrected if it is my own\n>> misunderstanding.) I’m reporting it here based on guidance from\n>> https://git-scm.com/community.\n>>\n>> I created a minimal testcase with a detailed README here:\n>> https://github.com/philipmw/git-bugreport-2018-hunk-fail\n>>\n>> Overview of the bug:\n>>\n>> When interactively selecting hunks to apply, using `git checkout -p\n>> <tree> <file>`, git will correctly apply an unmodified hunk, but will\n>> refuse to apply a hunk that went through a text editor (\"e\" command),\n>> even when I made no changes in the text editor.\n>>\n>> Thanks for any advice or attention you can give to this matter.\n> \n> This sounds like the bug discussed in:\n> \n>    https://public-inbox.org/git/be321106-2f10-e678-8237-449d2dd30fee@talktalk.net/\n\nLooking at the bug report Philip linked to I think this is a long \nstanding bug where splitting a patch and then editing one of the \nsubhunks can fail because git-add--interactive.perl doesn't know how to \nstitch the subhunks back together when one of them has been edited. \nThere's a failing test in t3701-add-interactive.sh to document this. It \nis on my radar to fix this (at least in simple cases) but I haven't got \nround to it yet.\n\nThanks Philip for the detailed report\n\nBest Wishes\n\nPhillip\n\n\n> (that message and the surrounding thread).\n> \n> The fix is in f4d35a6b49 (add -p: fix counting empty context lines in\n> edited patches, 2018-06-11), which is in the current tip of 'master',\n> but not yet any released version.\n> \n> -Peff\n> \n\n"}]}