diff options
| author | Pratyush Yadav <me@yadavpratyush.com> | 2020-12-02 00:40:06 +0530 |
|---|---|---|
| committer | Pratyush Yadav <me@yadavpratyush.com> | 2020-12-02 00:40:06 +0530 |
| commit | 1141f8325c4a3dd536a35415e11a907a8023e9df (patch) | |
| tree | 1f6150649c75eb2c238b2949558697b207f02eec | |
| parent | 38c2ac2e2ab00a8bcef528f24cb5b883b4413e5c (diff) | |
| parent | 627c87f84c157885d587125cf0c73591a0e3ee7a (diff) | |
| download | git-1141f8325c4a3dd536a35415e11a907a8023e9df.tar.xz | |
Merge branch 'ms/commit-template'
Teach git-gui to read the commit message template and pre-populate it in
the commit message buffer.
* ms/commit-template:
git-gui: use commit message template
git-gui: Only touch GITGUI_MSG when needed
| -rwxr-xr-x | git-gui.sh | 12 | ||||
| -rw-r--r-- | lib/commit.tcl | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/git-gui.sh b/git-gui.sh index 867b8cea46..cc6c2aa2c3 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1482,6 +1482,7 @@ proc rescan {after {honor_trustmtime 1}} { } elseif {[run_prepare_commit_msg_hook]} { } elseif {[load_message MERGE_MSG]} { } elseif {[load_message SQUASH_MSG]} { + } elseif {[load_message [get_config commit.template]]} { } $ui_comm edit reset $ui_comm edit modified false @@ -1616,6 +1617,12 @@ proc run_prepare_commit_msg_hook {} { fconfigure $fd_sm -encoding utf-8 puts -nonewline $fd_pcm [read $fd_sm] close $fd_sm + } elseif {[file isfile [get_config commit.template]]} { + set pcm_source "template" + set fd_sm [open [get_config commit.template] r] + fconfigure $fd_sm -encoding utf-8 + puts -nonewline $fd_pcm [read $fd_sm] + close $fd_sm } else { set pcm_source "" } @@ -2305,11 +2312,10 @@ proc do_quit {{rc {1}}} { if {$GITGUI_BCK_exists && ![$ui_comm edit modified]} { file rename -force [gitdir GITGUI_BCK] $save set GITGUI_BCK_exists 0 - } else { + } elseif {[$ui_comm edit modified]} { set msg [string trim [$ui_comm get 0.0 end]] regsub -all -line {[ \r\t]+$} $msg {} msg - if {(![string match amend* $commit_type] - || [$ui_comm edit modified]) + if {![string match amend* $commit_type] && $msg ne {}} { catch { set fd [open $save w] diff --git a/lib/commit.tcl b/lib/commit.tcl index b516aa2990..11379f8ad3 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -456,6 +456,7 @@ A rescan will be automatically started now. } $ui_comm delete 0.0 end + load_message [get_config commit.template] $ui_comm edit reset $ui_comm edit modified false if {$::GITGUI_BCK_exists} { |
