From: Alexandre Julliard <julliard@winehq.org>
To: git@vger.kernel.org
Subject: [PATCH 1/2] git.el: Avoid appending a signoff line that is already present.
Date: Sat, 10 Mar 2007 19:21:25 +0100 [thread overview]
Message-ID: <87ps7h5596.fsf@wine.dyndns.org> (raw)
Also avoid inserting an extra newline if other signoff lines are
present.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
---
contrib/emacs/git.el | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 13d1982..427f89b 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -891,6 +891,18 @@ and returns the process output as a string."
(with-current-buffer log-edit-parent-buffer
(git-get-filenames (git-marked-files-state 'added 'deleted 'modified))))
+(defun git-append-sign-off (name email)
+ "Append a Signed-off-by entry to the current buffer, avoiding duplicates."
+ (let ((sign-off (format "Signed-off-by: %s <%s>" name email))
+ (case-fold-search t))
+ (goto-char (point-min))
+ (unless (re-search-forward (concat "^" (regexp-quote sign-off)) nil t)
+ (goto-char (point-min))
+ (unless (re-search-forward "^Signed-off-by: " nil t)
+ (setq sign-off (concat "\n" sign-off)))
+ (goto-char (point-max))
+ (insert sign-off "\n"))))
+
(defun git-commit-file ()
"Commit the marked file(s), asking for a commit message."
(interactive)
@@ -899,6 +911,8 @@ and returns the process output as a string."
(merge-heads (git-get-merge-heads))
(dir default-directory)
(coding-system (git-get-commits-coding-system))
+ (committer-name (git-get-committer-name))
+ (committer-email (git-get-committer-email))
(sign-off git-append-signed-off-by))
(with-current-buffer buffer
(when (eq 0 (buffer-size))
@@ -907,7 +921,7 @@ and returns the process output as a string."
(insert
(propertize
(format "Author: %s <%s>\n%s"
- (git-get-committer-name) (git-get-committer-email)
+ committer-name committer-email
(if merge-heads
(format "Parent: %s\n%s\n"
(git-rev-parse "HEAD")
@@ -916,11 +930,9 @@ and returns the process output as a string."
'face 'git-header-face)
(propertize git-log-msg-separator 'face 'git-separator-face)
"\n")
- (cond ((file-readable-p ".git/MERGE_MSG")
- (insert-file-contents ".git/MERGE_MSG"))
- (sign-off
- (insert (format "\n\nSigned-off-by: %s <%s>\n"
- (git-get-committer-name) (git-get-committer-email)))))))
+ (when (file-readable-p ".git/MERGE_MSG")
+ (insert-file-contents ".git/MERGE_MSG"))
+ (when sign-off (git-append-sign-off committer-name committer-email))))
(log-edit #'git-do-commit nil #'git-log-edit-files buffer)
(setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords))
(setq buffer-file-coding-system coding-system)
--
1.5.0.3.321.g4253
--
Alexandre Julliard
julliard@winehq.org
reply other threads:[~2007-03-10 18:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ps7h5596.fsf@wine.dyndns.org \
--to=julliard@winehq.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).