Skip to content

Commit e0d7805

Browse files
bebarinogitster
authored andcommitted
completion: fix alias listings with newlines
Aliases with newlines have been a problem since commit 56fc25f (Bash completion support for remotes in .git/config., 2006-11-05). The chance of the problem occurring has been slim at best, until commit 518ef8f (completion: Replace config --list with --get-regexp, 2009-09-11) removed the case statement introduced by commit 56fc25f. Before removing the case statement, most aliases with newlines would work unless they were specially crafted as follows [alias] foo = "log -1 --pretty='format:%s\nalias.error=broken'" After removing the case statement, a more benign alias like [alias] whowhat = "log -1 --pretty='format:%an <%ae>\n%s'" wont-complete = ... would cause the completion to break badly. For now, revert the removal of the case statement until someone comes up with a better way to get keys from git-config. Signed-off-by: Stephen Boyd <[email protected]> Acked-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 427e586 commit e0d7805

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

contrib/completion/git-completion.bash

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,12 @@ __git_aliases ()
602602
{
603603
local i IFS=$'\n'
604604
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
605-
i="${i#alias.}"
606-
echo "${i/ */}"
605+
case "$i" in
606+
alias.*)
607+
i="${i#alias.}"
608+
echo "${i/ */}"
609+
;;
610+
esac
607611
done
608612
}
609613

0 commit comments

Comments
 (0)