t5523-push-upstream: add function to ensure fresh upstream repo
[git/debian.git] / t / t5523-push-upstream.sh
blob5a18533ad7965b82a656ba779bfc8098a13339c4
1 #!/bin/sh
3 test_description='push with --set-upstream'
4 . ./test-lib.sh
6 ensure_fresh_upstream() {
7 rm -rf parent && git init --bare parent
10 test_expect_success 'setup bare parent' '
11 ensure_fresh_upstream &&
12 git remote add upstream parent
15 test_expect_success 'setup local commit' '
16 echo content >file &&
17 git add file &&
18 git commit -m one
21 check_config() {
22 (echo $2; echo $3) >expect.$1
23 (git config branch.$1.remote
24 git config branch.$1.merge) >actual.$1
25 test_cmp expect.$1 actual.$1
28 test_expect_success 'push -u master:master' '
29 git push -u upstream master:master &&
30 check_config master upstream refs/heads/master
33 test_expect_success 'push -u master:other' '
34 git push -u upstream master:other &&
35 check_config master upstream refs/heads/other
38 test_expect_success 'push -u --dry-run master:otherX' '
39 git push -u --dry-run upstream master:otherX &&
40 check_config master upstream refs/heads/other
43 test_expect_success 'push -u master2:master2' '
44 git branch master2 &&
45 git push -u upstream master2:master2 &&
46 check_config master2 upstream refs/heads/master2
49 test_expect_success 'push -u master2:other2' '
50 git push -u upstream master2:other2 &&
51 check_config master2 upstream refs/heads/other2
54 test_expect_success 'push -u :master2' '
55 git push -u upstream :master2 &&
56 check_config master2 upstream refs/heads/other2
59 test_expect_success 'push -u --all' '
60 git branch all1 &&
61 git branch all2 &&
62 git push -u --all &&
63 check_config all1 upstream refs/heads/all1 &&
64 check_config all2 upstream refs/heads/all2
67 test_expect_success 'push -u HEAD' '
68 git checkout -b headbranch &&
69 git push -u upstream HEAD &&
70 check_config headbranch upstream refs/heads/headbranch
73 test_done