Merge branch 'js/commit-gpgsign' into pu
[gitweb.git] / lib / commit.tcl
index 5ce46877bfb24701187f5ff5e94ce4aaf8b666b2..01d2cc280ba7832840cb8ef64844daa88ebd9670 100644 (file)
@@ -260,8 +260,25 @@ proc commit_prehook_wait {fd_ph curHEAD msg_p} {
 }
 
 proc commit_commitmsg {curHEAD msg_p} {
+       global is_detached repo_config
        global pch_error
 
+       if {$is_detached
+           && ![file exists [gitdir rebase-merge head-name]]
+           &&  [is_config_true 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 lose 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.
        #
        set fd_ph [githook_read commit-msg $msg_p]
@@ -352,6 +369,9 @@ A rescan will be automatically started now.
        # -- Create the commit.
        #
        set cmd [list commit-tree $tree_id]
+       if {[is_config_true commit.gpgsign]} {
+               lappend cmd -S
+       }
        foreach p [concat $PARENT $MERGE_HEAD] {
                lappend cmd -p $p
        }
@@ -392,6 +412,7 @@ A rescan will be automatically started now.
        catch {file delete [gitdir MERGE_MSG]}
        catch {file delete [gitdir SQUASH_MSG]}
        catch {file delete [gitdir GITGUI_MSG]}
+       catch {file delete [gitdir CHERRY_PICK_HEAD]}
 
        # -- Let rerere do its thing.
        #