emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bernt Hansen <bernt@norang.ca>
To: emacs-orgmode@gnu.org
Cc: Bernt Hansen <bernt@norang.ca>
Subject: [PATCH 1/2] Use lisp cd function to change directories to avoid shell dependencies
Date: Wed, 19 Aug 2009 16:06:17 -0400	[thread overview]
Message-ID: <1250712378-16345-2-git-send-email-bernt@norang.ca> (raw)
In-Reply-To: <87vdkju8lc.fsf@gollum.intra.norang.ca>

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.
---
 lisp/org.el |   38 ++++++++++++++++++++------------------
 1 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index e2cdce8..63ce2de 100644
--- a/lisp/org.el
+++ b/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
 
-- 
1.6.4

  parent reply	other threads:[~2009-08-19 20:06 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-18 17:22 [PATCH 0/2] Teach org-version to include git version information Bernt Hansen
2009-08-18 17:22 ` [PATCH 1/2] Add git version number to org-version information Bernt Hansen
2009-08-18 17:22 ` [PATCH 2/2] Add .dirty to git org-version info if files are modified Bernt Hansen
2009-08-18 19:08 ` [PATCH 0/2] Teach org-version to include git version information Carsten Dominik
2009-08-18 19:10   ` Bernt Hansen
2009-08-18 19:15     ` Carsten Dominik
2009-08-18 19:30       ` Stefan Vollmar
2009-08-18 19:44         ` Bernt Hansen
2009-08-18 19:48           ` Stefan Vollmar
2009-08-19 10:10       ` Manish
2009-08-19 11:24         ` Bernt Hansen
2009-08-19 12:01           ` Manish
2009-08-19 12:08             ` Bernt Hansen
2009-08-19 12:19               ` Manish
2009-08-19 12:30                 ` Bernt Hansen
2009-08-19 13:20                   ` Manish
2009-08-19 13:32                     ` Bernt Hansen
2009-08-19 13:34                       ` Bernt Hansen
2009-08-19 13:58                       ` Manish
2009-08-19 14:02                       ` Nick Dokos
2009-08-19 14:16                         ` Manish
2009-08-19 14:29                           ` Nick Dokos
2009-08-19 14:42                             ` Bernt Hansen
2009-08-19 14:51                               ` Manish
2009-08-19 15:04                                 ` Nick Dokos
2009-08-19 15:10                                   ` Manish
2009-08-19 15:16                                   ` Bernt Hansen
2009-08-19 15:23                                     ` Manish
2009-08-19 15:27                                       ` Bernt Hansen
2009-08-19 20:06                                         ` [PATCH 0/2] org-version fix for windows Bernt Hansen
2009-08-20  3:54                                           ` Bernt Hansen
2009-08-20 19:06                                             ` Bernt Hansen
2009-08-20 19:53                                               ` Carsten Dominik
2009-08-19 20:06                                         ` Bernt Hansen [this message]
2009-08-19 20:06                                         ` [PATCH 2/2] Skip git-version determination if git command fails Bernt Hansen
2009-08-19 14:17                         ` [PATCH 0/2] Teach org-version to include git version information Bernt Hansen
2009-08-19 14:41                           ` Manish
2009-08-19 14:44                             ` Bernt Hansen
2009-08-19 13:22               ` Manish
2009-08-19 13:40                 ` Bernt Hansen
2009-08-19 13:57                   ` Nick Dokos
2009-08-19 12:21         ` Nick Dokos
2009-08-19 12:30           ` Manish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1250712378-16345-2-git-send-email-bernt@norang.ca \
    --to=bernt@norang.ca \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).