749
# Usage: __git_complete_refs [<option>]...
750
# --remote=<remote>: The remote to list refs from, can be the name of a
751
# configured remote, a path, or a URL.
752
-# --track: List unique remote branches for 'git checkout's tracking DWIMery.
752
+# --dwim: List unique remote branches for 'git switch's tracking DWIMery.
753
# --pfx=<prefix>: A prefix to be added to each ref.
754
# --cur=<word>: The current ref to be completed. Defaults to the current
755
# word to be completed.
757
# space.
758
__git_complete_refs ()
759
{
760
- local remote track pfx cur_="$cur" sfx=" "
760
+ local remote dwim pfx cur_="$cur" sfx=" "
761
762
while test $# != 0; do
763
case "$1" in
764
--remote=*) remote="${1##--remote=}" ;;
765
- --track) track="yes" ;;
765
+ --dwim) dwim="yes" ;;
766
+ # --track is an old spelling of --dwim
767
+ --track) dwim="yes" ;;
768
--pfx=*) pfx="${1##--pfx=}" ;;
769
--cur=*) cur_="${1##--cur=}" ;;
770
--sfx=*) sfx="${1##--sfx=}" ;;
773
shift
774
done
775
774
- __gitcomp_direct "$(__git_refs "$remote" "$track" "$pfx" "$cur_" "$sfx")"
776
+ __gitcomp_direct "$(__git_refs "$remote" "$dwim" "$pfx" "$cur_" "$sfx")"
777
}
778
779
# __git_refs2 requires 1 argument (to pass to __git_refs)
1372
*)
1373
# check if --track, --no-track, or --no-guess was specified
1374
# if so, disable DWIM mode
1373
- local flags="--track --no-track --no-guess" track_opt="--track"
1375
+ local flags="--track --no-track --no-guess" dwim_opt="--dwim"
1376
if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] ||
1377
[ -n "$(__git_find_on_cmdline "$flags")" ]; then
1376
- track_opt=''
1378
+ dwim_opt=''
1379
fi
1378
- __git_complete_refs $track_opt
1380
+ __git_complete_refs $dwim_opt
1381
;;
1382
esac
1383
}
2227
*)
2228
# check if --track, --no-track, or --no-guess was specified
2229
# if so, disable DWIM mode
2228
- local track_opt="--track" only_local_ref=n
2230
+ local dwim_opt="--dwim" only_local_ref=n
2231
if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] ||
2232
[ -n "$(__git_find_on_cmdline "--track --no-track --no-guess")" ]; then
2231
- track_opt=''
2233
+ dwim_opt=''
2234
fi
2235
# explicit --guess enables DWIM mode regardless of
2236
# $GIT_COMPLETION_CHECKOUT_NO_GUESS
2237
if [ -n "$(__git_find_on_cmdline "--guess")" ]; then
2236
- track_opt='--track'
2238
+ dwim_opt='--dwim'
2239
fi
2240
if [ -z "$(__git_find_on_cmdline "-d --detach")" ]; then
2241
only_local_ref=y
2242
else
2243
# --guess --detach is invalid combination, no
2244
# dwim will be done when --detach is specified
2243
- track_opt=
2245
+ dwim_opt=
2246
fi
2245
- if [ $only_local_ref = y -a -z "$track_opt" ]; then
2247
+ if [ $only_local_ref = y -a -z "$dwim_opt" ]; then
2248
__gitcomp_direct "$(__git_heads "" "$cur" " ")"
2249
else
2248
- __git_complete_refs $track_opt
2250
+ __git_complete_refs $dwim_opt
2251
fi
2252
;;
2253
esac