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