{"thread":{"id":"7738","subject":"[PATCH] git.el: Add a commit description to the reflog.","startedAt":"2007-04-19T11:16:58Z","lastAt":"2007-04-19T11:16:58Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"39879","messageId":"873b2wobpx.fsf@wine.dyndns.org","threadId":"7738","inReplyTo":null,"subject":"[PATCH] git.el: Add a commit description to the reflog.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2007-04-19T11:16:58Z","receivedAt":"2007-04-19T11:16:58Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Add a description of the commit to the reflog using the first line of\nthe log message, the same way the git-commit script does it.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n contrib/emacs/git.el |   42 ++++++++++++++++++++++++++++--------------\n 1 files changed, 28 insertions(+), 14 deletions(-)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 2f9995e..f600179 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -345,9 +345,15 @@ and returns the process output as a string.\"\n   (let ((str (git-call-process-env-string nil \"symbolic-ref\" ref)))\n     (and str (car (split-string str \"\\n\")))))\n \n-(defun git-update-ref (ref val &optional oldval)\n+(defun git-update-ref (ref newval &optional oldval reason)\n   \"Update a reference by calling git-update-ref.\"\n-  (apply #'git-call-process-env nil nil \"update-ref\" ref val (if oldval (list oldval))))\n+  (let ((args (and oldval (list oldval))))\n+    (push newval args)\n+    (push ref args)\n+    (when reason\n+     (push reason args)\n+     (push \"-m\" args))\n+    (eq 0 (apply #'git-call-process-env nil nil \"update-ref\" args))))\n \n (defun git-read-tree (tree &optional index-file)\n   \"Read a tree into the index file.\"\n@@ -364,8 +370,10 @@ and returns the process output as a string.\"\n   \"Call git-commit-tree with buffer as input and return the resulting commit SHA1.\"\n   (let ((author-name (git-get-committer-name))\n         (author-email (git-get-committer-email))\n+        (subject \"commit (initial): \")\n         author-date log-start log-end args coding-system-for-write)\n     (when head\n+      (setq subject \"commit: \")\n       (push \"-p\" args)\n       (push head args))\n     (with-current-buffer buffer\n@@ -384,22 +392,29 @@ and returns the process output as a string.\"\n             (goto-char (point-min))\n             (while (re-search-forward \"^Parent: +\\\\([0-9a-f]+\\\\)\" nil t)\n               (unless (string-equal head (match-string 1))\n+                (setq subject \"commit (merge): \")\n                 (push \"-p\" args)\n                 (push (match-string 1) args))))\n         (setq log-start (point-min)))\n       (setq log-end (point-max))\n+      (goto-char log-start)\n+      (when (re-search-forward \".*$\" nil t)\n+        (setq subject (concat subject (match-string 0))))\n       (setq coding-system-for-write buffer-file-coding-system))\n-    (git-get-string-sha1\n-     (with-output-to-string\n-       (with-current-buffer standard-output\n-         (let ((env `((\"GIT_AUTHOR_NAME\" . ,author-name)\n-                      (\"GIT_AUTHOR_EMAIL\" . ,author-email)\n-                      (\"GIT_COMMITTER_NAME\" . ,(git-get-committer-name))\n-                      (\"GIT_COMMITTER_EMAIL\" . ,(git-get-committer-email)))))\n-           (when author-date (push `(\"GIT_AUTHOR_DATE\" . ,author-date) env))\n-           (apply #'git-run-command-region\n-                  buffer log-start log-end env\n-                  \"commit-tree\" tree (nreverse args))))))))\n+    (let ((commit\n+           (git-get-string-sha1\n+            (with-output-to-string\n+              (with-current-buffer standard-output\n+                (let ((env `((\"GIT_AUTHOR_NAME\" . ,author-name)\n+                             (\"GIT_AUTHOR_EMAIL\" . ,author-email)\n+                             (\"GIT_COMMITTER_NAME\" . ,(git-get-committer-name))\n+                             (\"GIT_COMMITTER_EMAIL\" . ,(git-get-committer-email)))))\n+                  (when author-date (push `(\"GIT_AUTHOR_DATE\" . ,author-date) env))\n+                  (apply #'git-run-command-region\n+                         buffer log-start log-end env\n+                         \"commit-tree\" tree (nreverse args))))))))\n+      (and (git-update-ref \"HEAD\" commit head subject)\n+           commit))))\n \n (defun git-empty-db-p ()\n   \"Check if the git db is empty (no commit done yet).\"\n@@ -662,7 +677,6 @@ and returns the process output as a string.\"\n                       (if (or (not (string-equal tree head-tree))\n                               (yes-or-no-p \"The tree was not modified, do you really want to perform an empty commit? \"))\n                           (let ((commit (git-commit-tree buffer tree head)))\n-                            (git-update-ref \"HEAD\" commit head)\n                             (condition-case nil (delete-file \".git/MERGE_HEAD\") (error nil))\n                             (condition-case nil (delete-file \".git/MERGE_MSG\") (error nil))\n                             (with-current-buffer buffer (erase-buffer))\n-- \n1.5.1.1.182.g3cfa9\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}