387
esac
388
}
389
390
+__git_complete_remote_or_refspec ()
391
+{
392
+ local cmd="${COMP_WORDS[1]}"
393
+ local cur="${COMP_WORDS[COMP_CWORD]}"
394
+ local i c=2 remote="" pfx="" lhs=1
395
+ while [ $c -lt $COMP_CWORD ]; do
396
+ i="${COMP_WORDS[c]}"
397
+ case "$i" in
398
+ -*) ;;
399
+ *) remote="$i"; break ;;
400
+ esac
401
+ c=$((++c))
402
+ done
403
+ if [ -z "$remote" ]; then
404
+ __gitcomp "$(__git_remotes)"
405
+ return
406
+ fi
407
+ [ "$remote" = "." ] && remote=
408
+ case "$cur" in
409
+ *:*)
410
+ case "$COMP_WORDBREAKS" in
411
+ *:*) : great ;;
412
+ *) pfx="${cur%%:*}:" ;;
413
+ esac
414
+ cur="${cur#*:}"
415
+ lhs=0
416
+ ;;
417
+ +*)
418
+ pfx="+"
419
+ cur="${cur#+}"
420
+ ;;
421
+ esac
422
+ case "$cmd" in
423
+ fetch)
424
+ if [ $lhs = 1 ]; then
425
+ __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
426
+ else
427
+ __gitcomp "$(__git_refs)" "$pfx" "$cur"
428
+ fi
429
+ ;;
430
+ pull)
431
+ if [ $lhs = 1 ]; then
432
+ __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
433
+ else
434
+ __gitcomp "$(__git_refs)" "$pfx" "$cur"
435
+ fi
436
+ ;;
437
+ push)
438
+ if [ $lhs = 1 ]; then
439
+ __gitcomp "$(__git_refs)" "$pfx" "$cur"
440
+ else
441
+ __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
442
+ fi
443
+ ;;
444
+ esac
445
+}
446
+
447
__git_all_commands ()
448
{
449
if [ -n "${__git_all_commandlist-}" ]; then
889
890
_git_fetch ()
891
{
835
- local cur="${COMP_WORDS[COMP_CWORD]}"
836
-
837
- if [ "$COMP_CWORD" = 2 ]; then
838
- __gitcomp "$(__git_remotes)"
839
- else
840
- case "$cur" in
841
- *:*)
842
- local pfx=""
843
- case "$COMP_WORDBREAKS" in
844
- *:*) : great ;;
845
- *) pfx="${cur%%:*}:" ;;
846
- esac
847
- __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
848
- ;;
849
- *)
850
- __gitcomp "$(__git_refs2 "${COMP_WORDS[2]}")"
851
- ;;
852
- esac
853
- fi
892
+ __git_complete_remote_or_refspec
893
}
894
895
_git_format_patch ()
1159
1160
_git_pull ()
1161
{
1123
- local cur="${COMP_WORDS[COMP_CWORD]}"
1124
-
1125
- if [ "$COMP_CWORD" = 2 ]; then
1126
- __gitcomp "$(__git_remotes)"
1127
- else
1128
- __gitcomp "$(__git_refs "${COMP_WORDS[2]}")"
1129
- fi
1162
+ __git_complete_remote_or_refspec
1163
}
1164
1165
_git_push ()
1166
{
1134
- local cur="${COMP_WORDS[COMP_CWORD]}"
1135
-
1136
- if [ "$COMP_CWORD" = 2 ]; then
1137
- __gitcomp "$(__git_remotes)"
1138
- else
1139
- case "$cur" in
1140
- *:*)
1141
- local pfx=""
1142
- case "$COMP_WORDBREAKS" in
1143
- *:*) : great ;;
1144
- *) pfx="${cur%%:*}:" ;;
1145
- esac
1146
-
1147
- __gitcomp "$(__git_refs "${COMP_WORDS[2]}")" "$pfx" "${cur#*:}"
1148
- ;;
1149
- +*)
1150
- __gitcomp "$(__git_refs)" + "${cur#+}"
1151
- ;;
1152
- *)
1153
- __gitcomp "$(__git_refs)"
1154
- ;;
1155
- esac
1156
- fi
1167
+ __git_complete_remote_or_refspec
1168
}
1169
1170
_git_rebase ()