completion: fix bugs with slashes in remote names
Previously, some calls to for-each-ref passed fixed numbers of path components to strip from refs, assuming that remote names had no slashes in them. This made completions like: git push github/dseomn :com<Tab> Result in: git push github/dseomn :dseomn/completion-remote-slash With this patch, it instead results in: git push github/dseomn :completion-remote-slash Signed-off-by: David Mandelberg <david@mandelberg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Mandelberg committed
Mar 23, 2025 at 17:06 UTC
778d2f1760bf5411ab15657bdaf0ecf19352c502
2 files changed
+189
-29
contrib/completion/git-completion.bash
+31
-7
@@ -790,16 +790,39 @@ __git_tags ()
790
__git_dwim_remote_heads ()
791
{
792
local pfx="${1-}" cur_="${2-}" sfx="${3-}"
793
- local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
793
794
# employ the heuristic used by git checkout and git switch
795
# Try to find a remote branch that cur_es the completion word
796
# but only output if the branch name is unique
798
- __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
799
- --sort="refname:strip=3" \
800
- ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \
801
- "refs/remotes/*/$cur_*" "refs/remotes/*/$cur_*/**" | \
802
- uniq -u
797
+ local awk_script='
798
+ function casemap(s) {
799
+ if (ENVIRON["IGNORE_CASE"])
800
+ return tolower(s)
801
+ else
802
+ return s
803
+ }
804
+ BEGIN {
805
+ split(ENVIRON["REMOTES"], remotes, /\n/)
806
+ for (i in remotes)
807
+ remotes[i] = "refs/remotes/" casemap(remotes[i])
808
+ cur_ = casemap(ENVIRON["CUR_"])
809
+ }
810
+ {
811
+ ref_case = casemap($0)
812
+ for (i in remotes) {
813
+ if (index(ref_case, remotes[i] "/" cur_) == 1) {
814
+ branch = substr($0, length(remotes[i] "/") + 1)
815
+ print ENVIRON["PFX"] branch ENVIRON["SFX"]
816
+ break
817
+ }
818
+ }
819
+ }
820
+ '
821
+ __git for-each-ref --format='%(refname)' refs/remotes/ |
822
+ PFX="$pfx" SFX="$sfx" CUR_="$cur_" \
823
+ IGNORE_CASE=${GIT_COMPLETION_IGNORE_CASE+1} \
824
+ REMOTES="$(__git_remotes | sort -r)" awk "$awk_script" |
825
+ sort | uniq -u
826
}
827
828
# Lists refs from the local (by default) or from a remote repository.
@@ -905,7 +928,8 @@ __git_refs ()
928
case "HEAD" in
929
$match*|$umatch*) echo "${pfx}HEAD$sfx" ;;
930
esac
908
- __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
931
+ local strip="$(__git_count_path_components "refs/remotes/$remote")"
932
+ __git for-each-ref --format="$fer_pfx%(refname:strip=$strip)$sfx" \
933
${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \
934
"refs/remotes/$remote/$match*" \
935
"refs/remotes/$remote/$match*/**"
t/t9902-completion.sh
+158
-22
@@ -149,7 +149,8 @@ fi
149
test_expect_success 'setup for __git_find_repo_path/__gitdir tests' '
150
mkdir -p subdir/subsubdir &&
151
mkdir -p non-repo &&
152
- git init -b main otherrepo
152
+ git init -b main otherrepo &&
153
+ git init -b main slashrepo
154
'
155
156
test_expect_success '__git_find_repo_path - from command line (through $__git_dir)' '
@@ -674,6 +675,13 @@ test_expect_success 'setup for ref completion' '
675
) &&
676
git remote add other "$ROOT/otherrepo/.git" &&
677
git fetch --no-tags other &&
678
+ (
679
+ cd slashrepo &&
680
+ git commit --allow-empty -m initial &&
681
+ git branch -m main branch/with/slash
682
+ ) &&
683
+ git remote add remote/with/slash "$ROOT/slashrepo/.git" &&
684
+ git fetch --no-tags remote/with/slash &&
685
rm -f .git/FETCH_HEAD &&
686
git init thirdrepo
687
'
@@ -686,6 +694,8 @@ test_expect_success '__git_refs - simple' '
694
other/HEAD
695
other/branch-in-other
696
other/main-in-other
697
+ remote/with/slash/HEAD
698
+ remote/with/slash/branch/with/slash
699
matching-tag
700
EOF
701
(
@@ -702,6 +712,8 @@ test_expect_success '__git_refs - full refs' '
712
refs/remotes/other/HEAD
713
refs/remotes/other/branch-in-other
714
refs/remotes/other/main-in-other
715
+ refs/remotes/remote/with/slash/HEAD
716
+ refs/remotes/remote/with/slash/branch/with/slash
717
refs/tags/matching-tag
718
EOF
719
(
@@ -767,6 +779,19 @@ test_expect_success '__git_refs - configured remote' '
779
test_cmp expected "$actual"
780
'
781
782
+test_expect_success '__git_refs - configured remote - with slash' '
783
+ cat >expected <<-EOF &&
784
+ HEAD
785
+ HEAD
786
+ branch/with/slash
787
+ EOF
788
+ (
789
+ cur= &&
790
+ __git_refs remote/with/slash >"$actual"
791
+ ) &&
792
+ test_cmp expected "$actual"
793
+'
794
+
795
test_expect_success '__git_refs - configured remote - full refs' '
796
cat >expected <<-EOF &&
797
HEAD
@@ -909,17 +934,19 @@ test_expect_success '__git_refs - unique remote branches for git checkout DWIMer
934
other/ambiguous
935
other/branch-in-other
936
other/main-in-other
912
- remote/ambiguous
913
- remote/branch-in-remote
937
+ remote/with/slash/HEAD
938
+ remote/with/slash/ambiguous
939
+ remote/with/slash/branch-in-remote
940
+ remote/with/slash/branch/with/slash
941
matching-tag
915
- HEAD
942
branch-in-other
943
branch-in-remote
944
+ branch/with/slash
945
main-in-other
946
EOF
947
for remote_ref in refs/remotes/other/ambiguous \
921
- refs/remotes/remote/ambiguous \
922
- refs/remotes/remote/branch-in-remote
948
+ refs/remotes/remote/with/slash/ambiguous \
949
+ refs/remotes/remote/with/slash/branch-in-remote
950
do
951
git update-ref $remote_ref main &&
952
test_when_finished "git update-ref -d $remote_ref" || return 1
@@ -939,6 +966,8 @@ test_expect_success '__git_refs - after --opt=' '
966
other/HEAD
967
other/branch-in-other
968
other/main-in-other
969
+ remote/with/slash/HEAD
970
+ remote/with/slash/branch/with/slash
971
matching-tag
972
EOF
973
(
@@ -955,6 +984,8 @@ test_expect_success '__git_refs - after --opt= - full refs' '
984
refs/remotes/other/HEAD
985
refs/remotes/other/branch-in-other
986
refs/remotes/other/main-in-other
987
+ refs/remotes/remote/with/slash/HEAD
988
+ refs/remotes/remote/with/slash/branch/with/slash
989
refs/tags/matching-tag
990
EOF
991
(
@@ -972,6 +1003,8 @@ test_expect_success '__git refs - excluding refs' '
1003
^other/HEAD
1004
^other/branch-in-other
1005
^other/main-in-other
1006
+ ^remote/with/slash/HEAD
1007
+ ^remote/with/slash/branch/with/slash
1008
^matching-tag
1009
EOF
1010
(
@@ -988,6 +1021,8 @@ test_expect_success '__git refs - excluding full refs' '
1021
^refs/remotes/other/HEAD
1022
^refs/remotes/other/branch-in-other
1023
^refs/remotes/other/main-in-other
1024
+ ^refs/remotes/remote/with/slash/HEAD
1025
+ ^refs/remotes/remote/with/slash/branch/with/slash
1026
^refs/tags/matching-tag
1027
EOF
1028
(
@@ -1015,6 +1050,8 @@ test_expect_success '__git_refs - do not filter refs unless told so' '
1050
other/branch-in-other
1051
other/main-in-other
1052
other/matching/branch-in-other
1053
+ remote/with/slash/HEAD
1054
+ remote/with/slash/branch/with/slash
1055
matching-tag
1056
matching/tag
1057
EOF
@@ -1135,6 +1172,8 @@ test_expect_success '__git_complete_refs - simple' '
1172
other/HEAD Z
1173
other/branch-in-other Z
1174
other/main-in-other Z
1175
+ remote/with/slash/HEAD Z
1176
+ remote/with/slash/branch/with/slash Z
1177
matching-tag Z
1178
EOF
1179
(
@@ -1173,6 +1212,20 @@ test_expect_success '__git_complete_refs - remote' '
1212
test_cmp expected out
1213
'
1214
1215
+test_expect_success '__git_complete_refs - remote - with slash' '
1216
+ sed -e "s/Z$//" >expected <<-EOF &&
1217
+ HEAD Z
1218
+ HEAD Z
1219
+ branch/with/slash Z
1220
+ EOF
1221
+ (
1222
+ cur= &&
1223
+ __git_complete_refs --remote=remote/with/slash &&
1224
+ print_comp
1225
+ ) &&
1226
+ test_cmp expected out
1227
+'
1228
+
1229
test_expect_success '__git_complete_refs - track' '
1230
sed -e "s/Z$//" >expected <<-EOF &&
1231
HEAD Z
@@ -1181,9 +1234,11 @@ test_expect_success '__git_complete_refs - track' '
1234
other/HEAD Z
1235
other/branch-in-other Z
1236
other/main-in-other Z
1237
+ remote/with/slash/HEAD Z
1238
+ remote/with/slash/branch/with/slash Z
1239
matching-tag Z
1185
- HEAD Z
1240
branch-in-other Z
1241
+ branch/with/slash Z
1242
main-in-other Z
1243
EOF
1244
(
@@ -1228,6 +1283,8 @@ test_expect_success '__git_complete_refs - suffix' '
1283
other/HEAD.
1284
other/branch-in-other.
1285
other/main-in-other.
1286
+ remote/with/slash/HEAD.
1287
+ remote/with/slash/branch/with/slash.
1288
matching-tag.
1289
EOF
1290
(
@@ -1253,6 +1310,20 @@ test_expect_success '__git_complete_fetch_refspecs - simple' '
1310
test_cmp expected out
1311
'
1312
1313
+test_expect_success '__git_complete_fetch_refspecs - with slash' '
1314
+ sed -e "s/Z$//" >expected <<-EOF &&
1315
+ HEAD:HEAD Z
1316
+ HEAD:HEAD Z
1317
+ branch/with/slash:branch/with/slash Z
1318
+ EOF
1319
+ (
1320
+ cur= &&
1321
+ __git_complete_fetch_refspecs remote/with/slash &&
1322
+ print_comp
1323
+ ) &&
1324
+ test_cmp expected out
1325
+'
1326
+
1327
test_expect_success '__git_complete_fetch_refspecs - matching' '
1328
sed -e "s/Z$//" >expected <<-EOF &&
1329
branch-in-other:branch-in-other Z
@@ -1333,8 +1404,8 @@ test_expect_success '__git_complete_worktree_paths with -C' '
1404
1405
test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' '
1406
test_completion "git switch " <<-\EOF
1336
- HEAD Z
1407
branch-in-other Z
1408
+ branch/with/slash Z
1409
main Z
1410
main-in-other Z
1411
matching-branch Z
@@ -1480,8 +1551,8 @@ test_expect_success 'git-bisect - existing view subcommand is recognized and ena
1551
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
1552
test_completion "git checkout " <<-\EOF
1553
HEAD Z
1483
- HEAD Z
1554
branch-in-other Z
1555
+ branch/with/slash Z
1556
main Z
1557
main-in-other Z
1558
matching-branch Z
@@ -1489,6 +1560,8 @@ test_expect_success 'git checkout - completes refs and unique remote branches fo
1560
other/HEAD Z
1561
other/branch-in-other Z
1562
other/main-in-other Z
1563
+ remote/with/slash/HEAD Z
1564
+ remote/with/slash/branch/with/slash Z
1565
EOF
1566
'
1567
@@ -1508,8 +1581,8 @@ test_expect_success 'git switch - with GIT_COMPLETION_CHECKOUT_NO_GUESS=1, compl
1581
1582
test_expect_success 'git switch - --guess overrides GIT_COMPLETION_CHECKOUT_NO_GUESS=1, complete local branches and unique remote names for DWIM logic' '
1583
GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git switch --guess " <<-\EOF
1511
- HEAD Z
1584
branch-in-other Z
1585
+ branch/with/slash Z
1586
main Z
1587
main-in-other Z
1588
matching-branch Z
@@ -1518,8 +1591,8 @@ test_expect_success 'git switch - --guess overrides GIT_COMPLETION_CHECKOUT_NO_G
1591
1592
test_expect_success 'git switch - a later --guess overrides previous --no-guess, complete local and remote unique branches for DWIM' '
1593
test_completion "git switch --no-guess --guess " <<-\EOF
1521
- HEAD Z
1594
branch-in-other Z
1595
+ branch/with/slash Z
1596
main Z
1597
main-in-other Z
1598
matching-branch Z
@@ -1542,14 +1615,16 @@ test_expect_success 'git checkout - with GIT_COMPLETION_NO_GUESS=1 only complete
1615
other/HEAD Z
1616
other/branch-in-other Z
1617
other/main-in-other Z
1618
+ remote/with/slash/HEAD Z
1619
+ remote/with/slash/branch/with/slash Z
1620
EOF
1621
'
1622
1623
test_expect_success 'git checkout - --guess overrides GIT_COMPLETION_NO_GUESS=1, complete refs and unique remote branches for DWIM' '
1624
GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git checkout --guess " <<-\EOF
1625
HEAD Z
1551
- HEAD Z
1626
branch-in-other Z
1627
+ branch/with/slash Z
1628
main Z
1629
main-in-other Z
1630
matching-branch Z
@@ -1557,6 +1632,8 @@ test_expect_success 'git checkout - --guess overrides GIT_COMPLETION_NO_GUESS=1,
1632
other/HEAD Z
1633
other/branch-in-other Z
1634
other/main-in-other Z
1635
+ remote/with/slash/HEAD Z
1636
+ remote/with/slash/branch/with/slash Z
1637
EOF
1638
'
1639
@@ -1569,14 +1646,16 @@ test_expect_success 'git checkout - with --no-guess, only completes refs' '
1646
other/HEAD Z
1647
other/branch-in-other Z
1648
other/main-in-other Z
1649
+ remote/with/slash/HEAD Z
1650
+ remote/with/slash/branch/with/slash Z
1651
EOF
1652
'
1653
1654
test_expect_success 'git checkout - a later --guess overrides previous --no-guess, complete refs and unique remote branches for DWIM' '
1655
test_completion "git checkout --no-guess --guess " <<-\EOF
1656
HEAD Z
1578
- HEAD Z
1657
branch-in-other Z
1658
+ branch/with/slash Z
1659
main Z
1660
main-in-other Z
1661
matching-branch Z
@@ -1584,6 +1663,8 @@ test_expect_success 'git checkout - a later --guess overrides previous --no-gues
1663
other/HEAD Z
1664
other/branch-in-other Z
1665
other/main-in-other Z
1666
+ remote/with/slash/HEAD Z
1667
+ remote/with/slash/branch/with/slash Z
1668
EOF
1669
'
1670
@@ -1596,6 +1677,8 @@ test_expect_success 'git checkout - a later --no-guess overrides previous --gues
1677
other/HEAD Z
1678
other/branch-in-other Z
1679
other/main-in-other Z
1680
+ remote/with/slash/HEAD Z
1681
+ remote/with/slash/branch/with/slash Z
1682
EOF
1683
'
1684
@@ -1609,6 +1692,8 @@ test_expect_success 'git checkout - with checkout.guess = false, only completes
1692
other/HEAD Z
1693
other/branch-in-other Z
1694
other/main-in-other Z
1695
+ remote/with/slash/HEAD Z
1696
+ remote/with/slash/branch/with/slash Z
1697
EOF
1698
'
1699
@@ -1616,8 +1701,8 @@ test_expect_success 'git checkout - with checkout.guess = true, completes refs a
1701
test_config checkout.guess true &&
1702
test_completion "git checkout " <<-\EOF
1703
HEAD Z
1619
- HEAD Z
1704
branch-in-other Z
1705
+ branch/with/slash Z
1706
main Z
1707
main-in-other Z
1708
matching-branch Z
@@ -1625,6 +1710,8 @@ test_expect_success 'git checkout - with checkout.guess = true, completes refs a
1710
other/HEAD Z
1711
other/branch-in-other Z
1712
other/main-in-other Z
1713
+ remote/with/slash/HEAD Z
1714
+ remote/with/slash/branch/with/slash Z
1715
EOF
1716
'
1717
@@ -1632,8 +1719,8 @@ test_expect_success 'git checkout - a later --guess overrides previous checkout.
1719
test_config checkout.guess false &&
1720
test_completion "git checkout --guess " <<-\EOF
1721
HEAD Z
1635
- HEAD Z
1722
branch-in-other Z
1723
+ branch/with/slash Z
1724
main Z
1725
main-in-other Z
1726
matching-branch Z
@@ -1641,6 +1728,8 @@ test_expect_success 'git checkout - a later --guess overrides previous checkout.
1728
other/HEAD Z
1729
other/branch-in-other Z
1730
other/main-in-other Z
1731
+ remote/with/slash/HEAD Z
1732
+ remote/with/slash/branch/with/slash Z
1733
EOF
1734
'
1735
@@ -1654,6 +1743,8 @@ test_expect_success 'git checkout - a later --no-guess overrides previous checko
1743
other/HEAD Z
1744
other/branch-in-other Z
1745
other/main-in-other Z
1746
+ remote/with/slash/HEAD Z
1747
+ remote/with/slash/branch/with/slash Z
1748
EOF
1749
'
1750
@@ -1666,6 +1757,8 @@ test_expect_success 'git switch - with --detach, complete all references' '
1757
other/HEAD Z
1758
other/branch-in-other Z
1759
other/main-in-other Z
1760
+ remote/with/slash/HEAD Z
1761
+ remote/with/slash/branch/with/slash Z
1762
EOF
1763
'
1764
@@ -1678,6 +1771,8 @@ test_expect_success 'git checkout - with --detach, complete only references' '
1771
other/HEAD Z
1772
other/branch-in-other Z
1773
other/main-in-other Z
1774
+ remote/with/slash/HEAD Z
1775
+ remote/with/slash/branch/with/slash Z
1776
EOF
1777
'
1778
@@ -1850,6 +1945,8 @@ test_expect_success 'git switch - with -d, complete all references' '
1945
other/HEAD Z
1946
other/branch-in-other Z
1947
other/main-in-other Z
1948
+ remote/with/slash/HEAD Z
1949
+ remote/with/slash/branch/with/slash Z
1950
EOF
1951
'
1952
@@ -1862,6 +1959,8 @@ test_expect_success 'git checkout - with -d, complete only references' '
1959
other/HEAD Z
1960
other/branch-in-other Z
1961
other/main-in-other Z
1962
+ remote/with/slash/HEAD Z
1963
+ remote/with/slash/branch/with/slash Z
1964
EOF
1965
'
1966
@@ -1870,11 +1969,15 @@ test_expect_success 'git switch - with --track, complete only remote branches' '
1969
other/HEAD Z
1970
other/branch-in-other Z
1971
other/main-in-other Z
1972
+ remote/with/slash/HEAD Z
1973
+ remote/with/slash/branch/with/slash Z
1974
EOF
1975
test_completion "git switch -t " <<-\EOF
1976
other/HEAD Z
1977
other/branch-in-other Z
1978
other/main-in-other Z
1979
+ remote/with/slash/HEAD Z
1980
+ remote/with/slash/branch/with/slash Z
1981
EOF
1982
'
1983
@@ -1883,11 +1986,15 @@ test_expect_success 'git checkout - with --track, complete only remote branches'
1986
other/HEAD Z
1987
other/branch-in-other Z
1988
other/main-in-other Z
1989
+ remote/with/slash/HEAD Z
1990
+ remote/with/slash/branch/with/slash Z
1991
EOF
1992
test_completion "git checkout -t " <<-\EOF
1993
other/HEAD Z
1994
other/branch-in-other Z
1995
other/main-in-other Z
1996
+ remote/with/slash/HEAD Z
1997
+ remote/with/slash/branch/with/slash Z
1998
EOF
1999
'
2000
@@ -1907,6 +2014,8 @@ test_expect_success 'git checkout - with --no-track, complete only local referen
2014
other/HEAD Z
2015
other/branch-in-other Z
2016
other/main-in-other Z
2017
+ remote/with/slash/HEAD Z
2018
+ remote/with/slash/branch/with/slash Z
2019
EOF
2020
'
2021
@@ -1919,6 +2028,8 @@ test_expect_success 'git switch - with -c, complete all references' '
2028
other/HEAD Z
2029
other/branch-in-other Z
2030
other/main-in-other Z
2031
+ remote/with/slash/HEAD Z
2032
+ remote/with/slash/branch/with/slash Z
2033
EOF
2034
'
2035
@@ -1931,6 +2042,8 @@ test_expect_success 'git switch - with -C, complete all references' '
2042
other/HEAD Z
2043
other/branch-in-other Z
2044
other/main-in-other Z
2045
+ remote/with/slash/HEAD Z
2046
+ remote/with/slash/branch/with/slash Z
2047
EOF
2048
'
2049
@@ -1943,6 +2056,8 @@ test_expect_success 'git switch - with -c and --track, complete all references'
2056
other/HEAD Z
2057
other/branch-in-other Z
2058
other/main-in-other Z
2059
+ remote/with/slash/HEAD Z
2060
+ remote/with/slash/branch/with/slash Z
2061
EOF
2062
'
2063
@@ -1955,6 +2070,8 @@ test_expect_success 'git switch - with -C and --track, complete all references'
2070
other/HEAD Z
2071
other/branch-in-other Z
2072
other/main-in-other Z
2073
+ remote/with/slash/HEAD Z
2074
+ remote/with/slash/branch/with/slash Z
2075
EOF
2076
'
2077
@@ -1967,6 +2084,8 @@ test_expect_success 'git switch - with -c and --no-track, complete all reference
2084
other/HEAD Z
2085
other/branch-in-other Z
2086
other/main-in-other Z
2087
+ remote/with/slash/HEAD Z
2088
+ remote/with/slash/branch/with/slash Z
2089
EOF
2090
'
2091
@@ -1979,6 +2098,8 @@ test_expect_success 'git switch - with -C and --no-track, complete all reference
2098
other/HEAD Z
2099
other/branch-in-other Z
2100
other/main-in-other Z
2101
+ remote/with/slash/HEAD Z
2102
+ remote/with/slash/branch/with/slash Z
2103
EOF
2104
'
2105
@@ -1991,6 +2112,8 @@ test_expect_success 'git checkout - with -b, complete all references' '
2112
other/HEAD Z
2113
other/branch-in-other Z
2114
other/main-in-other Z
2115
+ remote/with/slash/HEAD Z
2116
+ remote/with/slash/branch/with/slash Z
2117
EOF
2118
'
2119
@@ -2003,6 +2126,8 @@ test_expect_success 'git checkout - with -B, complete all references' '
2126
other/HEAD Z
2127
other/branch-in-other Z
2128
other/main-in-other Z
2129
+ remote/with/slash/HEAD Z
2130
+ remote/with/slash/branch/with/slash Z
2131
EOF
2132
'
2133
@@ -2015,6 +2140,8 @@ test_expect_success 'git checkout - with -b and --track, complete all references
2140
other/HEAD Z
2141
other/branch-in-other Z
2142
other/main-in-other Z
2143
+ remote/with/slash/HEAD Z
2144
+ remote/with/slash/branch/with/slash Z
2145
EOF
2146
'
2147
@@ -2027,6 +2154,8 @@ test_expect_success 'git checkout - with -B and --track, complete all references
2154
other/HEAD Z
2155
other/branch-in-other Z
2156
other/main-in-other Z
2157
+ remote/with/slash/HEAD Z
2158
+ remote/with/slash/branch/with/slash Z
2159
EOF
2160
'
2161
@@ -2039,6 +2168,8 @@ test_expect_success 'git checkout - with -b and --no-track, complete all referen
2168
other/HEAD Z
2169
other/branch-in-other Z
2170
other/main-in-other Z
2171
+ remote/with/slash/HEAD Z
2172
+ remote/with/slash/branch/with/slash Z
2173
EOF
2174
'
2175
@@ -2051,13 +2182,15 @@ test_expect_success 'git checkout - with -B and --no-track, complete all referen
2182
other/HEAD Z
2183
other/branch-in-other Z
2184
other/main-in-other Z
2185
+ remote/with/slash/HEAD Z
2186
+ remote/with/slash/branch/with/slash Z
2187
EOF
2188
'
2189
2190
test_expect_success 'git switch - for -c, complete local branches and unique remote branches' '
2191
test_completion "git switch -c " <<-\EOF
2059
- HEAD Z
2192
branch-in-other Z
2193
+ branch/with/slash Z
2194
main Z
2195
main-in-other Z
2196
matching-branch Z
@@ -2066,8 +2199,8 @@ test_expect_success 'git switch - for -c, complete local branches and unique rem
2199
2200
test_expect_success 'git switch - for -C, complete local branches and unique remote branches' '
2201
test_completion "git switch -C " <<-\EOF
2069
- HEAD Z
2202
branch-in-other Z
2203
+ branch/with/slash Z
2204
main Z
2205
main-in-other Z
2206
matching-branch Z
@@ -2104,8 +2237,8 @@ test_expect_success 'git switch - for -C with --no-track, complete local branche
2237
2238
test_expect_success 'git checkout - for -b, complete local branches and unique remote branches' '
2239
test_completion "git checkout -b " <<-\EOF
2107
- HEAD Z
2240
branch-in-other Z
2241
+ branch/with/slash Z
2242
main Z
2243
main-in-other Z
2244
matching-branch Z
@@ -2114,8 +2247,8 @@ test_expect_success 'git checkout - for -b, complete local branches and unique r
2247
2248
test_expect_success 'git checkout - for -B, complete local branches and unique remote branches' '
2249
test_completion "git checkout -B " <<-\EOF
2117
- HEAD Z
2250
branch-in-other Z
2251
+ branch/with/slash Z
2252
main Z
2253
main-in-other Z
2254
matching-branch Z
@@ -2152,8 +2285,8 @@ test_expect_success 'git checkout - for -B with --no-track, complete local branc
2285
2286
test_expect_success 'git switch - with --orphan completes local branch names and unique remote branch names' '
2287
test_completion "git switch --orphan " <<-\EOF
2155
- HEAD Z
2288
branch-in-other Z
2289
+ branch/with/slash Z
2290
main Z
2291
main-in-other Z
2292
matching-branch Z
@@ -2168,8 +2301,8 @@ test_expect_success 'git switch - --orphan with branch already provided complete
2301
2302
test_expect_success 'git checkout - with --orphan completes local branch names and unique remote branch names' '
2303
test_completion "git checkout --orphan " <<-\EOF
2171
- HEAD Z
2304
branch-in-other Z
2305
+ branch/with/slash Z
2306
main Z
2307
main-in-other Z
2308
matching-branch Z
@@ -2185,6 +2318,8 @@ test_expect_success 'git checkout - --orphan with branch already provided comple
2318
other/HEAD Z
2319
other/branch-in-other Z
2320
other/main-in-other Z
2321
+ remote/with/slash/HEAD Z
2322
+ remote/with/slash/branch/with/slash Z
2323
EOF
2324
'
2325
@@ -2199,7 +2334,8 @@ test_expect_success 'git restore completes modified files' '
2334
test_expect_success 'teardown after ref completion' '
2335
git branch -d matching-branch &&
2336
git tag -d matching-tag &&
2202
- git remote remove other
2337
+ git remote remove other &&
2338
+ git remote remove remote/with/slash
2339
'
2340
2341