489
# generates completion reply with compgen
490
__gitcomp ()
491
{
492
- local cur
493
- _get_comp_words_by_ref -n =: cur
492
local cur_="$cur"
493
494
if [ $# -gt 2 ]; then
551
__git_refs ()
552
{
553
local i is_hash=y dir="$(__gitdir "${1-}")" track="${2-}"
556
- local cur format refs
557
- _get_comp_words_by_ref -n =: cur
554
+ local format refs
555
if [ -d "$dir" ]; then
556
case "$cur" in
557
refs|refs/*)
665
666
__git_complete_revlist_file ()
667
{
671
- local pfx ls ref cur
672
- _get_comp_words_by_ref -n =: cur
673
- local cur_="$cur"
668
+ local pfx ls ref cur_="$cur"
669
case "$cur_" in
670
*..?*:*)
671
return
737
738
__git_complete_remote_or_refspec ()
739
{
745
- local cur words cword
746
- _get_comp_words_by_ref -n =: cur words cword
740
local cur_="$cur" cmd="${words[1]}"
741
local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
742
while [ $c -lt $cword ]; do
808
809
__git_complete_strategy ()
810
{
818
- local cur prev
819
- _get_comp_words_by_ref -n =: cur prev
811
__git_compute_merge_strategies
812
case "$prev" in
813
-s|--strategy)
985
# __git_find_on_cmdline requires 1 argument
986
__git_find_on_cmdline ()
987
{
997
- local word subcommand c=1 words cword
998
- _get_comp_words_by_ref -n =: words cword
988
+ local word subcommand c=1
989
while [ $c -lt $cword ]; do
990
word="${words[c]}"
991
for subcommand in $1; do
1000
1001
__git_has_doubledash ()
1002
{
1013
- local c=1 words cword
1014
- _get_comp_words_by_ref -n =: words cword
1003
+ local c=1
1004
while [ $c -lt $cword ]; do
1005
if [ "--" = "${words[c]}" ]; then
1006
return 0
1014
1015
_git_am ()
1016
{
1028
- local cur dir="$(__gitdir)"
1029
- _get_comp_words_by_ref -n =: cur
1017
+ local dir="$(__gitdir)"
1018
if [ -d "$dir"/rebase-apply ]; then
1019
__gitcomp "--skip --continue --resolved --abort"
1020
return
1038
1039
_git_apply ()
1040
{
1053
- local cur
1054
- _get_comp_words_by_ref -n =: cur
1041
case "$cur" in
1042
--whitespace=*)
1043
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1060
{
1061
__git_has_doubledash && return
1062
1077
- local cur
1078
- _get_comp_words_by_ref -n =: cur
1063
case "$cur" in
1064
--*)
1065
__gitcomp "
1073
1074
_git_archive ()
1075
{
1092
- local cur
1093
- _get_comp_words_by_ref -n =: cur
1076
case "$cur" in
1077
--format=*)
1078
__gitcomp "$(git archive --list)" "" "${cur##--format=}"
1120
1121
_git_branch ()
1122
{
1141
- local i c=1 only_local_ref="n" has_r="n" cur words cword
1123
+ local i c=1 only_local_ref="n" has_r="n"
1124
1143
- _get_comp_words_by_ref -n =: cur words cword
1125
while [ $c -lt $cword ]; do
1126
i="${words[c]}"
1127
case "$i" in
1151
1152
_git_bundle ()
1153
{
1173
- local words cword
1174
- _get_comp_words_by_ref -n =: words cword
1154
local cmd="${words[2]}"
1155
case "$cword" in
1156
2)
1173
{
1174
__git_has_doubledash && return
1175
1197
- local cur
1198
- _get_comp_words_by_ref -n =: cur
1176
case "$cur" in
1177
--conflict=*)
1178
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
1202
1203
_git_cherry_pick ()
1204
{
1228
- local cur
1229
- _get_comp_words_by_ref -n =: cur
1205
case "$cur" in
1206
--*)
1207
__gitcomp "--edit --no-commit"
1216
{
1217
__git_has_doubledash && return
1218
1244
- local cur
1245
- _get_comp_words_by_ref -n =: cur
1219
case "$cur" in
1220
--*)
1221
__gitcomp "--dry-run --quiet"
1227
1228
_git_clone ()
1229
{
1257
- local cur
1258
- _get_comp_words_by_ref -n =: cur
1230
case "$cur" in
1231
--*)
1232
__gitcomp "
1253
{
1254
__git_has_doubledash && return
1255
1285
- local cur
1286
- _get_comp_words_by_ref -n =: cur
1256
case "$cur" in
1257
--cleanup=*)
1258
__gitcomp "default strip verbatim whitespace
1287
1288
_git_describe ()
1289
{
1321
- local cur
1322
- _get_comp_words_by_ref -n =: cur
1290
case "$cur" in
1291
--*)
1292
__gitcomp "
1318
{
1319
__git_has_doubledash && return
1320
1354
- local cur
1355
- _get_comp_words_by_ref -n =: cur
1321
case "$cur" in
1322
--*)
1323
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1338
{
1339
__git_has_doubledash && return
1340
1376
- local cur
1377
- _get_comp_words_by_ref -n =: cur
1341
case "$cur" in
1342
--tool=*)
1343
__gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1362
1363
_git_fetch ()
1364
{
1402
- local cur
1403
- _get_comp_words_by_ref -n =: cur
1365
case "$cur" in
1366
--*)
1367
__gitcomp "$__git_fetch_options"
1373
1374
_git_format_patch ()
1375
{
1415
- local cur
1416
- _get_comp_words_by_ref -n =: cur
1376
case "$cur" in
1377
--thread=*)
1378
__gitcomp "
1404
1405
_git_fsck ()
1406
{
1448
- local cur
1449
- _get_comp_words_by_ref -n =: cur
1407
case "$cur" in
1408
--*)
1409
__gitcomp "
1418
1419
_git_gc ()
1420
{
1464
- local cur
1465
- _get_comp_words_by_ref -n =: cur
1421
case "$cur" in
1422
--*)
1423
__gitcomp "--prune --aggressive"
1436
{
1437
__git_has_doubledash && return
1438
1484
- local cur
1485
- _get_comp_words_by_ref -n =: cur
1439
case "$cur" in
1440
--*)
1441
__gitcomp "
1458
1459
_git_help ()
1460
{
1508
- local cur
1509
- _get_comp_words_by_ref -n =: cur
1461
case "$cur" in
1462
--*)
1463
__gitcomp "--all --info --man --web"
1475
1476
_git_init ()
1477
{
1527
- local cur
1528
- _get_comp_words_by_ref -n =: cur
1478
case "$cur" in
1479
--shared=*)
1480
__gitcomp "
1494
{
1495
__git_has_doubledash && return
1496
1548
- local cur
1549
- _get_comp_words_by_ref -n =: cur
1497
case "$cur" in
1498
--*)
1499
__gitcomp "--cached --deleted --modified --others --ignored
1554
if [ -f "$g/MERGE_HEAD" ]; then
1555
merge="--merge"
1556
fi
1610
- local cur
1611
- _get_comp_words_by_ref -n =: cur
1557
case "$cur" in
1558
--pretty=*)
1559
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1607
{
1608
__git_complete_strategy && return
1609
1665
- local cur
1666
- _get_comp_words_by_ref -n =: cur
1610
case "$cur" in
1611
--*)
1612
__gitcomp "$__git_merge_options"
1617
1618
_git_mergetool ()
1619
{
1677
- local cur
1678
- _get_comp_words_by_ref -n =: cur
1620
case "$cur" in
1621
--tool=*)
1622
__gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1637
1638
_git_mv ()
1639
{
1699
- local cur
1700
- _get_comp_words_by_ref -n =: cur
1640
case "$cur" in
1641
--*)
1642
__gitcomp "--dry-run"
1655
{
1656
local subcommands='add append copy edit list prune remove show'
1657
local subcommand="$(__git_find_on_cmdline "$subcommands")"
1719
- local cur words cword
1720
- _get_comp_words_by_ref -n =: cur words cword
1658
1659
case "$subcommand,$cur" in
1660
,--*)
1704
{
1705
__git_complete_strategy && return
1706
1770
- local cur
1771
- _get_comp_words_by_ref -n =: cur
1707
case "$cur" in
1708
--*)
1709
__gitcomp "
1719
1720
_git_push ()
1721
{
1787
- local cur prev
1788
- _get_comp_words_by_ref -n =: cur prev
1722
case "$prev" in
1723
--repo)
1724
__gitcomp "$(__git_remotes)"
1743
_git_rebase ()
1744
{
1745
local dir="$(__gitdir)"
1813
- local cur
1814
- _get_comp_words_by_ref -n =: cur
1746
if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1747
__gitcomp "--continue --skip --abort"
1748
return
1784
1785
_git_send_email ()
1786
{
1856
- local cur
1857
- _get_comp_words_by_ref -n =: cur
1787
case "$cur" in
1788
--confirm=*)
1789
__gitcomp "
1825
1826
__git_config_get_set_variables ()
1827
{
1899
- local words cword
1900
- _get_comp_words_by_ref -n =: words cword
1828
local prevword word config_file= c=$cword
1829
while [ $c -gt 1 ]; do
1830
word="${words[c]}"
1855
1856
_git_config ()
1857
{
1931
- local cur prev
1932
- _get_comp_words_by_ref -n =: cur prev
1858
case "$prev" in
1859
branch.*.remote)
1860
__gitcomp "$(__git_remotes)"
2314
{
2315
__git_has_doubledash && return
2316
2392
- local cur
2393
- _get_comp_words_by_ref -n =: cur
2317
case "$cur" in
2318
--*)
2319
__gitcomp "--merge --mixed --hard --soft --patch"
2325
2326
_git_revert ()
2327
{
2405
- local cur
2406
- _get_comp_words_by_ref -n =: cur
2328
case "$cur" in
2329
--*)
2330
__gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2338
{
2339
__git_has_doubledash && return
2340
2420
- local cur
2421
- _get_comp_words_by_ref -n =: cur
2341
case "$cur" in
2342
--*)
2343
__gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2351
{
2352
__git_has_doubledash && return
2353
2435
- local cur
2436
- _get_comp_words_by_ref -n =: cur
2354
case "$cur" in
2355
--*)
2356
__gitcomp "
2368
{
2369
__git_has_doubledash && return
2370
2454
- local cur
2455
- _get_comp_words_by_ref -n =: cur
2371
case "$cur" in
2372
--pretty=*)
2373
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2391
2392
_git_show_branch ()
2393
{
2479
- local cur
2480
- _get_comp_words_by_ref -n =: cur
2394
case "$cur" in
2395
--*)
2396
__gitcomp "
2407
2408
_git_stash ()
2409
{
2497
- local cur
2498
- _get_comp_words_by_ref -n =: cur
2410
local save_opts='--keep-index --no-keep-index --quiet --patch'
2411
local subcommands='save list show apply clear drop pop create branch'
2412
local subcommand="$(__git_find_on_cmdline "$subcommands")"
2451
2452
local subcommands="add status init update summary foreach sync"
2453
if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2543
- local cur
2544
- _get_comp_words_by_ref -n =: cur
2454
case "$cur" in
2455
--*)
2456
__gitcomp "--quiet --cached"
2494
--edit --rmdir --find-copies-harder --copy-similarity=
2495
"
2496
2588
- local cur
2589
- _get_comp_words_by_ref -n =: cur
2497
case "$subcommand,$cur" in
2498
fetch,--*)
2499
__gitcomp "--revision= --fetch-all $fc_opts"
2565
_git_tag ()
2566
{
2567
local i c=1 f=0
2661
- local words cword prev
2662
- _get_comp_words_by_ref -n =: words cword prev
2568
while [ $c -lt $cword ]; do
2569
i="${words[c]}"
2570
case "$i" in
2610
setopt KSH_TYPESET
2611
fi
2612
2708
- local cur words cword
2709
- _get_comp_words_by_ref -n =: cur words cword
2613
+ local cur words cword prev
2614
+ _get_comp_words_by_ref -n =: cur words cword prev
2615
while [ $c -lt $cword ]; do
2616
i="${words[c]}"
2617
case "$i" in
2661
setopt KSH_TYPESET
2662
fi
2663
2664
+ local cur words cword prev
2665
+ _get_comp_words_by_ref -n =: cur words cword prev
2666
+
2667
__git_has_doubledash && return
2668
2761
- local cur
2669
local g="$(__gitdir)"
2670
local merge=""
2671
if [ -f "$g/MERGE_HEAD" ]; then
2672
merge="--merge"
2673
fi
2767
- _get_comp_words_by_ref -n =: cur
2674
case "$cur" in
2675
--*)
2676
__gitcomp "