git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/2] git-gui: use commit message template

From
Pratyush Yadav <me@yadavpratyush.com>
Date
Nov 27, 2020, 14:59 UTC
Message-ID
<20201127145927.26222-3-me@yadavpratyush.com>
In-Reply-To
<20201127145927.26222-1-me@yadavpratyush.com>
From: Martin Schön <Martin.Schoen@loewensteinmedical.de>

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>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
---
 git-gui.sh     | 7 +++++++
 lib/commit.tcl | 1 +
 2 files changed, 8 insertions(+)
diff --git a/git-gui.sh b/git-gui.sh
index 8ee67e6..cc6c2aa 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 ""
 	}
diff --git a/lib/commit.tcl b/lib/commit.tcl
index b516aa2..11379f8 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} {
-- 
2.29.2
Previous: Pratyush YadavNext: Pratyush Yadav
Message 3 of 4 in “git-gui: Use commit message template”
  1. 0/2 git-gui: Use commit message templatePratyush Yadav, Nov 27, 2020
  2. 1/2 git-gui: Only touch GITGUI_MSG when neededPratyush Yadav, Nov 27, 2020
  3. 2/2 git-gui: use commit message templatePratyush Yadav, Nov 27, 2020
  4. Pratyush YadavDec 1, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.