Adds the output of 'git describe' to the org-version string if we are running
from a git repository.  This identifies exactly what commit is checked out in
the org-mode git repository when reporting the org-mode version number.

org-version returns something like:

    Org-mode version 6.29trans (release_6.29c.42.g5996)

which shows 6.29trans (somewhere after the last release tag) which
is 42 commits after release_6.29c at git commit 5996.

The git describe information is not included if org mode is not
running from a git repository.
---
 lisp/org.el |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index b9f4229..3560a50 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -102,10 +102,22 @@
   "Show the org-mode version in the echo area.
 With prefix arg HERE, insert it at point."
   (interactive "P")
-  (let ((version (format "Org-mode version %s" org-version)))
-    (message version)
-    (if here
-       (insert version))))
+  (let* ((org-version org-version)
+        (dir (concat (file-name-directory (locate-library "org")) "../" )))
+    (if (file-exists-p (expand-file-name ".git" dir))
+       (progn
+        (shell-command (concat "cd " dir " && git describe --abbrev=4 HEAD"))
+        (save-excursion
+          (set-buffer "*Shell Command Output*")
+          (goto-char (point-min))
+          (replace-regexp "-" ".")
+          (goto-char (point-min))
+          (re-search-forward "[^\n]+")
+          (setq org-version (concat org-version " (" (match-string 0) ")")))))
+    (let ((version (format "Org-mode version %s" org-version)))
+      (message version)
+      (if here
+         (insert version)))))
 
 ;;; Compatibility constants
 
-- 
1.6.4



_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to