From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher League Subject: org-attach git-commit limitations Date: Wed, 3 Jun 2009 12:09:40 -0400 Message-ID: <03D790AD-D9E8-49BA-BB70-079BA3777EAA@contrapunctus.net> Mime-Version: 1.0 (Apple Message framework v935.3) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MBt2G-0005Vm-U0 for emacs-orgmode@gnu.org; Wed, 03 Jun 2009 12:09:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MBt2B-0005Tj-VQ for emacs-orgmode@gnu.org; Wed, 03 Jun 2009 12:09:52 -0400 Received: from [199.232.76.173] (port=51312 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MBt2B-0005Tb-Ow for emacs-orgmode@gnu.org; Wed, 03 Jun 2009 12:09:47 -0400 Received: from contrapunctus.net ([207.210.219.173]:54026) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MBt2B-0003QX-F4 for emacs-orgmode@gnu.org; Wed, 03 Jun 2009 12:09:47 -0400 Received: from sagan.home.lan (cpe-98-14-64-90.nyc.res.rr.com [98.14.64.90]) by contrapunctus.net (Postfix) with ESMTP id 109A283D4 for ; Wed, 3 Jun 2009 11:43:44 -0400 (EDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org 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- attach-directory. 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 ATTACH_DIR_COMMIT property..? Thanks, Chris 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 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))) - (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 .)")))) (shell-command (concat "(cd " dir "; " - " git add .; " " git ls-files --deleted -z | xargs -0 git rm; " " git commit -m 'Synchronized attachments')")))))