{"thread":{"id":"7184","subject":"[PATCH 1/2] git.el: Avoid appending a signoff line that is already present.","startedAt":"2007-03-10T18:21:25Z","lastAt":"2007-03-10T18:21:25Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"36752","messageId":"87ps7h5596.fsf@wine.dyndns.org","threadId":"7184","inReplyTo":null,"subject":"[PATCH 1/2] git.el: Avoid appending a signoff line that is already present.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2007-03-10T18:21:25Z","receivedAt":"2007-03-10T18:21:25Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Also avoid inserting an extra newline if other signoff lines are\npresent.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n contrib/emacs/git.el |   24 ++++++++++++++++++------\n 1 files changed, 18 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 13d1982..427f89b 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -891,6 +891,18 @@ and returns the process output as a string.\"\n   (with-current-buffer log-edit-parent-buffer\n     (git-get-filenames (git-marked-files-state 'added 'deleted 'modified))))\n \n+(defun git-append-sign-off (name email)\n+  \"Append a Signed-off-by entry to the current buffer, avoiding duplicates.\"\n+  (let ((sign-off (format \"Signed-off-by: %s <%s>\" name email))\n+        (case-fold-search t))\n+    (goto-char (point-min))\n+    (unless (re-search-forward (concat \"^\" (regexp-quote sign-off)) nil t)\n+      (goto-char (point-min))\n+      (unless (re-search-forward \"^Signed-off-by: \" nil t)\n+        (setq sign-off (concat \"\\n\" sign-off)))\n+      (goto-char (point-max))\n+      (insert sign-off \"\\n\"))))\n+\n (defun git-commit-file ()\n   \"Commit the marked file(s), asking for a commit message.\"\n   (interactive)\n@@ -899,6 +911,8 @@ and returns the process output as a string.\"\n         (merge-heads (git-get-merge-heads))\n         (dir default-directory)\n         (coding-system (git-get-commits-coding-system))\n+        (committer-name (git-get-committer-name))\n+        (committer-email (git-get-committer-email))\n         (sign-off git-append-signed-off-by))\n     (with-current-buffer buffer\n       (when (eq 0 (buffer-size))\n@@ -907,7 +921,7 @@ and returns the process output as a string.\"\n         (insert\n          (propertize\n           (format \"Author: %s <%s>\\n%s\"\n-                  (git-get-committer-name) (git-get-committer-email)\n+                  committer-name committer-email\n                   (if merge-heads\n                       (format \"Parent: %s\\n%s\\n\"\n                               (git-rev-parse \"HEAD\")\n@@ -916,11 +930,9 @@ and returns the process output as a string.\"\n           'face 'git-header-face)\n          (propertize git-log-msg-separator 'face 'git-separator-face)\n          \"\\n\")\n-        (cond ((file-readable-p \".git/MERGE_MSG\")\n-               (insert-file-contents \".git/MERGE_MSG\"))\n-              (sign-off\n-               (insert (format \"\\n\\nSigned-off-by: %s <%s>\\n\"\n-                               (git-get-committer-name) (git-get-committer-email)))))))\n+        (when (file-readable-p \".git/MERGE_MSG\")\n+          (insert-file-contents \".git/MERGE_MSG\"))\n+        (when sign-off (git-append-sign-off committer-name committer-email))))\n     (log-edit #'git-do-commit nil #'git-log-edit-files buffer)\n     (setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords))\n     (setq buffer-file-coding-system coding-system)\n-- \n1.5.0.3.321.g4253\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}