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

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."
(when (and (org-attach-use-annex) (let ((path-relative (file-relative-name path)))
(not (when (and (org-attach-use-annex)
(string-equal (not
"found" (string-equal
(shell-command-to-string "found"
(format "git annex find --format=found --in=here %s" (shell-command-to-string
(shell-quote-argument path)))))) (format "git annex find --format=found --in=here %s"
(let ((should-get (shell-quote-argument path-relative))))))
(if (eq org-attach-annex-auto-get 'ask) (let ((should-get
(y-or-n-p (format "Run git annex get %s? " path)) (if (eq org-attach-annex-auto-get 'ask)
org-attach-annex-auto-get))) (y-or-n-p (format "Run git annex get %s? " path-relative))
(if should-get org-attach-annex-auto-get)))
(progn (message "Running git annex get \"%s\"." path) (if should-get
(call-process "git" nil nil nil "annex" "get" path)) (progn (message "Running git annex get \"%s\"." path-relative)
(error "File %s stored in git annex but it is not available, and was not retrieved" (call-process "git" nil nil nil "annex" "get" path-relative))
path))))) (error "File %s stored in git annex but it is not available, and was not retrieved"
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.