]> asedeno.scripts.mit.edu Git - git.git/blob - t/t5523-push-upstream.sh
t5523-push-upstream: add function to ensure fresh upstream repo
[git.git] / t / t5523-push-upstream.sh
1 #!/bin/sh
2
3 test_description='push with --set-upstream'
4 . ./test-lib.sh
5
6 ensure_fresh_upstream() {
7         rm -rf parent && git init --bare parent
8 }
9
10 test_expect_success 'setup bare parent' '
11         ensure_fresh_upstream &&
12         git remote add upstream parent
13 '
14
15 test_expect_success 'setup local commit' '
16         echo content >file &&
17         git add file &&
18         git commit -m one
19 '
20
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
26 }
27
28 test_expect_success 'push -u master:master' '
29         git push -u upstream master:master &&
30         check_config master upstream refs/heads/master
31 '
32
33 test_expect_success 'push -u master:other' '
34         git push -u upstream master:other &&
35         check_config master upstream refs/heads/other
36 '
37
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
41 '
42
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
47 '
48
49 test_expect_success 'push -u master2:other2' '
50         git push -u upstream master2:other2 &&
51         check_config master2 upstream refs/heads/other2
52 '
53
54 test_expect_success 'push -u :master2' '
55         git push -u upstream :master2 &&
56         check_config master2 upstream refs/heads/other2
57 '
58
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
65 '
66
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
71 '
72
73 test_done