The sound distributed version control system

#121 Don't do anything if editor is quit without saving

Opened by loewenheim on November 26, 2020
loewenheim on November 26, 2020

From git I’m used to being able to abort committing by quitting my text editor without saving. In pijul, this doesn’t seem to work; quitting seems to be taken as “everything’s in order”. What do you think about changing this to work like in git?

pmeunier on November 26, 2020

I believe this is already the case: if the change message is empty, or if the file is empty, nothing is done.

arijid79 on November 26, 2020

if the change message is empty, or if the file is empty, nothing is done.

Yeah. This is exactly what I do when I need to abort. Although this issue seems greater for the OP when amending. Since in that case, the message is already written

loewenheim on November 26, 2020

I was also thinking about pulling, where there isn’t a message in the first place.

cole-h on November 26, 2020

I think what makes this difficult is the fact that the temp file is created with specific contents, which would be valid if quit without saving. (FWIW, the same happens with git commit --amend.)

dnaq on December 3, 2020

Even though the same thing happens with git commit —amend the commit hash doesn’t change in git when that happens.

cole-h on December 3, 2020

Are you sure? I can’t reproduce that behavior.

$ git rev-parse HEAD
1927e40d50528ce3f7a0ebb1138e9b99b7060085
$ git commit --amend
## quit editor without saving and without making any changes
$ git rev-parse HEAD
e0468b8606481afd8d3b1487cc1399c3db5820fc
dnaq on December 3, 2020

Sorry, you’re right. The commit hash changes in git.

jraregris on December 9, 2020

Another way to “back out” of a recording or commit is to quit the editor with a non-successful exit code. You can do that with :cq in vim. This aborts the action you were doing even if you saved before you quit the editor.