]> git.eshelyaron.com Git - emacs.git/commitdiff
Improved git-add completion
authorPeter Seibel <peter@gigamonkeys.com>
Sat, 18 Jan 2025 15:54:51 +0000 (07:54 -0800)
committerEshel Yaron <me@eshelyaron.com>
Mon, 20 Jan 2025 15:58:55 +0000 (16:58 +0100)
* lisp/pcmpl-git.el (pcomplete/git)): Complete untracked files.
(Bug#75336)

Copyright-paperwork-exempt: yes
(cherry picked from commit 2fd72a6ed3f6ea2937b38a4d74d93e8cfa1a54fb)

lisp/pcmpl-git.el

index 1c2b71bad8a3dbb8fb60cd200adc1e5b25135870..a9a4f2b20f5ad7afb512ecbfab15308fa177f03c 100644 (file)
@@ -82,8 +82,18 @@ Files listed by `git ls-files ARGS' satisfy the predicate."
                   (pcomplete-from-help `(,vc-git-program "help" ,subcmd)
                                        :argument
                                        "-+\\(?:\\[no-\\]\\)?[a-z-]+=?"))))
+               ;; Complete modified tracked files and untracked files and
+               ;; ignored files if -f or --force is specified.
+               ("add"
+                (pcomplete-here
+                 (pcomplete-entries
+                  nil
+                  (let ((flags (list "-o" "-m")))
+                    (unless (or (member "-f" pcomplete-args) (member "--force" pcomplete-args))
+                      (push "--exclude-standard" flags))
+                    (apply #'pcmpl-git--tracked-file-predicate flags)))))
                ;; Complete modified tracked files
-               ((or "add" "commit" "restore")
+               ((or "commit" "restore")
                 (pcomplete-here
                  (pcomplete-entries
                   nil (pcmpl-git--tracked-file-predicate "-m"))))