{"thread":{"id":"9320","subject":"[RFH PATCH] Teach the emacs git mode about core.excludesfile","startedAt":"2007-07-31T01:13:50Z","lastAt":"2007-07-31T19:57:00Z","messageCount":4,"participants":["Karl Hasselström","Matthieu Moy","Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"49178","messageId":"20070731011100.23561.27554.stgit@yoghurt","threadId":"9320","inReplyTo":null,"subject":"[RFH PATCH] Teach the emacs git mode about core.excludesfile","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-07-31T01:13:50Z","receivedAt":"2007-07-31T01:13:50Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"If there is a core.excludesfile option specified, let the emacs git\nmode take exclude patterns from that file, since that's what the docs\nsay, and what everyone else is already doing.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n---\n\nThis is a Request For Help. The patch works, but is clearly the work\nof someone who is not very fluent in elisp. Just look at all that\nduplicated code I've introduced!\n\n contrib/emacs/git.el |   19 ++++++++++++++++---\n 1 files changed, 16 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 53dd703..357e6d2 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -589,6 +589,13 @@ Return the list of files that haven't been handled.\"\n           (when node (push (ewoc-data node) unmerged-files))))\n       (git-set-files-state unmerged-files 'unmerged))))\n \n+(defun git-core-excludesfile ()\n+  \"The file core.excludesfile, or nil if it isn't specified.\"\n+  (let ((fn (git-config \"core.excludesfile\")))\n+    (if (and fn (file-readable-p fn))\n+        fn\n+      nil)))\n+\n (defun git-update-status-files (files &optional default-state)\n   \"Update the status of FILES from the index.\"\n   (unless git-status (error \"Not in git-status buffer.\"))\n@@ -600,9 +607,15 @@ Return the list of files that haven't been handled.\"\n     (git-run-ls-unmerged status files)\n     (when (and (or (not files) remaining-files)\n                (file-readable-p \".git/info/exclude\"))\n-      (setq remaining-files (git-run-ls-files status remaining-files\n-                                              'unknown \"-o\" \"--exclude-from=.git/info/exclude\"\n-                                              (concat \"--exclude-per-directory=\" git-per-dir-ignore-file))))\n+      (let ((ce (git-core-excludesfile)))\n+        (if ce\n+            (setq remaining-files (git-run-ls-files status remaining-files\n+                                                    'unknown \"-o\" \"--exclude-from=.git/info/exclude\"\n+                                                    (concat \"--exclude-per-directory=\" git-per-dir-ignore-file)\n+                                                    (concat \"--exclude-from=\" ce)))\n+          (setq remaining-files (git-run-ls-files status remaining-files\n+                                                  'unknown \"-o\" \"--exclude-from=.git/info/exclude\"\n+                                                  (concat \"--exclude-per-directory=\" git-per-dir-ignore-file))))))\n     ; mark remaining files with the default state (or remove them if nil)\n     (when remaining-files\n       (if default-state\n"},{"id":"49180","messageId":"vpqzm1dqqps.fsf@bauges.imag.fr","threadId":"9320","inReplyTo":"20070731011100.23561.27554.stgit@yoghurt","subject":"Re: [RFH PATCH] Teach the emacs git mode about core.excludesfile","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2007-07-31T01:58:23Z","receivedAt":"2007-07-31T01:58:23Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Karl Hasselström <kha@treskal.com> writes:\n\n> If there is a core.excludesfile option specified, let the emacs git\n> mode take exclude patterns from that file, since that's what the docs\n> say, and what everyone else is already doing.\n>\n> Signed-off-by: Karl Hasselström <kha@treskal.com>\n> ---\n>\n> This is a Request For Help. The patch works, but is clearly the work\n> of someone who is not very fluent in elisp. Just look at all that\n> duplicated code I've introduced!\n>\n>  contrib/emacs/git.el |   19 ++++++++++++++++---\n>  1 files changed, 16 insertions(+), 3 deletions(-)\n>\n> diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\n> index 53dd703..357e6d2 100644\n> --- a/contrib/emacs/git.el\n> +++ b/contrib/emacs/git.el\n> @@ -589,6 +589,13 @@ Return the list of files that haven't been handled.\"\n>            (when node (push (ewoc-data node) unmerged-files))))\n>        (git-set-files-state unmerged-files 'unmerged))))\n>  \n> +(defun git-core-excludesfile ()\n> +  \"The file core.excludesfile, or nil if it isn't specified.\"\n> +  (let ((fn (git-config \"core.excludesfile\")))\n> +    (if (and fn (file-readable-p fn))\n> +        fn\n> +      nil)))\n> +\n>  (defun git-update-status-files (files &optional default-state)\n>    \"Update the status of FILES from the index.\"\n>    (unless git-status (error \"Not in git-status buffer.\"))\n> @@ -600,9 +607,15 @@ Return the list of files that haven't been handled.\"\n>      (git-run-ls-unmerged status files)\n>      (when (and (or (not files) remaining-files)\n>                 (file-readable-p \".git/info/exclude\"))\n> -      (setq remaining-files (git-run-ls-files status remaining-files\n> -                                              'unknown \"-o\" \"--exclude-from=.git/info/exclude\"\n> -                                              (concat \"--exclude-per-directory=\" git-per-dir-ignore-file))))\n\nWhat you're looking for probably looks like that:\n\n         (let ((ce (git-core-excludesfile)))\n           (setq remaining-files (apply 'git-run-ls-files \n                                      `(,status ,remaining-files\n                                        unknown \"-o\" ... ,@(when ce\n                                                             (list ce))))))\n\n(the magic is in the backquote and the ,@ in `(... ,@(...)))\n\n(totally untested, probably bogus)\n\n-- \nMatthieu\n"},{"id":"49203","messageId":"87abtcvozz.fsf@wine.dyndns.org","threadId":"9320","inReplyTo":"20070731011100.23561.27554.stgit@yoghurt","subject":"Re: [RFH PATCH] Teach the emacs git mode about core.excludesfile","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2007-07-31T10:36:32Z","receivedAt":"2007-07-31T10:36:32Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Karl Hasselström <kha@treskal.com> writes:\n\n> This is a Request For Help. The patch works, but is clearly the work\n> of someone who is not very fluent in elisp. Just look at all that\n> duplicated code I've introduced!\n\nI would do it this way:\n\nFrom: Alexandre Julliard <julliard@winehq.org>\nDate: Tue, 31 Jul 2007 12:19:05 +0200\nSubject: [PATCH] git.el: Take into account the core.excludesfile config option.\n\nAlso don't require .git/info/exclude to exist in order to list unknown\nfiles.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n contrib/emacs/git.el |   20 +++++++++++++++-----\n 1 files changed, 15 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 53dd703..9bcd7c4 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -589,6 +589,16 @@ Return the list of files that haven't been handled.\"\n           (when node (push (ewoc-data node) unmerged-files))))\n       (git-set-files-state unmerged-files 'unmerged))))\n \n+(defun git-get-exclude-files ()\n+  \"Get the list of exclude files to pass to git-ls-files.\"\n+  (let (files\n+        (config (git-config \"core.excludesfile\")))\n+    (when (file-readable-p \".git/info/exclude\")\n+      (push \".git/info/exclude\" files))\n+    (when (and config (file-readable-p config))\n+      (push config files))\n+    files))\n+\n (defun git-update-status-files (files &optional default-state)\n   \"Update the status of FILES from the index.\"\n   (unless git-status (error \"Not in git-status buffer.\"))\n@@ -598,11 +608,11 @@ Return the list of files that haven't been handled.\"\n               (git-run-ls-files status files 'added \"-c\")\n             (git-run-diff-index status files))))\n     (git-run-ls-unmerged status files)\n-    (when (and (or (not files) remaining-files)\n-               (file-readable-p \".git/info/exclude\"))\n-      (setq remaining-files (git-run-ls-files status remaining-files\n-                                              'unknown \"-o\" \"--exclude-from=.git/info/exclude\"\n-                                              (concat \"--exclude-per-directory=\" git-per-dir-ignore-file))))\n+    (when (or (not files) remaining-files)\n+      (let ((exclude-files (git-get-exclude-files)))\n+        (setq remaining-files (apply #'git-run-ls-files status remaining-files 'unknown \"-o\"\n+                                     (concat \"--exclude-per-directory=\" git-per-dir-ignore-file)\n+                                     (mapcar (lambda (f) (concat \"--exclude-from=\" f)) exclude-files)))))\n     ; mark remaining files with the default state (or remove them if nil)\n     (when remaining-files\n       (if default-state\n-- \n1.5.3.rc3.92.g70c7b\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"},{"id":"49243","messageId":"20070731195700.GC28331@diana.vm.bytemark.co.uk","threadId":"9320","inReplyTo":"87abtcvozz.fsf@wine.dyndns.org","subject":"Re: [RFH PATCH] Teach the emacs git mode about core.excludesfile","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-07-31T19:57:00Z","receivedAt":"2007-07-31T19:57:00Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-07-31 12:36:32 +0200, Alexandre Julliard wrote:\n\n> I would do it this way:\n>\n> From: Alexandre Julliard <julliard@winehq.org>\n> Date: Tue, 31 Jul 2007 12:19:05 +0200\n> Subject: [PATCH] git.el: Take into account the core.excludesfile config option.\n>\n> Also don't require .git/info/exclude to exist in order to list unknown\n> files.\n>\n> Signed-off-by: Alexandre Julliard <julliard@winehq.org>\n\nAcked-by: Karl Hasselström <kha@treskal.com>\n\nWorks beautifully, thanks.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"}]}