From: Christopher League <league@contrapunctus.net>
To: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: org-attach git-commit limitations
Date: Wed, 3 Jun 2009 12:09:40 -0400 [thread overview]
Message-ID: <03D790AD-D9E8-49BA-BB70-079BA3777EAA@contrapunctus.net> (raw)
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')")))))
reply other threads:[~2009-06-03 16:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=03D790AD-D9E8-49BA-BB70-079BA3777EAA@contrapunctus.net \
--to=league@contrapunctus.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).