]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5523-push-upstream.sh
unicode: update the width tables to Unicode 15.1
[thirdparty/git.git] / t / t5523-push-upstream.sh
1 #!/bin/sh
2
3 test_description='push with --set-upstream'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7 TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/lib-terminal.sh
10
11 ensure_fresh_upstream() {
12 rm -rf parent && git init --bare parent
13 }
14
15 test_expect_success 'setup bare parent' '
16 ensure_fresh_upstream &&
17 git remote add upstream parent
18 '
19
20 test_expect_success 'setup local commit' '
21 echo content >file &&
22 git add file &&
23 git commit -m one
24 '
25
26 check_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
33 test_expect_success 'push -u main:main' '
34 git push -u upstream main:main &&
35 check_config main upstream refs/heads/main
36 '
37
38 test_expect_success 'push -u main:other' '
39 git push -u upstream main:other &&
40 check_config main upstream refs/heads/other
41 '
42
43 test_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
46 '
47
48 test_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
52 '
53
54 test_expect_success 'push -u topic_2:other2' '
55 git push -u upstream topic_2:other2 &&
56 check_config topic_2 upstream refs/heads/other2
57 '
58
59 test_expect_success 'push -u :topic_2' '
60 git push -u upstream :topic_2 &&
61 check_config topic_2 upstream refs/heads/other2
62 '
63
64 test_expect_success 'push -u --all' '
65 git branch all1 &&
66 git branch all2 &&
67 git push -u --all &&
68 check_config all1 upstream refs/heads/all1 &&
69 check_config all2 upstream refs/heads/all2
70 '
71
72 test_expect_success 'push -u HEAD' '
73 git checkout -b headbranch &&
74 git push -u upstream HEAD &&
75 check_config headbranch upstream refs/heads/headbranch
76 '
77
78 test_expect_success TTY 'progress messages go to tty' '
79 ensure_fresh_upstream &&
80
81 test_terminal git push -u upstream main >out 2>err &&
82 test_i18ngrep "Writing objects" err
83 '
84
85 test_expect_success 'progress messages do not go to non-tty' '
86 ensure_fresh_upstream &&
87
88 # skip progress messages, since stderr is non-tty
89 git push -u upstream main >out 2>err &&
90 test_i18ngrep ! "Writing objects" err
91 '
92
93 test_expect_success 'progress messages go to non-tty (forced)' '
94 ensure_fresh_upstream &&
95
96 # force progress messages to stderr, even though it is non-tty
97 git push -u --progress upstream main >out 2>err &&
98 test_i18ngrep "Writing objects" err
99 '
100
101 test_expect_success TTY 'push -q suppresses progress' '
102 ensure_fresh_upstream &&
103
104 test_terminal git push -u -q upstream main >out 2>err &&
105 test_i18ngrep ! "Writing objects" err
106 '
107
108 test_expect_success TTY 'push --no-progress suppresses progress' '
109 ensure_fresh_upstream &&
110
111 test_terminal git push -u --no-progress upstream main >out 2>err &&
112 test_i18ngrep ! "Unpacking objects" err &&
113 test_i18ngrep ! "Writing objects" err
114 '
115
116 test_expect_success TTY 'quiet push' '
117 ensure_fresh_upstream &&
118
119 test_terminal git push --quiet --no-progress upstream main 2>&1 | tee output &&
120 test_must_be_empty output
121 '
122
123 test_expect_success TTY 'quiet push -u' '
124 ensure_fresh_upstream &&
125
126 test_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output &&
127 test_must_be_empty output
128 '
129
130 test_done