{"thread":{"id":"7409","subject":"[PATCH] git.el: Display some information about the HEAD commit.","startedAt":"2007-03-26T10:16:16Z","lastAt":"2007-03-26T10:16:16Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"38026","messageId":"874po848en.fsf@wine.dyndns.org","threadId":"7409","inReplyTo":null,"subject":"[PATCH] git.el: Display some information about the HEAD commit.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2007-03-26T10:16:16Z","receivedAt":"2007-03-26T10:16:16Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Use git-log --pretty=oneline to print a short description of the\ncurrent HEAD (and merge heads if any) in the buffer header.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n contrib/emacs/git.el |   22 ++++++++++++++++++++--\n 1 files changed, 20 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 5f22dec..2f9995e 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -263,6 +263,16 @@ and returns the process output as a string.\"\n              (locale-charset-to-coding-system repo-config))\n       'utf-8)))\n \n+(defun git-get-logoutput-coding-system ()\n+  \"Return the coding system used for git-log output.\"\n+  (let ((repo-config (or (git-config \"i18n.logoutputencoding\")\n+                         (git-config \"i18n.commitencoding\"))))\n+    (or git-commits-coding-system\n+        (and repo-config\n+             (fboundp 'locale-charset-to-coding-system)\n+             (locale-charset-to-coding-system repo-config))\n+      'utf-8)))\n+\n (defun git-escape-file-name (name)\n   \"Escape a file name if necessary.\"\n   (if (string-match \"[\\n\\t\\\"\\\\]\" name)\n@@ -406,6 +416,14 @@ and returns the process output as a string.\"\n           (push (match-string 0) heads))))\n     (nreverse heads)))\n \n+(defun git-get-commit-description (commit)\n+  \"Get a one-line description of COMMIT.\"\n+  (let ((coding-system-for-read (git-get-logoutput-coding-system)))\n+    (let ((descr (git-call-process-env-string nil \"log\" \"--max-count=1\" \"--pretty=oneline\" commit)))\n+      (if (and descr (string-match \"\\\\`\\\\([0-9a-f]\\\\{40\\\\}\\\\) *\\\\(.*\\\\)$\" descr))\n+          (concat (substring (match-string 1 descr) 0 10) \" - \" (match-string 2 descr))\n+        descr))))\n+\n ;;;; File info structure\n ;;;; ------------------------------------------------------------\n \n@@ -573,7 +591,7 @@ and returns the process output as a string.\"\n   \"Refresh the ewoc header and footer.\"\n   (let ((branch (git-symbolic-ref \"HEAD\"))\n         (head (if (git-empty-db-p) \"Nothing committed yet\"\n-                (substring (git-rev-parse \"HEAD\") 0 10)))\n+                (git-get-commit-description \"HEAD\")))\n         (merge-heads (git-get-merge-heads)))\n     (ewoc-set-hf status\n                  (format \"Directory:  %s\\nBranch:     %s\\nHead:       %s%s\\n\"\n@@ -584,7 +602,7 @@ and returns the process output as a string.\"\n                          head\n                          (if merge-heads\n                              (concat \"\\nMerging:    \"\n-                                     (mapconcat (lambda (str) (substring str 0 10)) merge-heads \" \"))\n+                                     (mapconcat (lambda (str) (git-get-commit-description str)) merge-heads \"\\n            \"))\n                            \"\"))\n                  (if (ewoc-nth status 0) \"\" \"    No changes.\"))))\n \n-- \n1.5.1.rc2.2.g6da42\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}