git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
From: Dorab Patel <dorabpatel@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Eric Sunshine <sunshine@sunshineco.com>, Alexandre Julliard <julliard@winehq.org>, Dorab Patel <dorabpatel@gmail.com>
Subject: [PATCH v2] git.el: handle default excludesfile properly
Date: Mon,  5 Mar 2018 20:38:46 -0800
Message-ID: <20180306043846.33733-1-dorabpatel@gmail.com> (raw)
In-Reply-To: <20180303034803.21589-1-dorabpatel@gmail.com>

The previous version only looked at core.excludesfile for locating the
excludesfile.  So, when core.excludesfile was not defined, it did not
use the relevant default locations for the global excludes file.

The issue is in git-get-exclude-files().  Investigation shows that
git-get-exclude-files() is only called from
git-run-ls-files-with-excludes().  Modifying
git-run-ls-files-with-excludes() to use the "--exclude-standard"
option to git-run-ls-files() obviates the need for
git-get-exclude-files() altogether, which is now removed.  In
addition, the "--exclude-per-directory" option to git-run-ls-files()
is used only when git-per-dir-ignore-file is not the default
(.gitignore), since the default case is handled by the
"--exclude-standard" option.

Looking at the history shows that git-get-exclude-files() was
implemented by commit 274e13e0e9 (git.el: Take into account the
core.excludesfile config option., 2007-07-31), whereas the
"--exclude-standard" option was introduced by commit 8e7b07c8a7
(git-ls-files: add --exclude-standard, 2007-11-15), three and a half
months later.  This explains why the "--exclude-standard" option was
not used in the original code.

Signed-off-by: Dorab Patel <dorabpatel@gmail.com>
---

Notes:
    The original patch[1] V1 attempted to add code to
    git-get-exclude-files() to handle the case when core.excludesfile was
    not defined.  This involved code to check for the env variable
    XDG_CONFIG_HOME and related processing to find the value of the
    default excludesfile.  Further investigation showed that using the
    "--exclude-standard" option to git-run-ls-files-with-excludes()
    already does similar processing.  Hence the V2 patch uses the
    "--exclude-standard" option and does away with
    git-get-exclude-files().
    
    [1] https://public-inbox.org/git/20180303034803.21589-1-dorabpatel@gmail.com/

 contrib/emacs/git.el | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 97919f2d7..cef42f1de 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -755,22 +755,13 @@ Return the list of files that haven't been handled."
       (setq unmerged-files (nreverse unmerged-files))  ;; assume it is sorted already
       (git-set-filenames-state status 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-run-ls-files-with-excludes (status files default-state &rest options)
-  "Run git-ls-files on FILES with appropriate --exclude-from options."
-  (let ((exclude-files (git-get-exclude-files)))
-    (apply #'git-run-ls-files status files default-state "--directory" "--no-empty-directory"
-           (concat "--exclude-per-directory=" git-per-dir-ignore-file)
-           (append options (mapcar (lambda (f) (concat "--exclude-from=" f)) exclude-files)))))
+  "Run git-ls-files on FILES with appropriate exclude options."
+  (apply #'git-run-ls-files status files default-state
+	 "--directory" "--no-empty-directory" "--exclude-standard"
+	 (append (unless (string-equal git-per-dir-ignore-file ".gitignore") ; handled by --exclude-standard
+		   (list (concat "--exclude-per-directory=" git-per-dir-ignore-file)))
+		 options)))
 
 (defun git-update-status-files (&optional files mark-files)
   "Update the status of FILES from the index.
-- 
2.16.2


  parent reply index

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-03  3:48 [PATCH] " Dorab Patel
2018-03-03  8:42 ` Eric Sunshine
2018-03-04  1:36   ` Dorab Patel
2018-03-04  2:12     ` Eric Sunshine
2018-03-04  2:57       ` Dorab Patel
2018-03-04  4:34         ` Eric Sunshine
2018-03-05  2:36     ` Junio C Hamano
2018-03-06 11:54       ` Alexandre Julliard
2018-03-07 21:52         ` Dorab Patel
2018-03-08  9:41           ` Ævar Arnfjörð Bjarmason
2018-03-08  9:45         ` [PATCH] git{,-blame}.el: remove old bitrotting Emacs code Ævar Arnfjörð Bjarmason
2018-03-08 17:27           ` Junio C Hamano
2018-03-10 12:30             ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2018-03-10 16:50               ` Martin Ågren
2018-03-13 18:40                 ` Junio C Hamano
2018-03-08 17:55           ` [PATCH] " Kyle Meyer
2018-03-06  4:38 ` Dorab Patel [this message]
     [not found] <EKzyQbDEJGG4Lm5YboF8xg@mail.gmail.com>
2018-03-10 18:45 ` [PATCH v3] " Ævar Arnfjörð Bjarmason
2018-03-13 18:53   ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2018-03-13 22:14     ` Junio C Hamano
2018-03-27 16:57   ` [PATCH v3] " Jonathan Nieder
2018-04-11 20:42     ` [PATCH v4] " Ævar Arnfjörð Bjarmason
2018-04-12  2:19       ` Junio C Hamano
2018-04-12  6:52         ` Ævar Arnfjörð Bjarmason
2018-04-12  9:23           ` Junio C Hamano
2018-04-18 20:16             ` Todd Zullinger

Reply instructions:

You may reply publically 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: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20180306043846.33733-1-dorabpatel@gmail.com \
    --to=dorabpatel@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=julliard@winehq.org \
    --cc=sunshine@sunshineco.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

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox