Function: org-attach-git-annex-get-maybe

org-attach-git-annex-get-maybe is a byte-compiled function defined in org-attach-git.el.gz.

Signature

(org-attach-git-annex-get-maybe PATH)

Documentation

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.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-attach-git.el.gz
(defun org-attach-git-annex-get-maybe (path)
  "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."
  (let* ((default-directory
           (cond ((eq org-attach-git-dir 'default)
                  (expand-file-name org-attach-id-dir))
                 ((eq org-attach-git-dir 'individual-repository)
                  (org-attach-dir))))
	 (path-relative (file-relative-name path)))
    (when (and (org-attach-git-use-annex)
	       (not
		(string-equal
		 "found"
		 (shell-command-to-string
		  (format "git annex find --format=found --in=here %s"
			  (shell-quote-argument path-relative))))))
      (let ((should-get
	     (if (eq org-attach-git-annex-auto-get 'ask)
		 (y-or-n-p (format "Run git annex get %s? " path-relative))
	       org-attach-git-annex-auto-get)))
	(unless should-get
	  (error "File %s stored in git annex but unavailable" path))
	(message "Running git annex get \"%s\"." path-relative)
	(call-process "git" nil nil nil "annex" "get" path-relative)))))