From 28392e2704a30a271567b55f78c98541e46ee6f2 Mon Sep 17 00:00:00 2001 From: "G.raud" Date: Tue, 31 Oct 2017 02:03:58 +0100 Subject: [PATCH 1/2] Support newlines in git aliases that are shell commands Parse an aliases' newline-delimited list that does not contain the values, then retrieve each value one by one. --- git-sh.bash | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git-sh.bash b/git-sh.bash index 1891700..69a65c7 100644 --- a/git-sh.bash +++ b/git-sh.bash @@ -163,10 +163,11 @@ done # Create aliases for everything defined in the gitconfig [alias] section. _git_import_aliases () { eval "$( - git config --get-regexp 'alias\..*' | - sed 's/^alias\.//' | - while read key command + git config --list --name-only | + sed -n 's/^alias\.//p' | + while read key do + command=$(git config --get "alias.$key") if expr -- "$command" : '!' >/dev/null then echo "alias $key='git $key'" else echo "gitalias $key=\"git $command\"" From 6f15a738e2577bfb5590140c9b706a98c6c67399 Mon Sep 17 00:00:00 2001 From: "G.raud" Date: Tue, 31 Oct 2017 02:30:18 +0100 Subject: [PATCH 2/2] Support newlines in git aliases that are not shell commands The newlines are changed to spaces in the alias to avoid the execution of several shell commands just as git (2.11) does. --- git-sh.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git-sh.bash b/git-sh.bash index 69a65c7..85be066 100644 --- a/git-sh.bash +++ b/git-sh.bash @@ -170,7 +170,9 @@ _git_import_aliases () { command=$(git config --get "alias.$key") if expr -- "$command" : '!' >/dev/null then echo "alias $key='git $key'" - else echo "gitalias $key=\"git $command\"" + else echo "gitalias $key=\"git $(set -f; printf '%s ' $command)\"" + # Newlines in aliases that are not shell commands will be + # considered whitespace (as git itself would do). fi done )"