diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2026-03-31 22:45:36 +0200 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2026-03-31 22:45:36 +0200 |
| commit | 52eecabe7c996865436f7e62fac8ab71f98f8efa (patch) | |
| tree | d1f1ea8cc17c0c3e7ce25c5c051b7badb73ebc79 | |
| parent | b9b68e26788af49250208a5c0327daf434b613f2 (diff) | |
magit-gitignore-read-pattern: Drop weird usage of diff arguments
That was only used in an edge-case and even then it made little sense.
Instead add a DIRECTORY and make `magit-gitignore-in-subdir' pass the
selected subdirectory. The intention is to limit the patterns to that
directory, but that does not work yet because there is more weirdness
in `magit--gitignore-patterns'.
| -rw-r--r-- | lisp/magit-gitignore.el | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lisp/magit-gitignore.el b/lisp/magit-gitignore.el index 71f3d38..f83ab77 100644 --- a/lisp/magit-gitignore.el +++ b/lisp/magit-gitignore.el @@ -65,8 +65,8 @@ Prompt the user for a directory and add the rule to the tracked, they are shared with other clones of the repository. Also stage the file." :description "shared in subdirectory (path/to/.gitignore)" - (interactive (list (magit-gitignore-read-pattern) - (read-directory-name "Limit rule to files in: "))) + (interactive (let ((dir (read-directory-name "Limit rule to files in: "))) + (list (magit-gitignore-read-pattern dir) dir))) (magit--gitignore rule (expand-file-name ".gitignore" directory) t)) ;;;###autoload(autoload 'magit-gitignore-in-gitdir "magit-gitignore" nil t) @@ -107,11 +107,9 @@ Rules that are defined in that file affect all local repositories." (magit-run-git "add" (magit-convert-filename-for-git file))) (magit-refresh))) -(defun magit-gitignore-read-pattern () - (let* ((base (car magit-buffer-diff-files)) - (base (and base (file-directory-p base) base)) - (choices (magit--gitignore-patterns base)) - (default (magit-current-file))) +(defun magit-gitignore-read-pattern (&optional directory) + (let ((choices (magit--gitignore-patterns directory)) + (default (magit-current-file))) (when default (setq default (concat "/" default)) (unless (member default choices) |
