Skip to content

Commit 3ffcd08

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Reported-by: Felipe Contreras <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 69ef3c0 commit 3ffcd08

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,6 +2639,7 @@ _git ()
26392639
--bare
26402640
--version
26412641
--exec-path
2642+
--exec-path=
26422643
--html-path
26432644
--info-path
26442645
--work-tree=

t/t9902-completion.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ test_expect_success 'double dash "git" itself' '
179179
--bare Z
180180
--version Z
181181
--exec-path Z
182+
--exec-path=
182183
--html-path Z
183184
--info-path Z
184185
--work-tree=
@@ -207,7 +208,11 @@ test_expect_success 'double dash "git checkout"' '
207208
test_expect_success 'general options' '
208209
test_completion "git --ver" "--version " &&
209210
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" &&
211216
test_completion "git --htm" "--html-path " &&
212217
test_completion "git --pag" "--paginate " &&
213218
test_completion "git --no-p" "--no-pager " &&

0 commit comments

Comments
 (0)