Skip to content

Commit 29b2041

Browse files
committed
Merge branch 'jk/add-e-kill-editor'
"git add -e" did not allow the user to abort the operation by killing the editor. * jk/add-e-kill-editor: add: check return value of launch_editor
2 parents 935d937 + cb64800 commit 29b2041

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

builtin/add.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
209209
if (run_diff_files(&rev, 0))
210210
die(_("Could not write patch"));
211211

212-
launch_editor(file, NULL, NULL);
212+
if (launch_editor(file, NULL, NULL))
213+
die(_("editing patch failed"));
213214

214215
if (stat(file, &st))
215216
die_errno(_("Could not stat '%s'"), file);

t/t3702-add-edit.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,11 @@ test_expect_success 'add -e' '
118118
119119
'
120120

121+
test_expect_success 'add -e notices editor failure' '
122+
git reset --hard &&
123+
echo change >>file &&
124+
test_must_fail env GIT_EDITOR=false git add -e &&
125+
test_expect_code 1 git diff --exit-code
126+
'
127+
121128
test_done

0 commit comments

Comments
 (0)