Merge branch 'jc/fix-tree-walk'
[git] / t / t5523-push-upstream.sh
1 #!/bin/sh
2
3 test_description='push with --set-upstream'
4 . ./test-lib.sh
5
6 test_expect_success 'setup bare parent' '
7         git init --bare parent &&
8         git remote add upstream parent
9 '
10
11 test_expect_success 'setup local commit' '
12         echo content >file &&
13         git add file &&
14         git commit -m one
15 '
16
17 check_config() {
18         (echo $2; echo $3) >expect.$1
19         (git config branch.$1.remote
20          git config branch.$1.merge) >actual.$1
21         test_cmp expect.$1 actual.$1
22 }
23
24 test_expect_success 'push -u master:master' '
25         git push -u upstream master:master &&
26         check_config master upstream refs/heads/master
27 '
28
29 test_expect_success 'push -u master:other' '
30         git push -u upstream master:other &&
31         check_config master upstream refs/heads/other
32 '
33
34 test_expect_success 'push -u --dry-run master:otherX' '
35         git push -u --dry-run upstream master:otherX &&
36         check_config master upstream refs/heads/other
37 '
38
39 test_expect_success 'push -u master2:master2' '
40         git branch master2 &&
41         git push -u upstream master2:master2 &&
42         check_config master2 upstream refs/heads/master2
43 '
44
45 test_expect_success 'push -u master2:other2' '
46         git push -u upstream master2:other2 &&
47         check_config master2 upstream refs/heads/other2
48 '
49
50 test_expect_success 'push -u :master2' '
51         git push -u upstream :master2 &&
52         check_config master2 upstream refs/heads/other2
53 '
54
55 test_expect_success 'push -u --all' '
56         git branch all1 &&
57         git branch all2 &&
58         git push -u --all &&
59         check_config all1 upstream refs/heads/all1 &&
60         check_config all2 upstream refs/heads/all2
61 '
62
63 test_expect_success 'push -u HEAD' '
64         git checkout -b headbranch &&
65         git push -u upstream HEAD &&
66         check_config headbranch upstream refs/heads/headbranch
67 '
68
69 test_done