Attachments: Remove dependence on xargs

Patch by David Maus, who writes:

> Attached patch for org-attach-commit in org-attach.el removes the
> dependency on the xargs command to remove files in the repository that
> were deleted in the attachment directory.
>
> Simply capture output of git ls-files --deleted -z in a temporary
> buffer, get the filenames from there via string-split and call git rm
> on each single file.
This commit is contained in:
Carsten Dominik 2010-03-24 22:17:28 +01:00
parent 1d4ee49c91
commit 7e476db196
2 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,7 @@
2010-03-24 Carsten Dominik <carsten.dominik@gmail.com> 2010-03-24 Carsten Dominik <carsten.dominik@gmail.com>
* org-attach.el (org-attach-commit): Remove dependence on xargs.
* org-latex.el (org-export-latex-fontify): Do not mistake table.el * org-latex.el (org-export-latex-fontify): Do not mistake table.el
borders for strike-through emphasis. borders for strike-through emphasis.

View File

@ -241,12 +241,17 @@ the ATTACH_DIR property) their own attachment directory."
"Commit changes to git if `org-attach-directory' is properly initialized. "Commit changes to git if `org-attach-directory' is properly initialized.
This checks for the existence of a \".git\" directory in that directory." This checks for the existence of a \".git\" directory in that directory."
(let ((dir (expand-file-name org-attach-directory))) (let ((dir (expand-file-name org-attach-directory)))
(if (file-exists-p (expand-file-name ".git" dir)) (when (file-exists-p (expand-file-name ".git" dir))
(shell-command (with-temp-buffer
(concat "(cd " dir "; " (cd dir)
" git add .; " (shell-command "git add .")
" git ls-files --deleted -z | xargs -0 git rm; " (shell-command "git ls-files --deleted -z" t)
" git commit -m 'Synchronized attachments')"))))) (mapc '(lambda (file)
(unless (string= file "")
(shell-command
(concat "git rm \"" file "\""))))
(split-string (buffer-string) ""))
(shell-command "git commit -m 'Synchronized attachments'")))))
(defun org-attach-tag (&optional off) (defun org-attach-tag (&optional off)
"Turn the autotag on or (if OFF is set) off." "Turn the autotag on or (if OFF is set) off."