git-gui: warn when trying to commit on a detached head
The commandline is already warning when checking out a detached head. Since the only thing thats potentially dangerous is to create commits on a detached head lets warn in case the user is about to do that. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
This commit is contained in:
parent
1cac41f8ea
commit
e34789cc8b
@ -854,6 +854,7 @@ set default_config(gui.fontdiff) [font configure font_diff]
|
|||||||
# TODO: this option should be added to the git-config documentation
|
# TODO: this option should be added to the git-config documentation
|
||||||
set default_config(gui.maxfilesdisplayed) 5000
|
set default_config(gui.maxfilesdisplayed) 5000
|
||||||
set default_config(gui.usettk) 1
|
set default_config(gui.usettk) 1
|
||||||
|
set default_config(gui.warndetachedcommit) 1
|
||||||
set font_descs {
|
set font_descs {
|
||||||
{fontui font_ui {mc "Main Font"}}
|
{fontui font_ui {mc "Main Font"}}
|
||||||
{fontdiff font_diff {mc "Diff/Console Font"}}
|
{fontdiff font_diff {mc "Diff/Console Font"}}
|
||||||
|
@ -260,8 +260,23 @@ proc commit_prehook_wait {fd_ph curHEAD msg_p} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc commit_commitmsg {curHEAD msg_p} {
|
proc commit_commitmsg {curHEAD msg_p} {
|
||||||
|
global is_detached repo_config
|
||||||
global pch_error
|
global pch_error
|
||||||
|
|
||||||
|
if {$is_detached && $repo_config(gui.warndetachedcommit)} {
|
||||||
|
set msg [mc "You are about to commit on a detached head.\
|
||||||
|
This is a potentially dangerous thing to do because if you switch\
|
||||||
|
to another branch you will loose your changes and it can be difficult\
|
||||||
|
to retrieve them later from the reflog. You should probably cancel this\
|
||||||
|
commit and create a new branch to continue.\n\
|
||||||
|
\n\
|
||||||
|
Do you really want to proceed with your Commit?"]
|
||||||
|
if {[ask_popup $msg] ne yes} {
|
||||||
|
unlock_index
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# -- Run the commit-msg hook.
|
# -- Run the commit-msg hook.
|
||||||
#
|
#
|
||||||
set fd_ph [githook_read commit-msg $msg_p]
|
set fd_ph [githook_read commit-msg $msg_p]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user