org-attach: Use relative path for git annex

* lisp/org-attach.el (org-attach-annex-get-maybe): Use relative path as
  argument for git annex.  Fixes error in test with version 3 of git
  annex.
This commit is contained in:
Erik Hetzner 2016-02-26 12:44:46 -08:00 committed by Nicolas Goaziou
parent d79835a821
commit f97317abcb
1 changed files with 17 additions and 16 deletions

View File

@ -299,22 +299,23 @@ the ATTACH_DIR property) their own attachment directory."
(defun org-attach-annex-get-maybe (path) (defun org-attach-annex-get-maybe (path)
"Call git annex get PATH (via shell) if using git annex. "Call git annex get PATH (via shell) if using git annex.
Signals an error if the file content is not available and it was not retrieved." Signals an error if the file content is not available and it was not retrieved."
(let ((path-relative (file-relative-name path)))
(when (and (org-attach-use-annex) (when (and (org-attach-use-annex)
(not (not
(string-equal (string-equal
"found" "found"
(shell-command-to-string (shell-command-to-string
(format "git annex find --format=found --in=here %s" (format "git annex find --format=found --in=here %s"
(shell-quote-argument path)))))) (shell-quote-argument path-relative))))))
(let ((should-get (let ((should-get
(if (eq org-attach-annex-auto-get 'ask) (if (eq org-attach-annex-auto-get 'ask)
(y-or-n-p (format "Run git annex get %s? " path)) (y-or-n-p (format "Run git annex get %s? " path-relative))
org-attach-annex-auto-get))) org-attach-annex-auto-get)))
(if should-get (if should-get
(progn (message "Running git annex get \"%s\"." path) (progn (message "Running git annex get \"%s\"." path-relative)
(call-process "git" nil nil nil "annex" "get" path)) (call-process "git" nil nil nil "annex" "get" path-relative))
(error "File %s stored in git annex but it is not available, and was not retrieved" (error "File %s stored in git annex but it is not available, and was not retrieved"
path))))) path))))))
(defun org-attach-commit () (defun org-attach-commit ()
"Commit changes to git if `org-attach-directory' is properly initialized. "Commit changes to git if `org-attach-directory' is properly initialized.