scripts/bash_aliases: man_gitstaged(): Script around a porcelain git command

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>
This commit is contained in:
Alejandro Colomar 2021-05-09 23:38:57 +02:00 committed by Michael Kerrisk
parent f493a71fe1
commit b08daf3c0c
1 changed files with 3 additions and 5 deletions

View 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/, $//"
}
########################################################################