{"thread":{"id":"26553","subject":"stash --patch splitting","startedAt":"2011-02-19T00:49:20Z","lastAt":"2011-02-19T00:49:20Z","messageCount":1,"participants":["Jeffrey Middleton"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"161573","messageId":"AANLkTimcUi0jKK2AWsw7MHNdHFWbKFSjBixeM0pU74+a@mail.gmail.com","threadId":"26553","inReplyTo":null,"subject":"stash --patch splitting","fromName":"Jeffrey Middleton","fromEmail":"jefromi@gmail.com","sentAt":"2011-02-19T00:49:20Z","receivedAt":"2011-02-19T00:49:20Z","isPatch":false,"sender":{"key":"jefromi@gmail.com","avatar":null},"body":"git stash --patch doesn't appear to play nice with splitting hunks:\n\n\tmkdir stash-p &&\n\tcd stash-p &&\n\tgit init &&\n\tseq 1 3 > a &&\n\tgit add a &&\n\tgit commit -m \"add a\" &&\n\tsed -i 's/[13]/&&/' a &&\n\t(echo s; echo y; echo n) | git stash -p\n\nThat's a file with three lines, a modification to lines 1 and 3, then\nan attempt to partially stash, splitting and stashing the modification\nto line 1 but not line 3. It looks like the patch generated to roll\nback the selected changes is faulty somehow:\n\n\tSaved working directory and index state WIP on master: 7cb76e1 add a\n\terror: patch failed: a:1\n\terror: a: patch does not apply\n\tCannot remove worktree changes\n\nThe patch that git-stash attempts to reverse-apply looks sort of reasonable:\n\n\tdiff --git a/a b/a\n\tindex 01e79c3..88483cf 100644\n\t--- a/a\n\t+++ b/a\n\t@@ -1,3 +1,3 @@\n\t-1\n\t+11\n\t 2\n\t 3\n\nbut it doesn't apply, since the third line is now different in the\nwork tree. The patch I'd really expect to see would have \"33\" on the\nthird line. I've been staring at all the temporary index files\n(git-stash.sh:105 and on) and the stash mode in\ngit-add--interactive.perl and trying to figure out where it goes\nwrong, but I don't think I'm going to get it right now. Maybe one of\ny'all will immediately see it?\n\n\nThanks,\nJeffrey\n"}]}