Merge branch 'jk/add-e-kill-editor'
authorJunio C Hamano <gitster@pobox.com>
Fri, 22 May 2015 19:41:55 +0000 (12:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 22 May 2015 19:41:55 +0000 (12:41 -0700)
"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

builtin/add.c
t/t3702-add-edit.sh
index ee370b059adfd106c70e2c4aa4df50663cb4a8ec..df5135bf62acabfa9f68793435c1576ba7c1a36a 100644 (file)
@@ -209,7 +209,8 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
        if (run_diff_files(&rev, 0))
                die(_("Could not write patch"));
 
-       launch_editor(file, NULL, NULL);
+       if (launch_editor(file, NULL, NULL))
+               die(_("editing patch failed"));
 
        if (stat(file, &st))
                die_errno(_("Could not stat '%s'"), file);
index 4ee47cc9a862cdbe8c63bc9d4ebbe46ff3c344bc..3cb74ca296d141a6bd248e527680f5f217608ca7 100755 (executable)
@@ -118,4 +118,11 @@ test_expect_success 'add -e' '
 
 '
 
+test_expect_success 'add -e notices editor failure' '
+       git reset --hard &&
+       echo change >>file &&
+       test_must_fail env GIT_EDITOR=false git add -e &&
+       test_expect_code 1 git diff --exit-code
+'
+
 test_done