From ff623acacf508f4356a601fe304dfab18637f3a4 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Mon, 26 Dec 2022 18:04:59 -0500 Subject: km/magit-insert-staged-file: Strip directory by default --- lisp/km-magit.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/km-magit.el b/lisp/km-magit.el index 08ddd06..92ba112 100644 --- a/lisp/km-magit.el +++ b/lisp/km-magit.el @@ -469,13 +469,13 @@ N defaults to 20." (1 (car files)) (t (magit-completing-read "File" files nil t)))))) -(defun km/magit-insert-staged-file (&optional no-directory) +(defun km/magit-insert-staged-file (&optional full-name) "Select a staged file to insert. This is useful for referring to file names in commit messages. By default, the path for the file name is relative to the top directory of the repository. Remove the directory component from -the file name if NO-DIRECTORY is non-nil. +the file name unless FULL-NAME is non-nil. If there are no staged files, look instead at files that changed in HEAD. These rules will usually offer the files of interest @@ -491,7 +491,7 @@ command will still offer the staged files)." (0 (error "No files found")) (t (completing-read "Staged file: " files nil t))))) - (insert (if no-directory (file-name-nondirectory file) file))))) + (insert (if full-name file (file-name-nondirectory file)))))) (defun km/magit-shorten-hash (hash &optional n) (magit-rev-parse (format "--short=%s" (or n (magit-abbrev-length))) hash)) -- cgit v1.2.3