فهرست منبع

Use lisp cd function to change directories to avoid shell dependencies

This fixes git version determination on windows for cygwin and for msysGit
where git is installed in the user's PATH for the windows command shell.
Bernt Hansen 16 سال پیش
والد
کامیت
ffaa4ff134
1فایلهای تغییر یافته به همراه20 افزوده شده و 18 حذف شده
  1. 20 18
      lisp/org.el

+ 20 - 18
lisp/org.el

@@ -104,25 +104,27 @@ With prefix arg HERE, insert it at point."
   (interactive "P")
   (let* ((org-version org-version)
 	 (git-version)
-	 (dir (concat (file-name-directory (locate-library "org")) "../" )))
+	 (dir (concat (file-name-directory (locate-library "org")) "../" ))
+	 (version))
     (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 git-version (match-string 0))
-	   (shell-command (concat "cd " dir " && git diff-index --name-only HEAD --"))
-	   (unless (eql 1 (point-max))
-	     (setq git-version (concat git-version ".dirty")))
-	   (setq org-version (concat org-version " (" git-version ")")))))
-    (let ((version (format "Org-mode version %s" org-version)))
-      (if here (insert version))
-      (message version)
-      version)))
+	(let ((pwd (substring (pwd) 10)))
+	  (cd dir)
+	  (shell-command "git describe --abbrev=4 HEAD")
+	  (save-excursion
+	    (set-buffer "*Shell Command Output*")
+	    (goto-char (point-min))
+	    (re-search-forward "[^\n]+")
+	    (setq git-version (match-string 0))
+	    (subst-char-in-string ?- ?. git-version t)
+	    (shell-command "git diff-index --name-only HEAD --")
+	    (unless (eql 1 (point-max))
+	      (setq git-version (concat git-version ".dirty")))
+	    (setq org-version (concat org-version " (" git-version ")")))
+	  (cd pwd)))
+    (setq version (format "Org-mode version %s" org-version))
+    (if here (insert version))
+    (message version)
+    version))
 
 ;;; Compatibility constants