Subject: [PATCH] Add file completion for git apply, am to pcomplete

From: Antero Mejr <[email-masked]>
Date: Sun, 16 Feb 2025 23:33:32 -0500

Tags: patch

This patch lets pcomplete recognize the "git apply" and "git am"
subcommands and complete filenames for patch files. This is helpful for
eshell.

>From 2c620140d45e4bcb3ea5d52470b6d6d783f1dcc4 Mon Sep 17 00:00:00 2001
From: Antero Mejr <[email-masked]>
Date: Tue, 28 Jan 2025 13:39:10 -0500
Subject: [PATCH] Add file completion for git apply, am to pcomplete

* lisp/pcmpl-git.el (pcomplete/git): Add an "apply" and "am" clause to
complete all files.
---
 lisp/pcmpl-git.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/pcmpl-git.el b/lisp/pcmpl-git.el
index f23002df28b..02af87f839d 100644
--- a/lisp/pcmpl-git.el
+++ b/lisp/pcmpl-git.el
@@ -114,7 +114,10 @@ Files listed by `git ls-files ARGS' satisfy the predicate."
                ;; Complete remotes and their revisions
                ((or "fetch" "pull" "push")
                 (pcomplete-here (process-lines vc-git-program "remote"))
-                (pcomplete-here (pcmpl-git--remote-refs (pcomplete-arg 1)))))))))
+                (pcomplete-here (pcmpl-git--remote-refs (pcomplete-arg 1))))
+               ;; Complete all files
+               ((or "apply" "am")
+                (pcomplete-here (pcomplete-entries))))))))
 
 (provide 'pcmpl-git)
 ;;; pcmpl-git.el ends here
-- 
2.43.0