Skip to content

Commit f24a595

Browse files
mantizgitster
authored andcommitted
completion: Allow dash as the first character for __git_ps1
If the argument for `__git_ps1` begins with a dash, `printf` tries to interpret it as an option which results in an error message. The problem is solved by adding '--' before the argument to tell `printf` to not interpret the following argument as an option. Adding '--' directly to the argument does not help because the argument is enclosed by double quotes. Signed-off-by: Christian Hammerl <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 233054d commit f24a595

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ __git_ps1 ()
313313
fi
314314

315315
local f="$w$i$s$u"
316-
printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
316+
printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
317317
fi
318318
}
319319

0 commit comments

Comments
 (0)