emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Org attach: use vc to find the git dir if it exists
@ 2013-08-12 13:28 Rémi Vanicat
  2013-08-31 13:58 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Rémi Vanicat @ 2013-08-12 13:28 UTC (permalink / raw)
  To: emacs-orgmode

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
       (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
-- 
1.8.4.rc2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Org attach: use vc to find the git dir if it exists
  2013-08-12 13:28 [PATCH] Org attach: use vc to find the git dir if it exists Rémi Vanicat
@ 2013-08-31 13:58 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2013-08-31 13:58 UTC (permalink / raw)
  To: Rémi Vanicat; +Cc: emacs-orgmode

Applied, thank you Remi.

- Carsten

On 12.8.2013, at 15:28, Rémi Vanicat <vanicat@debian.org> wrote:

> 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
>       (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
> -- 
> 1.8.4.rc2
> 
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-31 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-12 13:28 [PATCH] Org attach: use vc to find the git dir if it exists Rémi Vanicat
2013-08-31 13:58 ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).