completion: avoid trailing space for --exec-path

"--exec-path" looks to the completion script like an unambiguous successful completion, but it is wrong to emit a SP after it as if declaring that we are done with completion; the user could be trying to do git --exec-path; # print name of helper directory or git --exec-path=/path/to/alternative/helper/dir <subcommand> so the most helpful thing to do is to leave out the trailing space and leave it to the operator to type an equal sign or carriage return according to the situation. [fc: added tests] Cc: Andreas Schwab <schwab@linux-m68k.org> Reported-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Apr 15, 2012 at 22:44 UTC 3ffcd08688a0e5f5de808c1077d10552d1f84e70
2 files changed +7 -1
contrib/completion/git-completion.bash
+1
@@ -2639,6 +2639,7 @@ _git ()
2639 --bare
2640 --version
2641 --exec-path
2642 + --exec-path=
2643 --html-path
2644 --info-path
2645 --work-tree=
t/t9902-completion.sh
+6 -1
@@ -179,6 +179,7 @@ test_expect_success 'double dash "git" itself' '
179 --bare Z
180 --version Z
181 --exec-path Z
182 + --exec-path=
183 --html-path Z
184 --info-path Z
185 --work-tree=
@@ -207,7 +208,11 @@ test_expect_success 'double dash "git checkout"' '
208 test_expect_success 'general options' '
209 test_completion "git --ver" "--version " &&
210 test_completion "git --hel" "--help " &&
210 - test_completion "git --exe" "--exec-path " &&
211 + sed -e "s/Z$//" >expected <<-\EOF &&
212 + --exec-path Z
213 + --exec-path=
214 + EOF
215 + test_completion "git --exe" &&
216 test_completion "git --htm" "--html-path " &&
217 test_completion "git --pag" "--paginate " &&
218 test_completion "git --no-p" "--no-pager " &&