Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [RFH PATCH] Teach the emacs git mode about core.excludesfile

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:43:25

Karl Hasselström [off-list ref] writes:
quoted hunk
If there is a core.excludesfile option specified, let the emacs git
mode take exclude patterns from that file, since that's what the docs
say, and what everyone else is already doing.

Signed-off-by: Karl Hasselström <redacted>
---

This is a Request For Help. The patch works, but is clearly the work
of someone who is not very fluent in elisp. Just look at all that
duplicated code I've introduced!

 contrib/emacs/git.el |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 53dd703..357e6d2 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -589,6 +589,13 @@ Return the list of files that haven't been handled."
           (when node (push (ewoc-data node) unmerged-files))))
       (git-set-files-state unmerged-files 'unmerged))))
 
+(defun git-core-excludesfile ()
+  "The file core.excludesfile, or nil if it isn't specified."
+  (let ((fn (git-config "core.excludesfile")))
+    (if (and fn (file-readable-p fn))
+        fn
+      nil)))
+
 (defun git-update-status-files (files &optional default-state)
   "Update the status of FILES from the index."
   (unless git-status (error "Not in git-status buffer."))
@@ -600,9 +607,15 @@ Return the list of files that haven't been handled."
     (git-run-ls-unmerged status files)
     (when (and (or (not files) remaining-files)
                (file-readable-p ".git/info/exclude"))
-      (setq remaining-files (git-run-ls-files status remaining-files
-                                              'unknown "-o" "--exclude-from=.git/info/exclude"
-                                              (concat "--exclude-per-directory=" git-per-dir-ignore-file))))
What you're looking for probably looks like that:

         (let ((ce (git-core-excludesfile)))
           (setq remaining-files (apply 'git-run-ls-files 
                                      `(,status ,remaining-files
                                        unknown "-o" ... ,@(when ce
                                                             (list ce))))))

(the magic is in the backquote and the ,@ in `(... ,@(...)))

(totally untested, probably bogus)

-- 
Matthieu
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help