Git fork

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>

authored by

David Mandelberg and committed by
Junio C Hamano
778d2f17 5637bdc3

+189 -29
+31 -7
contrib/completion/git-completion.bash
··· 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 794 795 # employ the heuristic used by git checkout and git switch 796 # Try to find a remote branch that cur_es the completion word 797 # 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 803 } 804 805 # Lists refs from the local (by default) or from a remote repository. ··· 905 case "HEAD" in 906 $match*|$umatch*) echo "${pfx}HEAD$sfx" ;; 907 esac 908 - __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ 909 ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \ 910 "refs/remotes/$remote/$match*" \ 911 "refs/remotes/$remote/$match*/**"
··· 790 __git_dwim_remote_heads () 791 { 792 local pfx="${1-}" cur_="${2-}" sfx="${3-}" 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 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. ··· 928 case "HEAD" in 929 $match*|$umatch*) echo "${pfx}HEAD$sfx" ;; 930 esac 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*/**"
+158 -22
t/t9902-completion.sh
··· 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 153 ' 154 155 test_expect_success '__git_find_repo_path - from command line (through $__git_dir)' ' ··· 674 ) && 675 git remote add other "$ROOT/otherrepo/.git" && 676 git fetch --no-tags other && 677 rm -f .git/FETCH_HEAD && 678 git init thirdrepo 679 ' ··· 686 other/HEAD 687 other/branch-in-other 688 other/main-in-other 689 matching-tag 690 EOF 691 ( ··· 702 refs/remotes/other/HEAD 703 refs/remotes/other/branch-in-other 704 refs/remotes/other/main-in-other 705 refs/tags/matching-tag 706 EOF 707 ( ··· 767 test_cmp expected "$actual" 768 ' 769 770 test_expect_success '__git_refs - configured remote - full refs' ' 771 cat >expected <<-EOF && 772 HEAD ··· 909 other/ambiguous 910 other/branch-in-other 911 other/main-in-other 912 - remote/ambiguous 913 - remote/branch-in-remote 914 matching-tag 915 - HEAD 916 branch-in-other 917 branch-in-remote 918 main-in-other 919 EOF 920 for remote_ref in refs/remotes/other/ambiguous \ 921 - refs/remotes/remote/ambiguous \ 922 - refs/remotes/remote/branch-in-remote 923 do 924 git update-ref $remote_ref main && 925 test_when_finished "git update-ref -d $remote_ref" || return 1 ··· 939 other/HEAD 940 other/branch-in-other 941 other/main-in-other 942 matching-tag 943 EOF 944 ( ··· 955 refs/remotes/other/HEAD 956 refs/remotes/other/branch-in-other 957 refs/remotes/other/main-in-other 958 refs/tags/matching-tag 959 EOF 960 ( ··· 972 ^other/HEAD 973 ^other/branch-in-other 974 ^other/main-in-other 975 ^matching-tag 976 EOF 977 ( ··· 988 ^refs/remotes/other/HEAD 989 ^refs/remotes/other/branch-in-other 990 ^refs/remotes/other/main-in-other 991 ^refs/tags/matching-tag 992 EOF 993 ( ··· 1015 other/branch-in-other 1016 other/main-in-other 1017 other/matching/branch-in-other 1018 matching-tag 1019 matching/tag 1020 EOF ··· 1135 other/HEAD Z 1136 other/branch-in-other Z 1137 other/main-in-other Z 1138 matching-tag Z 1139 EOF 1140 ( ··· 1173 test_cmp expected out 1174 ' 1175 1176 test_expect_success '__git_complete_refs - track' ' 1177 sed -e "s/Z$//" >expected <<-EOF && 1178 HEAD Z ··· 1181 other/HEAD Z 1182 other/branch-in-other Z 1183 other/main-in-other Z 1184 matching-tag Z 1185 - HEAD Z 1186 branch-in-other Z 1187 main-in-other Z 1188 EOF 1189 ( ··· 1228 other/HEAD. 1229 other/branch-in-other. 1230 other/main-in-other. 1231 matching-tag. 1232 EOF 1233 ( ··· 1253 test_cmp expected out 1254 ' 1255 1256 test_expect_success '__git_complete_fetch_refspecs - matching' ' 1257 sed -e "s/Z$//" >expected <<-EOF && 1258 branch-in-other:branch-in-other Z ··· 1333 1334 test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' ' 1335 test_completion "git switch " <<-\EOF 1336 - HEAD Z 1337 branch-in-other Z 1338 main Z 1339 main-in-other Z 1340 matching-branch Z ··· 1480 test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' ' 1481 test_completion "git checkout " <<-\EOF 1482 HEAD Z 1483 - HEAD Z 1484 branch-in-other Z 1485 main Z 1486 main-in-other Z 1487 matching-branch Z ··· 1489 other/HEAD Z 1490 other/branch-in-other Z 1491 other/main-in-other Z 1492 EOF 1493 ' 1494 ··· 1508 1509 test_expect_success 'git switch - --guess overrides GIT_COMPLETION_CHECKOUT_NO_GUESS=1, complete local branches and unique remote names for DWIM logic' ' 1510 GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git switch --guess " <<-\EOF 1511 - HEAD Z 1512 branch-in-other Z 1513 main Z 1514 main-in-other Z 1515 matching-branch Z ··· 1518 1519 test_expect_success 'git switch - a later --guess overrides previous --no-guess, complete local and remote unique branches for DWIM' ' 1520 test_completion "git switch --no-guess --guess " <<-\EOF 1521 - HEAD Z 1522 branch-in-other Z 1523 main Z 1524 main-in-other Z 1525 matching-branch Z ··· 1542 other/HEAD Z 1543 other/branch-in-other Z 1544 other/main-in-other Z 1545 EOF 1546 ' 1547 1548 test_expect_success 'git checkout - --guess overrides GIT_COMPLETION_NO_GUESS=1, complete refs and unique remote branches for DWIM' ' 1549 GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git checkout --guess " <<-\EOF 1550 HEAD Z 1551 - HEAD Z 1552 branch-in-other Z 1553 main Z 1554 main-in-other Z 1555 matching-branch Z ··· 1557 other/HEAD Z 1558 other/branch-in-other Z 1559 other/main-in-other Z 1560 EOF 1561 ' 1562 ··· 1569 other/HEAD Z 1570 other/branch-in-other Z 1571 other/main-in-other Z 1572 EOF 1573 ' 1574 1575 test_expect_success 'git checkout - a later --guess overrides previous --no-guess, complete refs and unique remote branches for DWIM' ' 1576 test_completion "git checkout --no-guess --guess " <<-\EOF 1577 HEAD Z 1578 - HEAD Z 1579 branch-in-other Z 1580 main Z 1581 main-in-other Z 1582 matching-branch Z ··· 1584 other/HEAD Z 1585 other/branch-in-other Z 1586 other/main-in-other Z 1587 EOF 1588 ' 1589 ··· 1596 other/HEAD Z 1597 other/branch-in-other Z 1598 other/main-in-other Z 1599 EOF 1600 ' 1601 ··· 1609 other/HEAD Z 1610 other/branch-in-other Z 1611 other/main-in-other Z 1612 EOF 1613 ' 1614 ··· 1616 test_config checkout.guess true && 1617 test_completion "git checkout " <<-\EOF 1618 HEAD Z 1619 - HEAD Z 1620 branch-in-other Z 1621 main Z 1622 main-in-other Z 1623 matching-branch Z ··· 1625 other/HEAD Z 1626 other/branch-in-other Z 1627 other/main-in-other Z 1628 EOF 1629 ' 1630 1631 test_expect_success 'git checkout - a later --guess overrides previous checkout.guess = false, complete refs and unique remote branches for DWIM' ' 1632 test_config checkout.guess false && 1633 test_completion "git checkout --guess " <<-\EOF 1634 - HEAD Z 1635 HEAD Z 1636 branch-in-other Z 1637 main Z 1638 main-in-other Z 1639 matching-branch Z ··· 1641 other/HEAD Z 1642 other/branch-in-other Z 1643 other/main-in-other Z 1644 EOF 1645 ' 1646 ··· 1654 other/HEAD Z 1655 other/branch-in-other Z 1656 other/main-in-other Z 1657 EOF 1658 ' 1659 ··· 1666 other/HEAD Z 1667 other/branch-in-other Z 1668 other/main-in-other Z 1669 EOF 1670 ' 1671 ··· 1678 other/HEAD Z 1679 other/branch-in-other Z 1680 other/main-in-other Z 1681 EOF 1682 ' 1683 ··· 1850 other/HEAD Z 1851 other/branch-in-other Z 1852 other/main-in-other Z 1853 EOF 1854 ' 1855 ··· 1862 other/HEAD Z 1863 other/branch-in-other Z 1864 other/main-in-other Z 1865 EOF 1866 ' 1867 ··· 1870 other/HEAD Z 1871 other/branch-in-other Z 1872 other/main-in-other Z 1873 EOF 1874 test_completion "git switch -t " <<-\EOF 1875 other/HEAD Z 1876 other/branch-in-other Z 1877 other/main-in-other Z 1878 EOF 1879 ' 1880 ··· 1883 other/HEAD Z 1884 other/branch-in-other Z 1885 other/main-in-other Z 1886 EOF 1887 test_completion "git checkout -t " <<-\EOF 1888 other/HEAD Z 1889 other/branch-in-other Z 1890 other/main-in-other Z 1891 EOF 1892 ' 1893 ··· 1907 other/HEAD Z 1908 other/branch-in-other Z 1909 other/main-in-other Z 1910 EOF 1911 ' 1912 ··· 1919 other/HEAD Z 1920 other/branch-in-other Z 1921 other/main-in-other Z 1922 EOF 1923 ' 1924 ··· 1931 other/HEAD Z 1932 other/branch-in-other Z 1933 other/main-in-other Z 1934 EOF 1935 ' 1936 ··· 1943 other/HEAD Z 1944 other/branch-in-other Z 1945 other/main-in-other Z 1946 EOF 1947 ' 1948 ··· 1955 other/HEAD Z 1956 other/branch-in-other Z 1957 other/main-in-other Z 1958 EOF 1959 ' 1960 ··· 1967 other/HEAD Z 1968 other/branch-in-other Z 1969 other/main-in-other Z 1970 EOF 1971 ' 1972 ··· 1979 other/HEAD Z 1980 other/branch-in-other Z 1981 other/main-in-other Z 1982 EOF 1983 ' 1984 ··· 1991 other/HEAD Z 1992 other/branch-in-other Z 1993 other/main-in-other Z 1994 EOF 1995 ' 1996 ··· 2003 other/HEAD Z 2004 other/branch-in-other Z 2005 other/main-in-other Z 2006 EOF 2007 ' 2008 ··· 2015 other/HEAD Z 2016 other/branch-in-other Z 2017 other/main-in-other Z 2018 EOF 2019 ' 2020 ··· 2027 other/HEAD Z 2028 other/branch-in-other Z 2029 other/main-in-other Z 2030 EOF 2031 ' 2032 ··· 2039 other/HEAD Z 2040 other/branch-in-other Z 2041 other/main-in-other Z 2042 EOF 2043 ' 2044 ··· 2051 other/HEAD Z 2052 other/branch-in-other Z 2053 other/main-in-other Z 2054 EOF 2055 ' 2056 2057 test_expect_success 'git switch - for -c, complete local branches and unique remote branches' ' 2058 test_completion "git switch -c " <<-\EOF 2059 - HEAD Z 2060 branch-in-other Z 2061 main Z 2062 main-in-other Z 2063 matching-branch Z ··· 2066 2067 test_expect_success 'git switch - for -C, complete local branches and unique remote branches' ' 2068 test_completion "git switch -C " <<-\EOF 2069 - HEAD Z 2070 branch-in-other Z 2071 main Z 2072 main-in-other Z 2073 matching-branch Z ··· 2104 2105 test_expect_success 'git checkout - for -b, complete local branches and unique remote branches' ' 2106 test_completion "git checkout -b " <<-\EOF 2107 - HEAD Z 2108 branch-in-other Z 2109 main Z 2110 main-in-other Z 2111 matching-branch Z ··· 2114 2115 test_expect_success 'git checkout - for -B, complete local branches and unique remote branches' ' 2116 test_completion "git checkout -B " <<-\EOF 2117 - HEAD Z 2118 branch-in-other Z 2119 main Z 2120 main-in-other Z 2121 matching-branch Z ··· 2152 2153 test_expect_success 'git switch - with --orphan completes local branch names and unique remote branch names' ' 2154 test_completion "git switch --orphan " <<-\EOF 2155 - HEAD Z 2156 branch-in-other Z 2157 main Z 2158 main-in-other Z 2159 matching-branch Z ··· 2168 2169 test_expect_success 'git checkout - with --orphan completes local branch names and unique remote branch names' ' 2170 test_completion "git checkout --orphan " <<-\EOF 2171 - HEAD Z 2172 branch-in-other Z 2173 main Z 2174 main-in-other Z 2175 matching-branch Z ··· 2185 other/HEAD Z 2186 other/branch-in-other Z 2187 other/main-in-other Z 2188 EOF 2189 ' 2190 ··· 2199 test_expect_success 'teardown after ref completion' ' 2200 git branch -d matching-branch && 2201 git tag -d matching-tag && 2202 - git remote remove other 2203 ' 2204 2205
··· 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 && 153 + git init -b main slashrepo 154 ' 155 156 test_expect_success '__git_find_repo_path - from command line (through $__git_dir)' ' ··· 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 ' ··· 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 ( ··· 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 ( ··· 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 ··· 934 other/ambiguous 935 other/branch-in-other 936 other/main-in-other 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 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 \ 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 ··· 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 ( ··· 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 ( ··· 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 ( ··· 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 ( ··· 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 ··· 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 ( ··· 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 ··· 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 1240 branch-in-other Z 1241 + branch/with/slash Z 1242 main-in-other Z 1243 EOF 1244 ( ··· 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 ( ··· 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 ··· 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 1407 branch-in-other Z 1408 + branch/with/slash Z 1409 main Z 1410 main-in-other Z 1411 matching-branch Z ··· 1551 test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' ' 1552 test_completion "git checkout " <<-\EOF 1553 HEAD Z 1554 branch-in-other Z 1555 + branch/with/slash Z 1556 main Z 1557 main-in-other Z 1558 matching-branch Z ··· 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 ··· 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 1584 branch-in-other Z 1585 + branch/with/slash Z 1586 main Z 1587 main-in-other Z 1588 matching-branch Z ··· 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 1594 branch-in-other Z 1595 + branch/with/slash Z 1596 main Z 1597 main-in-other Z 1598 matching-branch Z ··· 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 1626 branch-in-other Z 1627 + branch/with/slash Z 1628 main Z 1629 main-in-other Z 1630 matching-branch Z ··· 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 ··· 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 1657 branch-in-other Z 1658 + branch/with/slash Z 1659 main Z 1660 main-in-other Z 1661 matching-branch Z ··· 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 ··· 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 ··· 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 ··· 1701 test_config checkout.guess true && 1702 test_completion "git checkout " <<-\EOF 1703 HEAD Z 1704 branch-in-other Z 1705 + branch/with/slash Z 1706 main Z 1707 main-in-other Z 1708 matching-branch Z ··· 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 1718 test_expect_success 'git checkout - a later --guess overrides previous checkout.guess = false, complete refs and unique remote branches for DWIM' ' 1719 test_config checkout.guess false && 1720 test_completion "git checkout --guess " <<-\EOF 1721 HEAD Z 1722 branch-in-other Z 1723 + branch/with/slash Z 1724 main Z 1725 main-in-other Z 1726 matching-branch Z ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 ··· 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 2192 branch-in-other Z 2193 + branch/with/slash Z 2194 main Z 2195 main-in-other Z 2196 matching-branch Z ··· 2199 2200 test_expect_success 'git switch - for -C, complete local branches and unique remote branches' ' 2201 test_completion "git switch -C " <<-\EOF 2202 branch-in-other Z 2203 + branch/with/slash Z 2204 main Z 2205 main-in-other Z 2206 matching-branch Z ··· 2237 2238 test_expect_success 'git checkout - for -b, complete local branches and unique remote branches' ' 2239 test_completion "git checkout -b " <<-\EOF 2240 branch-in-other Z 2241 + branch/with/slash Z 2242 main Z 2243 main-in-other Z 2244 matching-branch Z ··· 2247 2248 test_expect_success 'git checkout - for -B, complete local branches and unique remote branches' ' 2249 test_completion "git checkout -B " <<-\EOF 2250 branch-in-other Z 2251 + branch/with/slash Z 2252 main Z 2253 main-in-other Z 2254 matching-branch Z ··· 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 2288 branch-in-other Z 2289 + branch/with/slash Z 2290 main Z 2291 main-in-other Z 2292 matching-branch Z ··· 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 2304 branch-in-other Z 2305 + branch/with/slash Z 2306 main Z 2307 main-in-other Z 2308 matching-branch Z ··· 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 ··· 2334 test_expect_success 'teardown after ref completion' ' 2335 git branch -d matching-branch && 2336 git tag -d matching-tag && 2337 + git remote remove other && 2338 + git remote remove remote/with/slash 2339 ' 2340 2341