summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDorab Patel <dorabpatel@gmail.com>2018-03-05 20:38:46 -0800
committerJunio C Hamano <gitster@pobox.com>2018-03-05 23:30:27 -0800
commita0f3b0e1027d6a0cd82678081a54dd3cc7c5a378 (patch)
tree873ab85651537f00270414150916b1be0545be9c
parent38e79b1fdab9244e1727d0698afcf3bb8956c0a4 (diff)
downloadgit-dp/git-el-ls-files-excludes.tar.gz
git.el: handle default excludesfile properlydp/git-el-ls-files-excludes
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--contrib/emacs/git.el21
1 files changed, 6 insertions, 15 deletions
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 97919f2d73..cef42f1ded 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.