test_expect_success 'setup for __git_find_repo_path/__gitdir tests' '
mkdir -p subdir/subsubdir &&
mkdir -p non-repo &&
- git init -b main otherrepo
+ git init -b main otherrepo &&
+ git init -b main slashrepo
'
test_expect_success '__git_find_repo_path - from command line (through $__git_dir)' '
) &&
git remote add other "$ROOT/otherrepo/.git" &&
git fetch --no-tags other &&
+ (
+ cd slashrepo &&
+ git commit --allow-empty -m initial &&
+ git branch -m main branch/with/slash
+ ) &&
+ git remote add remote/with/slash "$ROOT/slashrepo/.git" &&
+ git fetch --no-tags remote/with/slash &&
rm -f .git/FETCH_HEAD &&
git init thirdrepo
'
other/HEAD
other/branch-in-other
other/main-in-other
+ remote/with/slash/HEAD
+ remote/with/slash/branch/with/slash
matching-tag
EOF
(
refs/remotes/other/HEAD
refs/remotes/other/branch-in-other
refs/remotes/other/main-in-other
+ refs/remotes/remote/with/slash/HEAD
+ refs/remotes/remote/with/slash/branch/with/slash
refs/tags/matching-tag
EOF
(
test_cmp expected "$actual"
'
+test_expect_success '__git_refs - configured remote - with slash' '
+ cat >expected <<-EOF &&
+ HEAD
+ HEAD
+ branch/with/slash
+ EOF
+ (
+ cur= &&
+ __git_refs remote/with/slash >"$actual"
+ ) &&
+ test_cmp expected "$actual"
+'
+
test_expect_success '__git_refs - configured remote - full refs' '
cat >expected <<-EOF &&
HEAD
other/ambiguous
other/branch-in-other
other/main-in-other
- remote/ambiguous
- remote/branch-in-remote
+ remote/with/slash/HEAD
+ remote/with/slash/ambiguous
+ remote/with/slash/branch-in-remote
+ remote/with/slash/branch/with/slash
matching-tag
- HEAD
branch-in-other
branch-in-remote
+ branch/with/slash
main-in-other
EOF
for remote_ref in refs/remotes/other/ambiguous \
- refs/remotes/remote/ambiguous \
- refs/remotes/remote/branch-in-remote
+ refs/remotes/remote/with/slash/ambiguous \
+ refs/remotes/remote/with/slash/branch-in-remote
do
git update-ref $remote_ref main &&
test_when_finished "git update-ref -d $remote_ref" || return 1
other/HEAD
other/branch-in-other
other/main-in-other
+ remote/with/slash/HEAD
+ remote/with/slash/branch/with/slash
matching-tag
EOF
(
refs/remotes/other/HEAD
refs/remotes/other/branch-in-other
refs/remotes/other/main-in-other
+ refs/remotes/remote/with/slash/HEAD
+ refs/remotes/remote/with/slash/branch/with/slash
refs/tags/matching-tag
EOF
(
^other/HEAD
^other/branch-in-other
^other/main-in-other
+ ^remote/with/slash/HEAD
+ ^remote/with/slash/branch/with/slash
^matching-tag
EOF
(
^refs/remotes/other/HEAD
^refs/remotes/other/branch-in-other
^refs/remotes/other/main-in-other
+ ^refs/remotes/remote/with/slash/HEAD
+ ^refs/remotes/remote/with/slash/branch/with/slash
^refs/tags/matching-tag
EOF
(
other/branch-in-other
other/main-in-other
other/matching/branch-in-other
+ remote/with/slash/HEAD
+ remote/with/slash/branch/with/slash
matching-tag
matching/tag
EOF
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
matching-tag Z
EOF
(
test_cmp expected out
'
+test_expect_success '__git_complete_refs - remote - with slash' '
+ sed -e "s/Z$//" >expected <<-EOF &&
+ HEAD Z
+ HEAD Z
+ branch/with/slash Z
+ EOF
+ (
+ cur= &&
+ __git_complete_refs --remote=remote/with/slash &&
+ print_comp
+ ) &&
+ test_cmp expected out
+'
+
test_expect_success '__git_complete_refs - track' '
sed -e "s/Z$//" >expected <<-EOF &&
HEAD Z
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
matching-tag Z
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main-in-other Z
EOF
(
other/HEAD.
other/branch-in-other.
other/main-in-other.
+ remote/with/slash/HEAD.
+ remote/with/slash/branch/with/slash.
matching-tag.
EOF
(
test_cmp expected out
'
+test_expect_success '__git_complete_fetch_refspecs - with slash' '
+ sed -e "s/Z$//" >expected <<-EOF &&
+ HEAD:HEAD Z
+ HEAD:HEAD Z
+ branch/with/slash:branch/with/slash Z
+ EOF
+ (
+ cur= &&
+ __git_complete_fetch_refspecs remote/with/slash &&
+ print_comp
+ ) &&
+ test_cmp expected out
+'
+
test_expect_success '__git_complete_fetch_refspecs - matching' '
sed -e "s/Z$//" >expected <<-EOF &&
branch-in-other:branch-in-other Z
test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' '
test_completion "git switch " <<-\EOF
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
test_completion "git checkout " <<-\EOF
HEAD Z
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
test_expect_success 'git switch - --guess overrides GIT_COMPLETION_CHECKOUT_NO_GUESS=1, complete local branches and unique remote names for DWIM logic' '
GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git switch --guess " <<-\EOF
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
test_expect_success 'git switch - a later --guess overrides previous --no-guess, complete local and remote unique branches for DWIM' '
test_completion "git switch --no-guess --guess " <<-\EOF
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
test_expect_success 'git checkout - --guess overrides GIT_COMPLETION_NO_GUESS=1, complete refs and unique remote branches for DWIM' '
GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git checkout --guess " <<-\EOF
HEAD Z
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
test_expect_success 'git checkout - a later --guess overrides previous --no-guess, complete refs and unique remote branches for DWIM' '
test_completion "git checkout --no-guess --guess " <<-\EOF
HEAD Z
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
test_config checkout.guess true &&
test_completion "git checkout " <<-\EOF
HEAD Z
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
test_config checkout.guess false &&
test_completion "git checkout --guess " <<-\EOF
HEAD Z
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
test_completion "git switch -t " <<-\EOF
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
test_completion "git checkout -t " <<-\EOF
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
test_expect_success 'git switch - for -c, complete local branches and unique remote branches' '
test_completion "git switch -c " <<-\EOF
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
test_expect_success 'git switch - for -C, complete local branches and unique remote branches' '
test_completion "git switch -C " <<-\EOF
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
test_expect_success 'git checkout - for -b, complete local branches and unique remote branches' '
test_completion "git checkout -b " <<-\EOF
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
test_expect_success 'git checkout - for -B, complete local branches and unique remote branches' '
test_completion "git checkout -B " <<-\EOF
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
test_expect_success 'git switch - with --orphan completes local branch names and unique remote branch names' '
test_completion "git switch --orphan " <<-\EOF
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
test_expect_success 'git checkout - with --orphan completes local branch names and unique remote branch names' '
test_completion "git checkout --orphan " <<-\EOF
- HEAD Z
branch-in-other Z
+ branch/with/slash Z
main Z
main-in-other Z
matching-branch Z
other/HEAD Z
other/branch-in-other Z
other/main-in-other Z
+ remote/with/slash/HEAD Z
+ remote/with/slash/branch/with/slash Z
EOF
'
test_expect_success 'teardown after ref completion' '
git branch -d matching-branch &&
git tag -d matching-tag &&
- git remote remove other
+ git remote remove other &&
+ git remote remove remote/with/slash
'