Commit Diff


commit - a7c9878d5b0e7770339e76efc0821897fe7a6be8
commit + 88f33a19290ffcb0a75f9b6cdd25c1207e46b858
blob - 73c9e659a5d078b48f853bb0fb2ebf16cedef6f0
blob + 56705cf058d3318856aad68700fbc380ab11e23d
--- lib/worktree.c
+++ lib/worktree.c
@@ -5475,8 +5475,12 @@ stage_path(void *arg, unsigned char status,
 			    ie->path, NULL, 1, 1);
 			if (err)
 				break;
-			if (choice != GOT_PATCH_CHOICE_YES)
+			if (choice == GOT_PATCH_CHOICE_NO)
+				break;
+			if (choice != GOT_PATCH_CHOICE_YES) {
+				err = got_error(GOT_ERR_PATCH_CHOICE);
 				break;
+			}
 		}
 		stage = GOT_FILEIDX_STAGE_DELETE;
 		got_fileindex_entry_stage_set(ie, stage);
blob - 3d1f624eae4a18cd9f42dbc35954c703cf11bc54
blob + 595696a78469f07142ccd9d777a2be68101c4e1b
--- regress/cmdline/stage.sh
+++ regress/cmdline/stage.sh
@@ -1537,8 +1537,9 @@ function test_stage_patch_quit {
 	local testroot=`test_init stage_patch_quit`
 
 	jot 16 > $testroot/repo/numbers
-	(cd $testroot/repo && git add numbers)
-	git_commit $testroot/repo -m "added numbers file"
+	echo zzz > $testroot/repo/zzz
+	(cd $testroot/repo && git add numbers zzz)
+	git_commit $testroot/repo -m "added files"
 	local commit_id=`git_show_head $testroot/repo`
 
 	got checkout $testroot/repo $testroot/wt > /dev/null
@@ -1551,9 +1552,11 @@ function test_stage_patch_quit {
 	sed -i -e 's/^2$/a/' $testroot/wt/numbers
 	sed -i -e 's/^7$/b/' $testroot/wt/numbers
 	sed -i -e 's/^16$/c/' $testroot/wt/numbers
+	(cd $testroot/wt && got rm zzz > /dev/null)
 
-	# stage first hunk and quit; and don't pass a path argument
-	printf "y\nq\n" > $testroot/patchscript
+	# stage first hunk and quit; and don't pass a path argument to
+	# ensure that we don't skip asking about the 'zzz' file after 'quit'
+	printf "y\nq\nn\n" > $testroot/patchscript
 	(cd $testroot/wt && got stage -F $testroot/patchscript -p \
 		> $testroot/stdout)
 	ret="$?"
@@ -1587,6 +1590,8 @@ stage this change? [y/n/q] y
 -----------------------------------------------
 M  numbers (change 2 of 3)
 stage this change? [y/n/q] q
+D  zzz
+stage deletion? [y/n] n
 EOF
 	cmp -s $testroot/stdout.expected $testroot/stdout
 	ret="$?"
@@ -1598,6 +1603,7 @@ EOF
 
 	(cd $testroot/wt && got status > $testroot/stdout)
 	echo "MM numbers" > $testroot/stdout.expected
+	echo "D  zzz" >> $testroot/stdout.expected
 	cmp -s $testroot/stdout.expected $testroot/stdout
 	ret="$?"
 	if [ "$ret" != "0" ]; then