emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-attach git-commit limitations
@ 2009-06-03 16:09 Christopher League
  0 siblings, 0 replies; only message in thread
From: Christopher League @ 2009-06-03 16:09 UTC (permalink / raw)
  To: org-mode mailing list

Hi folks,

I started trying to use the org-attach feature (C-c C-a) and I like  
the idea that it can auto-commit attachment changes to a git repo. But  
I noticed some shortcomings...

1. I like to keep the entire org-directory under version control, but  
org-attach only commits if the org-attach-directory is the root of the  
repo. Instead of using (file-exists-p (expand-file-name ".git" dir))  
in org-attach-commit, why not just TRY the "git add" shell command in  
that dir and check the return value to see whether to continue with  
the commit?

2. I got the above working, but then I noticed that if you use the  
ATTACH_DIR property to redirect attachments elsewhere, org-attach- 
commit ignores that and still tries to synchronize the standard org- 

Below I have a patch to address both of these, but I don't recommend  
applying it yet... if the ATTACH_DIR happens to be in a normal source  
tree, users may not want to auto-commit to it, particularly with such  
an unhelpful log message. So I'd like to add an ATTACH_DIR_COMMIT flag  
that, when set, indicates it's okay to auto-commit the ATTACH_DIR.

Other suggestions about how to customize whether or not to commit on a  
per-directory basis are welcome.. maybe a org-attach-commit-dirs  
variable that's a boolean, a list or a regex, combined with the  


diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 5f439da..a59b2ec 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -240,11 +240,12 @@ the ATTACH_DIR property) their own attachment  
  (defun org-attach-commit ()
    "Commit changes to git if `org-attach-directory' is properly  
  This checks for the existence of a \".git\" directory in that  
-  (let ((dir (expand-file-name org-attach-directory)))
-    (if (file-exists-p (expand-file-name ".git" dir))
+  (let ((dir (org-attach-dir)))
+    (if (and dir
+             (= 0 (shell-command
+                   (concat "(cd " dir "; git add .)"))))
  	 (concat "(cd " dir "; "
-		 " git add .; "
  		 " git ls-files --deleted -z | xargs -0 git rm; "
  		 " git commit -m 'Synchronized attachments')")))))

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-03 16:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-03 16:09 org-attach git-commit limitations Christopher League

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


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).