From 9ec6eb1065c65b32e9a565a6b66298aa4f2e527c Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 25 Feb 2020 01:03:28 +0200 Subject: [PATCH] vc-dir-ignore: More accurately choose base directory * lisp/vc/vc-dir.el: (vc-dir-ignore): Use it (bug#37189). * lisp/vc/vc.el: (vc--ignore-base-dir): Extract from vc-ignore. --- lisp/vc/vc-dir.el | 7 ++++--- lisp/vc/vc.el | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index e5c5e16a17a..38b4937e854 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -879,9 +879,10 @@ If a prefix argument is given, ignore all marked files." (vc-ignore (vc-dir-fileinfo->name filearg)) t)) vc-ewoc) - (vc-ignore - (file-relative-name (vc-dir-current-file)) - default-directory))) + (let ((rel-dir (vc--ignore-base-dir))) + (vc-ignore + (file-relative-name (vc-dir-current-file) rel-dir) + rel-dir)))) (defun vc-dir-current-file () (let ((node (ewoc-locate vc-ewoc))) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 53491dd1b04..fe666413168 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1406,14 +1406,7 @@ When called interactively, prompt for a FILE to ignore, unless a prefix argument is given, in which case prompt for a file FILE to remove from the list of ignored files." (interactive - (let* ((backend (vc-responsible-backend default-directory)) - (rel-dir - (condition-case nil - (file-name-directory - (vc-call-backend backend 'find-ignore-file - default-directory)) - (vc-not-supported - default-directory))) + (let* ((rel-dir (vc--ignore-base-dir)) (file (read-file-name "File to ignore: "))) (when (and (file-name-absolute-p file) (file-in-directory-p file rel-dir)) @@ -1426,6 +1419,15 @@ remove from the list of ignored files." (error "Unknown backend")))) (vc-call-backend backend 'ignore file directory remove))) +(defun vc--ignore-base-dir () + (let ((backend (vc-responsible-backend default-directory))) + (condition-case nil + (file-name-directory + (vc-call-backend backend 'find-ignore-file + default-directory)) + (vc-not-supported + default-directory)))) + (defun vc-default-ignore (backend file &optional directory remove) "Ignore FILE under DIRECTORY (default is `default-directory'). FILE is a wildcard specification relative to DIRECTORY. -- 2.39.2