All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Julliard <julliard@winehq.org>
To: "Karl Hasselström" <kha@treskal.com>
Cc: git@vger.kernel.org
Subject: Re: [RFH PATCH] Teach the emacs git mode about core.excludesfile
Date: Tue, 31 Jul 2007 12:36:32 +0200	[thread overview]
Message-ID: <87abtcvozz.fsf@wine.dyndns.org> (raw)
In-Reply-To: <20070731011100.23561.27554.stgit@yoghurt> ("Karl Hasselström"'s message of "Tue\, 31 Jul 2007 03\:13\:50 +0200")

Karl Hasselström <kha@treskal.com> writes:

> 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!

I would do it this way:

From: Alexandre Julliard <julliard@winehq.org>
Date: Tue, 31 Jul 2007 12:19:05 +0200
Subject: [PATCH] git.el: Take into account the core.excludesfile config option.

Also don't require .git/info/exclude to exist in order to list unknown
files.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
---
 contrib/emacs/git.el |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 53dd703..9bcd7c4 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -589,6 +589,16 @@ 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-get-exclude-files ()
+  "Get the list of exclude files to pass to git-ls-files."
+  (let (files
+        (config (git-config "core.excludesfile")))
+    (when (file-readable-p ".git/info/exclude")
+      (push ".git/info/exclude" files))
+    (when (and config (file-readable-p config))
+      (push config files))
+    files))
+
 (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."))
@@ -598,11 +608,11 @@ Return the list of files that haven't been handled."
               (git-run-ls-files status files 'added "-c")
             (git-run-diff-index status files))))
     (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))))
+    (when (or (not files) remaining-files)
+      (let ((exclude-files (git-get-exclude-files)))
+        (setq remaining-files (apply #'git-run-ls-files status remaining-files 'unknown "-o"
+                                     (concat "--exclude-per-directory=" git-per-dir-ignore-file)
+                                     (mapcar (lambda (f) (concat "--exclude-from=" f)) exclude-files)))))
     ; mark remaining files with the default state (or remove them if nil)
     (when remaining-files
       (if default-state
-- 
1.5.3.rc3.92.g70c7b

-- 
Alexandre Julliard
julliard@winehq.org

  parent reply	other threads:[~2007-07-31 10:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-31  1:13 [RFH PATCH] Teach the emacs git mode about core.excludesfile Karl Hasselström
2007-07-31  1:58 ` Matthieu Moy
2007-07-31 10:36 ` Alexandre Julliard [this message]
2007-07-31 19:57   ` Karl Hasselström
  -- strict thread matches above, loose matches on Subject: below --
2007-07-31  1:30 Karl Hasselström

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87abtcvozz.fsf@wine.dyndns.org \
    --to=julliard@winehq.org \
    --cc=git@vger.kernel.org \
    --cc=kha@treskal.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.