Skip to content

Commit

Permalink
t3200: Tests for new branch.autosetupmerge option "simple"
Browse files Browse the repository at this point in the history
In the previous commit a new autosetupmerge option was
introduced. Here the existing branch tests are extended
with three new cases testing this option - the obvious
matching-name and non-matching-name cases, and also a
non-matching-ref-type case.

The matching-name case needs to temporarily create
an independent repo to fetch from, as the general
strategy in these tests of using the local repo as
the remote precludes locally branching with the same
name as the "remote".

Signed-off-by: Tao Klerks <tao@klerks.biz>
  • Loading branch information
TaoK committed Feb 24, 2022
1 parent f18acad commit 7c74ceb
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions t/t3200-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,41 @@ test_expect_success 'branch from tag w/--track causes failure' '
test_must_fail git branch --track my11 foobar
'

test_expect_success 'simple tracking works when remote branch name matches' '
test_create_repo otherserver &&
test_commit -C otherserver my_commit 1 &&
git -C otherserver branch feature &&
git config branch.autosetupmerge simple &&
git config remote.otherserver.url otherserver &&
git config remote.otherserver.fetch refs/heads/*:refs/remotes/otherserver/* &&
git fetch otherserver &&
git branch feature otherserver/feature &&
rm -fr otherserver &&
test $(git config branch.feature.remote) = otherserver &&
test $(git config branch.feature.merge) = refs/heads/feature
'

test_expect_success 'simple tracking skips when remote branch name does not match' '
git config branch.autosetupmerge simple &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/main || git fetch local) &&
git branch my-other local/main &&
test -z "$(git config branch.my-other.remote)" &&
test -z "$(git config branch.my-other.merge)"
'

test_expect_success 'simple tracking skips when remote ref is not a branch' '
git config branch.autosetupmerge simple &&
git tag mytag12 main &&
git config remote.localtags.url . &&
git config remote.localtags.fetch refs/tags/*:refs/remotes/localtags/* &&
(git show-ref -q refs/remotes/localtags/mytag12 || git fetch localtags) &&
git branch mytag12 localtags/mytag12 &&
test -z "$(git config branch.mytag12.remote)" &&
test -z "$(git config branch.mytag12.merge)"
'

test_expect_success '--set-upstream-to fails on multiple branches' '
echo "fatal: too many arguments to set new upstream" >expect &&
test_must_fail git branch --set-upstream-to main a b c 2>err &&
Expand Down

0 comments on commit 7c74ceb

Please sign in to comment.