Open annulen opened 4 years ago
Most user-friendly solution would be to keep old commit message in temporary file or just stored in memory in variable, and put it back into editor if user switches back from amend mode.
Less user-friendly but still OK is to show a confirmation dialog if "Amend Last Commit" is clicked and there is a text to be destroyed
This is the most serious issue of the entire Git GUI! And I'm sure that it also happens under different circumstances (maybe after a Rescan when some other operations have been done in parallel, but I can't deliberately reproduce it). We need some form of commit message history, even for the scenarios when you screw up the Undo & Redo at a wrong moment. And obviously, even if you ignore power outages & Windows stability, one of the reasons why this is a must have is the frequency of Git GUI (wish.exe) freezing up.
Some additional information which might be useful to someone trying to implement this (based on some brief code spelunking):
.git/GITGUI_BCK
.backup_commit_buffer
: https://github.com/prati0100/git-gui/blob/df4f9e28f64ea97032ec70d9c8894dc87a1b7f9e/git-gui.sh#L4122-L4151ui_comm
also referred to as $ui_comm
..git/GITGUI_MSG
if it is non-empty when the program exits.Hope these are some useful pointers for someone. :)
Presumably we want to add confirmation/auto-save of message text before deleting/clearing message text.
I think it would make more sense to use two separate backup files for "amended" and "new" messages, and clear respective backup when commit is done. Works intuitively and no need to confirm anything.
GITGUI_BCK was introduced in 4578c5cb690df98d0d5fbea043114b4b7dec8f57, commit message contains details how GITGUI_BCK and GITGUI_MSG files are used
I think it would make more sense to use two separate backup files for "amended" and "new" messages, and clear respective backup when commit is done. Works intuitively and no need to confirm anything.
Actually, it's not that simple, as "amended" message becomes irrelevant after HEAD moves. I see two possible ways to handle this situation:
git citool --amend
doesn't restore message from GITGUI_MSG, so I guess doing #1 would not be a step back in functionality.
You can say that this is not a serious issue and one just should avoid misclicks, however, with traditional git commit + editor workflow it's much harder to lose typed text irreversibly.