[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] Org attach: use vc to find the git dir if it exists

From: Rémi Vanicat
Subject: [O] [PATCH] Org attach: use vc to find the git dir if it exists
Date: Mon, 12 Aug 2013 15:28:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Org attach use to fail to commit the attached file in git or git annex
when the .git repository is not in the data sub-directory. 

This new code will use vc-git to find the .git file, and from this do
what is needed for committing file into git or git annex.

 lisp/org-attach.el | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index faefa6b..9bf3cda 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -261,14 +261,15 @@ the ATTACH_DIR property) their own attachment directory."
 (defun org-attach-commit ()
   "Commit changes to git if `org-attach-directory' is properly initialized.
 This checks for the existence of a \".git\" directory in that directory."
-  (let ((dir (expand-file-name org-attach-directory))
-       (changes 0))
-    (when (file-exists-p (expand-file-name ".git" dir))
+  (let* ((dir (expand-file-name org-attach-directory))
+        (git-dir (vc-git-root dir))
+        (changes 0))
+    (when git-dir
        (cd dir)
        (let ((have-annex
               (and org-attach-git-annex-cutoff
-                   (file-exists-p (expand-file-name ".git/annex" dir)))))
+                   (file-exists-p (expand-file-name "annex" git-dir)))))
          (dolist (new-or-modified

reply via email to

[Prev in Thread] Current Thread [Next in Thread]