1#!/bin/sh
23
test_description='push with --set-upstream'
4. ./test-lib.sh
5. "$TEST_DIRECTORY"/lib-terminal.sh
67
ensure_fresh_upstream() {
8rm -rf parent && git init --bare parent
9}
1011
test_expect_success 'setup bare parent' '
12ensure_fresh_upstream &&
13git remote add upstream parent
14'
1516
test_expect_success 'setup local commit' '
17echo content >file &&
18git add file &&
19git commit -m one
20'
2122
check_config() {
23(echo $2; echo $3) >expect.$1
24(git config branch.$1.remote
25git config branch.$1.merge) >actual.$1
26test_cmp expect.$1 actual.$1
27}
2829
test_expect_success 'push -u master:master' '
30git push -u upstream master:master &&
31check_config master upstream refs/heads/master
32'
3334
test_expect_success 'push -u master:other' '
35git push -u upstream master:other &&
36check_config master upstream refs/heads/other
37'
3839
test_expect_success 'push -u --dry-run master:otherX' '
40git push -u --dry-run upstream master:otherX &&
41check_config master upstream refs/heads/other
42'
4344
test_expect_success 'push -u master2:master2' '
45git branch master2 &&
46git push -u upstream master2:master2 &&
47check_config master2 upstream refs/heads/master2
48'
4950
test_expect_success 'push -u master2:other2' '
51git push -u upstream master2:other2 &&
52check_config master2 upstream refs/heads/other2
53'
5455
test_expect_success 'push -u :master2' '
56git push -u upstream :master2 &&
57check_config master2 upstream refs/heads/other2
58'
5960
test_expect_success 'push -u --all' '
61git branch all1 &&
62git branch all2 &&
63git push -u --all &&
64check_config all1 upstream refs/heads/all1 &&
65check_config all2 upstream refs/heads/all2
66'
6768
test_expect_success 'push -u HEAD' '
69git checkout -b headbranch &&
70git push -u upstream HEAD &&
71check_config headbranch upstream refs/heads/headbranch
72'
7374
test_expect_success TTY 'progress messages go to tty' '
75ensure_fresh_upstream &&
7677
test_terminal git push -u upstream master >out 2>err &&
78test_i18ngrep "Writing objects" err
79'
8081
test_expect_success 'progress messages do not go to non-tty' '
82ensure_fresh_upstream &&
8384
# skip progress messages, since stderr is non-tty
85git push -u upstream master >out 2>err &&
86! grep "Writing objects" err
87'
8889
test_expect_success 'progress messages go to non-tty (forced)' '
90ensure_fresh_upstream &&
9192
# force progress messages to stderr, even though it is non-tty
93git push -u --progress upstream master >out 2>err &&
94test_i18ngrep "Writing objects" err
95'
9697
test_expect_success TTY 'push -q suppresses progress' '
98ensure_fresh_upstream &&
99100
test_terminal git push -u -q upstream master >out 2>err &&
101! grep "Writing objects" err
102'
103104
test_expect_success TTY 'push --no-progress suppresses progress' '
105ensure_fresh_upstream &&
106107
test_terminal git push -u --no-progress upstream master >out 2>err &&
108! grep "Unpacking objects" err &&
109! grep "Writing objects" err
110'
111112
test_expect_success TTY 'quiet push' '
113ensure_fresh_upstream &&
114115
test_terminal git push --quiet --no-progress upstream master 2>&1 | tee output &&
116test_cmp /dev/null output
117'
118119
test_done