Skip to content

Commit 3f4ccb5

Browse files
committed
Merge branch 'cw/completion'
More command line completion (in contrib/) for recent additions. * cw/completion: completion: recognize more long-options completion: teach remote subcommands to complete options completion: teach replace to complete options completion: teach ls-remote to complete options completion: improve bash completion for git-add completion: add subcommand completion for rerere completion: teach submodule subcommands to complete options
2 parents cbf1860 + f483a0a commit 3f4ccb5

1 file changed

Lines changed: 118 additions & 21 deletions

File tree

contrib/completion/git-completion.bash

Lines changed: 118 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ _git_apply ()
936936
--apply --no-add --exclude=
937937
--ignore-whitespace --ignore-space-change
938938
--whitespace= --inaccurate-eof --verbose
939+
--recount --directory=
939940
"
940941
return
941942
esac
@@ -947,13 +948,17 @@ _git_add ()
947948
--*)
948949
__gitcomp "
949950
--interactive --refresh --patch --update --dry-run
950-
--ignore-errors --intent-to-add
951+
--ignore-errors --intent-to-add --force --edit --chmod=
951952
"
952953
return
953954
esac
954955

955-
# XXX should we check for --update and --all options ?
956-
__git_complete_index_file "--others --modified --directory --no-empty-directory"
956+
local complete_opt="--others --modified --directory --no-empty-directory"
957+
if test -n "$(__git_find_on_cmdline "-u --update")"
958+
then
959+
complete_opt="--modified"
960+
fi
961+
__git_complete_index_file "$complete_opt"
957962
}
958963

959964
_git_archive ()
@@ -970,7 +975,7 @@ _git_archive ()
970975
--*)
971976
__gitcomp "
972977
--format= --list --verbose
973-
--prefix= --remote= --exec=
978+
--prefix= --remote= --exec= --output
974979
"
975980
return
976981
;;
@@ -1025,6 +1030,7 @@ _git_branch ()
10251030
--track --no-track --contains --merged --no-merged
10261031
--set-upstream-to= --edit-description --list
10271032
--unset-upstream --delete --move --remotes
1033+
--column --no-column --sort= --points-at
10281034
"
10291035
;;
10301036
*)
@@ -1138,6 +1144,8 @@ _git_clone ()
11381144
--single-branch
11391145
--branch
11401146
--recurse-submodules
1147+
--no-single-branch
1148+
--shallow-submodules
11411149
"
11421150
return
11431151
;;
@@ -1179,6 +1187,7 @@ _git_commit ()
11791187
--reset-author --file= --message= --template=
11801188
--cleanup= --untracked-files --untracked-files=
11811189
--verbose --quiet --fixup= --squash=
1190+
--patch --short --date --allow-empty
11821191
"
11831192
return
11841193
esac
@@ -1197,7 +1206,7 @@ _git_describe ()
11971206
--*)
11981207
__gitcomp "
11991208
--all --tags --contains --abbrev= --candidates=
1200-
--exact-match --debug --long --match --always
1209+
--exact-match --debug --long --match --always --first-parent
12011210
"
12021211
return
12031212
esac
@@ -1280,6 +1289,7 @@ __git_fetch_recurse_submodules="yes on-demand no"
12801289
__git_fetch_options="
12811290
--quiet --verbose --append --upload-pack --force --keep --depth=
12821291
--tags --no-tags --all --prune --dry-run --recurse-submodules=
1292+
--unshallow --update-shallow
12831293
"
12841294

12851295
_git_fetch ()
@@ -1329,7 +1339,7 @@ _git_fsck ()
13291339
--*)
13301340
__gitcomp "
13311341
--tags --root --unreachable --cache --no-reflogs --full
1332-
--strict --verbose --lost-found
1342+
--strict --verbose --lost-found --name-objects
13331343
"
13341344
return
13351345
;;
@@ -1373,6 +1383,8 @@ _git_grep ()
13731383
--max-depth
13741384
--count
13751385
--and --or --not --all-match
1386+
--break --heading --show-function --function-context
1387+
--untracked --no-index
13761388
"
13771389
return
13781390
;;
@@ -1445,6 +1457,12 @@ _git_ls_files ()
14451457

14461458
_git_ls_remote ()
14471459
{
1460+
case "$cur" in
1461+
--*)
1462+
__gitcomp "--heads --tags --refs --get-url --symref"
1463+
return
1464+
;;
1465+
esac
14481466
__gitcomp_nl "$(__git_remotes)"
14491467
}
14501468

@@ -1566,7 +1584,7 @@ _git_mergetool ()
15661584
return
15671585
;;
15681586
--*)
1569-
__gitcomp "--tool="
1587+
__gitcomp "--tool= --prompt --no-prompt"
15701588
return
15711589
;;
15721590
esac
@@ -2374,40 +2392,88 @@ _git_config ()
23742392

23752393
_git_remote ()
23762394
{
2377-
local subcommands="add rename remove set-head set-branches set-url show prune update"
2395+
local subcommands="
2396+
add rename remove set-head set-branches
2397+
get-url set-url show prune update
2398+
"
23782399
local subcommand="$(__git_find_on_cmdline "$subcommands")"
23792400
if [ -z "$subcommand" ]; then
2380-
__gitcomp "$subcommands"
2401+
case "$cur" in
2402+
--*)
2403+
__gitcomp "--verbose"
2404+
;;
2405+
*)
2406+
__gitcomp "$subcommands"
2407+
;;
2408+
esac
23812409
return
23822410
fi
23832411

2384-
case "$subcommand" in
2385-
rename|remove|set-url|show|prune)
2386-
__gitcomp_nl "$(__git_remotes)"
2412+
case "$subcommand,$cur" in
2413+
add,--*)
2414+
__gitcomp "--track --master --fetch --tags --no-tags --mirror="
2415+
;;
2416+
add,*)
2417+
;;
2418+
set-head,--*)
2419+
__gitcomp "--auto --delete"
2420+
;;
2421+
set-branches,--*)
2422+
__gitcomp "--add"
23872423
;;
2388-
set-head|set-branches)
2424+
set-head,*|set-branches,*)
23892425
__git_complete_remote_or_refspec
23902426
;;
2391-
update)
2427+
update,--*)
2428+
__gitcomp "--prune"
2429+
;;
2430+
update,*)
23922431
__gitcomp "$(__git_get_config_variables "remotes")"
23932432
;;
2433+
set-url,--*)
2434+
__gitcomp "--push --add --delete"
2435+
;;
2436+
get-url,--*)
2437+
__gitcomp "--push --all"
2438+
;;
2439+
prune,--*)
2440+
__gitcomp "--dry-run"
2441+
;;
23942442
*)
2443+
__gitcomp_nl "$(__git_remotes)"
23952444
;;
23962445
esac
23972446
}
23982447

23992448
_git_replace ()
24002449
{
2450+
case "$cur" in
2451+
--*)
2452+
__gitcomp "--edit --graft --format= --list --delete"
2453+
return
2454+
;;
2455+
esac
24012456
__gitcomp_nl "$(__git_refs)"
24022457
}
24032458

2459+
_git_rerere ()
2460+
{
2461+
local subcommands="clear forget diff remaining status gc"
2462+
local subcommand="$(__git_find_on_cmdline "$subcommands")"
2463+
if test -z "$subcommand"
2464+
then
2465+
__gitcomp "$subcommands"
2466+
return
2467+
fi
2468+
}
2469+
24042470
_git_reset ()
24052471
{
24062472
__git_has_doubledash && return
24072473

24082474
case "$cur" in
24092475
--*)
2410-
__gitcomp "--merge --mixed --hard --soft --patch"
2476+
__gitcomp "--merge --mixed --hard --soft --patch --keep"
24112477
return
24122478
;;
24132479
esac
@@ -2423,7 +2489,10 @@ _git_revert ()
24232489
fi
24242490
case "$cur" in
24252491
--*)
2426-
__gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2492+
__gitcomp "
2493+
--edit --mainline --no-edit --no-commit --signoff
2494+
--strategy= --strategy-option=
2495+
"
24272496
return
24282497
;;
24292498
esac
@@ -2451,7 +2520,7 @@ _git_shortlog ()
24512520
__gitcomp "
24522521
$__git_log_common_options
24532522
$__git_log_shortlog_options
2454-
--numbered --summary
2523+
--numbered --summary --email
24552524
"
24562525
return
24572526
;;
@@ -2556,17 +2625,45 @@ _git_submodule ()
25562625
__git_has_doubledash && return
25572626

25582627
local subcommands="add status init deinit update summary foreach sync"
2559-
if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2628+
local subcommand="$(__git_find_on_cmdline "$subcommands")"
2629+
if [ -z "$subcommand" ]; then
25602630
case "$cur" in
25612631
--*)
2562-
__gitcomp "--quiet --cached"
2632+
__gitcomp "--quiet"
25632633
;;
25642634
*)
25652635
__gitcomp "$subcommands"
25662636
;;
25672637
esac
25682638
return
25692639
fi
2640+
2641+
case "$subcommand,$cur" in
2642+
add,--*)
2643+
__gitcomp "--branch --force --name --reference --depth"
2644+
;;
2645+
status,--*)
2646+
__gitcomp "--cached --recursive"
2647+
;;
2648+
deinit,--*)
2649+
__gitcomp "--force --all"
2650+
;;
2651+
update,--*)
2652+
__gitcomp "
2653+
--init --remote --no-fetch
2654+
--recommend-shallow --no-recommend-shallow
2655+
--force --rebase --merge --reference --depth --recursive --jobs
2656+
"
2657+
;;
2658+
summary,--*)
2659+
__gitcomp "--cached --files --summary-limit"
2660+
;;
2661+
foreach,--*|sync,--*)
2662+
__gitcomp "--recursive"
2663+
;;
2664+
*)
2665+
;;
2666+
esac
25702667
}
25712668

25722669
_git_svn ()
@@ -2701,8 +2798,8 @@ _git_tag ()
27012798
--*)
27022799
__gitcomp "
27032800
--list --delete --verify --annotate --message --file
2704-
--sign --cleanup --local-user --force --column --sort
2705-
--contains --points-at
2801+
--sign --cleanup --local-user --force --column --sort=
2802+
--contains --points-at --merged --no-merged --create-reflog
27062803
"
27072804
;;
27082805
esac

0 commit comments

Comments
 (0)