Skip to content

Commit 1141f83

Browse files
committed
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
2 parents 38c2ac2 + 627c87f commit 1141f83

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

git-gui.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,7 @@ proc rescan {after {honor_trustmtime 1}} {
14821482
} elseif {[run_prepare_commit_msg_hook]} {
14831483
} elseif {[load_message MERGE_MSG]} {
14841484
} elseif {[load_message SQUASH_MSG]} {
1485+
} elseif {[load_message [get_config commit.template]]} {
14851486
}
14861487
$ui_comm edit reset
14871488
$ui_comm edit modified false
@@ -1616,6 +1617,12 @@ proc run_prepare_commit_msg_hook {} {
16161617
fconfigure $fd_sm -encoding utf-8
16171618
puts -nonewline $fd_pcm [read $fd_sm]
16181619
close $fd_sm
1620+
} elseif {[file isfile [get_config commit.template]]} {
1621+
set pcm_source "template"
1622+
set fd_sm [open [get_config commit.template] r]
1623+
fconfigure $fd_sm -encoding utf-8
1624+
puts -nonewline $fd_pcm [read $fd_sm]
1625+
close $fd_sm
16191626
} else {
16201627
set pcm_source ""
16211628
}
@@ -2305,11 +2312,10 @@ proc do_quit {{rc {1}}} {
23052312
if {$GITGUI_BCK_exists && ![$ui_comm edit modified]} {
23062313
file rename -force [gitdir GITGUI_BCK] $save
23072314
set GITGUI_BCK_exists 0
2308-
} else {
2315+
} elseif {[$ui_comm edit modified]} {
23092316
set msg [string trim [$ui_comm get 0.0 end]]
23102317
regsub -all -line {[ \r\t]+$} $msg {} msg
2311-
if {(![string match amend* $commit_type]
2312-
|| [$ui_comm edit modified])
2318+
if {![string match amend* $commit_type]
23132319
&& $msg ne {}} {
23142320
catch {
23152321
set fd [open $save w]

lib/commit.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ A rescan will be automatically started now.
456456
}
457457

458458
$ui_comm delete 0.0 end
459+
load_message [get_config commit.template]
459460
$ui_comm edit reset
460461
$ui_comm edit modified false
461462
if {$::GITGUI_BCK_exists} {

0 commit comments

Comments
 (0)