git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-gui: use commit message template
@ 2018-07-02 13:28 Martin Schön
  2018-07-02 19:49 ` Stefan Beller
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Schön @ 2018-07-02 13:28 UTC (permalink / raw)
  To: git

Use the file described by commit.template (if set) to show the commit message
template, just like other GUIs.

Signed-off-by: Martin Sch??n <Martin.Schoen@loewensteinmedical.de>
---
 git-gui.sh     | 9 +++++++++
 lib/commit.tcl | 1 +
 2 files changed, 10 insertions(+)

diff --git a/git-gui.sh b/git-gui.sh
index 5bc21b8..6fc598d 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1611,6 +1611,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 ""
 	}
@@ -1620,6 +1626,9 @@ proc run_prepare_commit_msg_hook {} {
 	set fd_ph [githook_read prepare-commit-msg \
 			[gitdir PREPARE_COMMIT_MSG] $pcm_source]
 	if {$fd_ph eq {}} {
+		if {$pcm_source eq "template"} {
+			load_message PREPARE_COMMIT_MSG
+		}
 		catch {file delete [gitdir PREPARE_COMMIT_MSG]}
 		return 0;
 	}
diff --git a/lib/commit.tcl b/lib/commit.tcl
index 83620b7..168f696 100644
--- a/lib/commit.tcl
+++ b/lib/commit.tcl
@@ -506,6 +506,7 @@ A rescan will be automatically started now.
 	unlock_index
 	reshow_diff
 	ui_status [mc "Created commit %s: %s" [string range $cmt_id 0 7] $subject]
+	rescan ui_ready
 }
 
 proc commit_postcommit_wait {fd_ph cmt_id} {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-03  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-02 13:28 [PATCH] git-gui: use commit message template Martin Schön
2018-07-02 19:49 ` Stefan Beller
2018-07-03  8:53   ` AW: " Schoen, Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).