ompletion: complete all possible -no-<options>
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest3 patches 0 repliesNew
- v23 patches 2 repliesSuperseded
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | parse-options: option to let --git-completion-helper show negative formcontrib/ parse-options.c t/ | +46 | 0 replies | |
| 2/3 | completion: suppress some -no- optionsbuiltin/ t/ | +6 | 0 replies | |
| 3/3 | completion: collapse extra --no-.. optionscontrib/ parse-options.c t/ | +115 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH v3 0/3] ompletion: complete all possible -no-<options>
v3 fixes an annoying bug in 3/3. If you do "git commit --fi<tab>" then the "fi" part is eaten up by bash and you got back to "git commit --" on the command line.
This is because we give COMPREPLY with two options "--fixup" and "--no-...". The second one forces the common prefix "--" for both of them, instead of "--fi". Bash does the rest according to the book.
Some tests are added to verify new behavior in __gitcomp and make sure this does not happen again.
contrib/completion/git-completion.bash +4 -1
@@ -286,7 +286,10 @@ __gitcomp () local c i=0 IFS=$' \t\n' for c in $1; do if [[ $c == "--" ]]; then - COMPREPLY[i++]="${2-}--no-...${4-} " + c="--no-...${4-}" + if [[ $c == "$cur_"* ]]; then + COMPREPLY[i++]="${2-}$c " + fi break fi c="$c${4-}"
t/t9902-completion.sh +36 -0
@@ -459,6 +459,42 @@ test_expect_success '__gitcomp - suffix' ' EOF ' +test_expect_success '__gitcomp - ignore optional negative options' ' + test_gitcomp "--" "--abc --def --no-one -- --no-two" <<-\EOF + --abc Z + --def Z + --no-one Z + --no-... Z + EOF +' + +test_expect_success '__gitcomp - ignore/narrow optional negative options' ' + test_gitcomp "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF + --abc Z + --abcdef Z + EOF +' + +test_expect_success '__gitcomp - ignore/narrow optional negative options' ' + test_gitcomp "--n" "--abc --def --no-one -- --no-two" <<-\EOF + --no-one Z + --no-... Z + EOF +' + +test_expect_success '__gitcomp - expand all negative options' ' + test_gitcomp "--no-" "--abc --def --no-one -- --no-two" <<-\EOF + --no-one Z + --no-two Z + EOF +' + +test_expect_success '__gitcomp - expand/narrow all negative options' ' + test_gitcomp "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF + --no-one Z + EOF +' + test_expect_success '__gitcomp - doesnt fail because of invalid variable name' ' __gitcomp "$invalid_variable_name" '
Nguyễn Thái Ngọc Duy (3):
parse-options: option to let --git-completion-helper show negative
form
completion: suppress some -no- options
completion: collapse extra --no-.. options
builtin/checkout.c | 10 +++-- contrib/completion/git-completion.bash | 61 ++++++++++++++++---------- parse-options.c | 58 ++++++++++++++++++++++-- t/t9902-completion.sh | 41 ++++++++++++++++- 4 files changed, 136 insertions(+), 34 deletions(-)
Signature · 1 line
2.18.0.rc0.333.g22e6ee6cdf