* [PATCH] . git.el: use commit.template if available
@ 2013-06-14 17:25 Curt Brune
2013-06-14 17:51 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Curt Brune @ 2013-06-14 17:25 UTC (permalink / raw)
To: git; +Cc: julliard
If the user's git config defines commit.template then include the
contents of that file in the log buffer by default.
In git-setup-log-buffer, instead of supplying the default commit
message insert the user's commit.template.
Signed-off-by: Curt Brune <curt@brune.net>
---
contrib/emacs/git.el | 47 ++++++++++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 19 deletions(-)
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 5ffc506..827578f 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -296,6 +296,11 @@ the process output as a string, or nil if the git command failed."
(and (fboundp 'user-mail-address) (user-mail-address))
(and (boundp 'user-mail-address) user-mail-address)))
+(defun git-get-commit-template ()
+ "Return the git commit template or nil"
+ ; copied from log-edit
+ (git-config "commit.template"))
+
(defun git-get-commits-coding-system ()
"Return the coding system to use for commits."
(let ((repo-config (git-config "i18n.commitencoding")))
@@ -1280,29 +1285,33 @@ The FILES list must be sorted."
(let ((dir default-directory)
(committer-name (git-get-committer-name))
(committer-email (git-get-committer-email))
+ (commit-template (git-get-commit-template))
(sign-off git-append-signed-off-by))
(with-current-buffer buffer
(cd dir)
(erase-buffer)
- (insert
- (propertize
- (format "Author: %s <%s>\n%s%s"
- (or author-name committer-name)
- (or author-email committer-email)
- (if date (format "Date: %s\n" date) "")
- (if merge-heads
- (format "Merge: %s\n"
- (mapconcat 'identity merge-heads " "))
- ""))
- 'face 'git-header-face)
- (propertize git-log-msg-separator 'face 'git-separator-face)
- "\n")
- (when subject (insert subject "\n\n"))
- (cond (msg (insert msg "\n"))
- ((file-readable-p ".git/rebase-apply/msg")
- (insert-file-contents ".git/rebase-apply/msg"))
- ((file-readable-p ".git/MERGE_MSG")
- (insert-file-contents ".git/MERGE_MSG")))
+ (if commit-template
+ (insert-file-contents commit-template)
+ (progn
+ (insert
+ (propertize
+ (format "Author: %s <%s>\n%s%s"
+ (or author-name committer-name)
+ (or author-email committer-email)
+ (if date (format "Date: %s\n" date) "")
+ (if merge-heads
+ (format "Merge: %s\n"
+ (mapconcat 'identity merge-heads " "))
+ ""))
+ 'face 'git-header-face)
+ (propertize git-log-msg-separator 'face 'git-separator-face)
+ "\n")
+ (when subject (insert subject "\n\n"))
+ (cond (msg (insert msg "\n"))
+ ((file-readable-p ".git/rebase-apply/msg")
+ (insert-file-contents ".git/rebase-apply/msg"))
+ ((file-readable-p ".git/MERGE_MSG")
+ (insert-file-contents ".git/MERGE_MSG")))))
; delete empty lines at end
(goto-char (point-min))
(when (re-search-forward "\n+\\'" nil t)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] . git.el: use commit.template if available
2013-06-14 17:25 [PATCH] . git.el: use commit.template if available Curt Brune
@ 2013-06-14 17:51 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2013-06-14 17:51 UTC (permalink / raw)
To: Curt Brune; +Cc: git, julliard
Curt Brune <curt@brune.net> writes:
> If the user's git config defines commit.template then include the
> contents of that file in the log buffer by default.
>
> In git-setup-log-buffer, instead of supplying the default commit
> message insert the user's commit.template.
>
> Signed-off-by: Curt Brune <curt@brune.net>
> ---
Interesting.
I wonder if git-do-commit still needs to reimplement the commit
logic using low-level plumbing in this era, which I think is the
cause of having to constantly catch up with what "git commit"
Porcelain does (like paying attention to configuration variables).
I often just do
M-x compile<ENTER>git commit args...<ENTER>
while setting my EDITOR to 'emacsclient', and I have a suspicion
that the callchain from git-commit-file to git-setup-log-buffer can
be quite simplified if such an approach is used. Enumerate the
marked file(s) to formulate the "git commit" command line and let
the underlying "git commit" do the heavy-lifting, that is.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-14 17:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-14 17:25 [PATCH] . git.el: use commit.template if available Curt Brune
2013-06-14 17:51 ` Junio C Hamano
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).