5a18533ad7965b82a656ba779bfc8098a13339c4
1#!/bin/sh
2
3test_description='push with --set-upstream'
4. ./test-lib.sh
5
6ensure_fresh_upstream() {
7 rm -rf parent && git init --bare parent
8}
9
10test_expect_success 'setup bare parent' '
11 ensure_fresh_upstream &&
12 git remote add upstream parent
13'
14
15test_expect_success 'setup local commit' '
16 echo content >file &&
17 git add file &&
18 git commit -m one
19'
20
21check_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
28test_expect_success 'push -u master:master' '
29 git push -u upstream master:master &&
30 check_config master upstream refs/heads/master
31'
32
33test_expect_success 'push -u master:other' '
34 git push -u upstream master:other &&
35 check_config master upstream refs/heads/other
36'
37
38test_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
43test_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
49test_expect_success 'push -u master2:other2' '
50 git push -u upstream master2:other2 &&
51 check_config master2 upstream refs/heads/other2
52'
53
54test_expect_success 'push -u :master2' '
55 git push -u upstream :master2 &&
56 check_config master2 upstream refs/heads/other2
57'
58
59test_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
67test_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
73test_done