Commit e94fb44
git-completion.bash: pass $__git_subcommand_idx from __git_main()
Many completion functions perform hardcoded comparisons with $cword.
This fails in the case where the main git command is given arguments
(e.g. `git -C . bundle<TAB>` would fail to complete its subcommands).
Even _git_worktree(), which uses __git_find_on_cmdline(), could still
fail. With something like `git -C add worktree move<TAB>`, the
subcommand would be incorrectly identified as "add" instead of "move".
Assign $__git_subcommand_idx in __git_main(), where the git subcommand
is actually found and the corresponding completion function is called.
Use this variable to replace hardcoded comparisons with $cword.
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent a5828ae commit e94fb44
1 file changed
+11
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1474 | 1474 | | |
1475 | 1475 | | |
1476 | 1476 | | |
1477 | | - | |
| 1477 | + | |
1478 | 1478 | | |
1479 | | - | |
| 1479 | + | |
1480 | 1480 | | |
1481 | 1481 | | |
1482 | | - | |
| 1482 | + | |
1483 | 1483 | | |
1484 | 1484 | | |
1485 | 1485 | | |
| |||
1894 | 1894 | | |
1895 | 1895 | | |
1896 | 1896 | | |
1897 | | - | |
| 1897 | + | |
1898 | 1898 | | |
1899 | 1899 | | |
1900 | 1900 | | |
| |||
3058 | 3058 | | |
3059 | 3059 | | |
3060 | 3060 | | |
3061 | | - | |
| 3061 | + | |
3062 | 3062 | | |
3063 | 3063 | | |
3064 | 3064 | | |
| |||
3277 | 3277 | | |
3278 | 3278 | | |
3279 | 3279 | | |
3280 | | - | |
| 3280 | + | |
3281 | 3281 | | |
3282 | | - | |
3283 | | - | |
3284 | | - | |
| 3282 | + | |
3285 | 3283 | | |
3286 | 3284 | | |
3287 | 3285 | | |
| |||
3306 | 3304 | | |
3307 | 3305 | | |
3308 | 3306 | | |
3309 | | - | |
| 3307 | + | |
3310 | 3308 | | |
3311 | 3309 | | |
3312 | 3310 | | |
| |||
3330 | 3328 | | |
3331 | 3329 | | |
3332 | 3330 | | |
3333 | | - | |
| 3331 | + | |
3334 | 3332 | | |
3335 | 3333 | | |
3336 | 3334 | | |
| |||
3398 | 3396 | | |
3399 | 3397 | | |
3400 | 3398 | | |
| 3399 | + | |
3401 | 3400 | | |
3402 | 3401 | | |
3403 | 3402 | | |
| |||
3412 | 3411 | | |
3413 | 3412 | | |
3414 | 3413 | | |
3415 | | - | |
| 3414 | + | |
3416 | 3415 | | |
3417 | 3416 | | |
3418 | 3417 | | |
| |||
0 commit comments