]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
scripts/bash_aliases: man_gitstaged(): Script around a porcelain git command
authorAlejandro Colomar <alx.manpages@gmail.com>
Sun, 9 May 2021 21:38:57 +0000 (23:38 +0200)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Sun, 9 May 2021 23:27:19 +0000 (11:27 +1200)
The output of 'git status' is not stable.

The more stable 'git status --porcelain' is more complex,
and scripting around it would be more complex.

However, 'git diff --staged --name-only' produces
the output that we were lookiong for.

Reported-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
scripts/bash_aliases

index 8cedc4efc94b865266b53cfa2dd37a011030dbe4..d9b6047d16feff5d318da080f247c37240c10243 100644 (file)
@@ -153,13 +153,11 @@ function pdfman()
 
 function man_gitstaged()
 {
-       git status                                                      \
-       |sed "/Changes not staged for commit:/q"                        \
-       |grep -E "^\s*(modified|deleted|new file):"                     \
-       |sed "s/^.*:\s*/, /"                                            \
+       git diff --staged --name-only                                   \
+       |sed "s/$/, /"                                                  \
        |sed "s%man[1-9]/%%"                                            \
        |tr -d '\n'                                                     \
-       |sed "s/^, //"
+       |sed "s/, $//"
 }
 
 ########################################################################