Use vc-git to find the git repository for org-attach

* lisp/org-attach.el (org-attach-commit): Use vc-git to find the git
repository.

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.

Patch by Remi Vanicat
This commit is contained in:
Carsten Dominik 2013-08-31 15:58:12 +02:00
parent 718306e2a1
commit 2c38c3acc0
1 changed files with 5 additions and 4 deletions

View File

@ -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
(with-temp-buffer
(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
(split-string
(shell-command-to-string