git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 'EDITOR=false git add -e' adds to index
@ 2015-05-13  0:31 Russ Cox
  2015-05-13  1:21 ` [PATCH] add: check return value of launch_editor Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Russ Cox @ 2015-05-13  0:31 UTC (permalink / raw)
  To: git

In contrast to most other git commands, git add -e does not check
whether the editor it invokes exits successfully. This means that if
you cause your editor to exit unsuccessfully, hoping to abort the add
-e, the add -e continues anyway.

The specific instance I've observed is that you set EDITOR to a
program that starts the editor outside the current terminal and waits
for it to exit. Then you realize you didn't want to add anything and
type ^C in the terminal where git is waiting for $EDITOR to finish.
That makes $EDITOR exit unsuccessfully, and git prints an error about
not being able to invoke the editor, but it continues on with the add
-e, adding everything from the patch to the index.

I am using the acme editor, but I believe that EDITOR='emacs -nw' or
EDITOR='subl -w' for Sublime Text are more common settings that would
have the same problem. In a test, EDITOR=false suffices.

The root cause seems to be that builtin/add.c's edit_patch does not
check the result of  the launch_editor call. It probably should.

The call to launch_editor in builtin/config.c should probably also be
checked, although there it's not as big a deal, provided the editor
did not modify the file; reapplying the same file should be a no-op.
This is different from git add -e.

I am seeing this behavior with git 2.2.1, but I checked the main repo
and commit c518059 from yesterday still has the unchecked
launch_editor call.

Thanks.
Russ

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-13  8:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-13  0:31 'EDITOR=false git add -e' adds to index Russ Cox
2015-05-13  1:21 ` [PATCH] add: check return value of launch_editor Jeff King
2015-05-13  8:12   ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).