'EDITOR=false git add -e' adds to index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]