stash --patch splitting

From: Jeffrey Middleton <hidden>
Date: 2016-06-15 22:50:36

git stash --patch doesn't appear to play nice with splitting hunks:

	mkdir stash-p &&
	cd stash-p &&
	git init &&
	seq 1 3 > a &&
	git add a &&
	git commit -m "add a" &&
	sed -i 's/[13]/&&/' a &&
	(echo s; echo y; echo n) | git stash -p

That's a file with three lines, a modification to lines 1 and 3, then
an attempt to partially stash, splitting and stashing the modification
to line 1 but not line 3. It looks like the patch generated to roll
back the selected changes is faulty somehow:

	Saved working directory and index state WIP on master: 7cb76e1 add a
	error: patch failed: a:1
	error: a: patch does not apply
	Cannot remove worktree changes

The patch that git-stash attempts to reverse-apply looks sort of reasonable:

	diff --git a/a b/a
	index 01e79c3..88483cf 100644
	--- a/a
	+++ b/a
	@@ -1,3 +1,3 @@
	-1
	+11
	 2
	 3

but it doesn't apply, since the third line is now different in the
work tree. The patch I'd really expect to see would have "33" on the
third line. I've been staring at all the temporary index files
(git-stash.sh:105 and on) and the stash mode in
git-add--interactive.perl and trying to figure out where it goes
wrong, but I don't think I'm going to get it right now. Maybe one of
y'all will immediately see it?


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