]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5523-push-upstream.sh
The third batch
[thirdparty/git.git] / t / t5523-push-upstream.sh
CommitLineData
e9fcd1e2
IL
1#!/bin/sh
2
3test_description='push with --set-upstream'
3ac8f630 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
c65d18cb 7TEST_PASSES_SANITIZE_LEAK=true
e9fcd1e2 8. ./test-lib.sh
8ac3ed27 9. "$TEST_DIRECTORY"/lib-terminal.sh
e9fcd1e2 10
2d59ced1
TRC
11ensure_fresh_upstream() {
12 rm -rf parent && git init --bare parent
13}
14
e9fcd1e2 15test_expect_success 'setup bare parent' '
2d59ced1 16 ensure_fresh_upstream &&
e9fcd1e2
IL
17 git remote add upstream parent
18'
19
20test_expect_success 'setup local commit' '
21 echo content >file &&
22 git add file &&
23 git commit -m one
24'
25
26check_config() {
27 (echo $2; echo $3) >expect.$1
28 (git config branch.$1.remote
29 git config branch.$1.merge) >actual.$1
30 test_cmp expect.$1 actual.$1
31}
32
3ac8f630
JS
33test_expect_success 'push -u main:main' '
34 git push -u upstream main:main &&
35 check_config main upstream refs/heads/main
e9fcd1e2
IL
36'
37
3ac8f630
JS
38test_expect_success 'push -u main:other' '
39 git push -u upstream main:other &&
40 check_config main upstream refs/heads/other
e9fcd1e2
IL
41'
42
3ac8f630
JS
43test_expect_success 'push -u --dry-run main:otherX' '
44 git push -u --dry-run upstream main:otherX &&
45 check_config main upstream refs/heads/other
e9fcd1e2
IL
46'
47
b6211b89
JS
48test_expect_success 'push -u topic_2:topic_2' '
49 git branch topic_2 &&
50 git push -u upstream topic_2:topic_2 &&
51 check_config topic_2 upstream refs/heads/topic_2
e9fcd1e2
IL
52'
53
b6211b89
JS
54test_expect_success 'push -u topic_2:other2' '
55 git push -u upstream topic_2:other2 &&
56 check_config topic_2 upstream refs/heads/other2
e9fcd1e2
IL
57'
58
b6211b89
JS
59test_expect_success 'push -u :topic_2' '
60 git push -u upstream :topic_2 &&
61 check_config topic_2 upstream refs/heads/other2
e9fcd1e2
IL
62'
63
425b4d7f 64test_expect_success 'push -u --all(the same behavior with--branches)' '
e9fcd1e2
IL
65 git branch all1 &&
66 git branch all2 &&
67 git push -u --all &&
68 check_config all1 upstream refs/heads/all1 &&
425b4d7f
TL
69 check_config all2 upstream refs/heads/all2 &&
70 git config --get-regexp branch.all* > expect &&
71 git config --remove-section branch.all1 &&
72 git config --remove-section branch.all2 &&
73 git push -u --branches &&
74 check_config all1 upstream refs/heads/all1 &&
75 check_config all2 upstream refs/heads/all2 &&
76 git config --get-regexp branch.all* > actual &&
77 test_cmp expect actual
e9fcd1e2
IL
78'
79
80test_expect_success 'push -u HEAD' '
81 git checkout -b headbranch &&
82 git push -u upstream HEAD &&
83 check_config headbranch upstream refs/heads/headbranch
84'
85
8ac3ed27
TRC
86test_expect_success TTY 'progress messages go to tty' '
87 ensure_fresh_upstream &&
88
3ac8f630 89 test_terminal git push -u upstream main >out 2>err &&
6789275d 90 test_grep "Writing objects" err
8ac3ed27
TRC
91'
92
d7c411b7 93test_expect_success 'progress messages do not go to non-tty' '
8ac3ed27
TRC
94 ensure_fresh_upstream &&
95
96 # skip progress messages, since stderr is non-tty
3ac8f630 97 git push -u upstream main >out 2>err &&
6789275d 98 test_grep ! "Writing objects" err
8ac3ed27
TRC
99'
100
d7c411b7 101test_expect_success 'progress messages go to non-tty (forced)' '
8ac3ed27
TRC
102 ensure_fresh_upstream &&
103
104 # force progress messages to stderr, even though it is non-tty
3ac8f630 105 git push -u --progress upstream main >out 2>err &&
6789275d 106 test_grep "Writing objects" err
8ac3ed27
TRC
107'
108
109test_expect_success TTY 'push -q suppresses progress' '
110 ensure_fresh_upstream &&
111
3ac8f630 112 test_terminal git push -u -q upstream main >out 2>err &&
6789275d 113 test_grep ! "Writing objects" err
8ac3ed27
TRC
114'
115
01fdc21f 116test_expect_success TTY 'push --no-progress suppresses progress' '
8ac3ed27
TRC
117 ensure_fresh_upstream &&
118
3ac8f630 119 test_terminal git push -u --no-progress upstream main >out 2>err &&
6789275d
JH
120 test_grep ! "Unpacking objects" err &&
121 test_grep ! "Writing objects" err
8ac3ed27
TRC
122'
123
c207e34f
CB
124test_expect_success TTY 'quiet push' '
125 ensure_fresh_upstream &&
126
3ac8f630 127 test_terminal git push --quiet --no-progress upstream main 2>&1 | tee output &&
ec21ac8c 128 test_must_be_empty output
c207e34f
CB
129'
130
f3cce896
ØW
131test_expect_success TTY 'quiet push -u' '
132 ensure_fresh_upstream &&
133
134 test_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output &&
135 test_must_be_empty output
136'
137
e9fcd1e2 138test_done