Merge branch 'jk/unused-post-2.40'
[git.git] / t / t5523-push-upstream.sh
blobc9acc076353a6ae784ced36a4927cda352950521
1 #!/bin/sh
3 test_description='push with --set-upstream'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/lib-terminal.sh
11 ensure_fresh_upstream() {
12 rm -rf parent && git init --bare parent
15 test_expect_success 'setup bare parent' '
16 ensure_fresh_upstream &&
17 git remote add upstream parent
20 test_expect_success 'setup local commit' '
21 echo content >file &&
22 git add file &&
23 git commit -m one
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
33 test_expect_success 'push -u main:main' '
34 git push -u upstream main:main &&
35 check_config main upstream refs/heads/main
38 test_expect_success 'push -u main:other' '
39 git push -u upstream main:other &&
40 check_config main upstream refs/heads/other
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
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
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
59 test_expect_success 'push -u :topic_2' '
60 git push -u upstream :topic_2 &&
61 check_config topic_2 upstream refs/heads/other2
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
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
78 test_expect_success TTY 'progress messages go to tty' '
79 ensure_fresh_upstream &&
81 test_terminal git push -u upstream main >out 2>err &&
82 test_i18ngrep "Writing objects" err
85 test_expect_success 'progress messages do not go to non-tty' '
86 ensure_fresh_upstream &&
88 # skip progress messages, since stderr is non-tty
89 git push -u upstream main >out 2>err &&
90 test_i18ngrep ! "Writing objects" err
93 test_expect_success 'progress messages go to non-tty (forced)' '
94 ensure_fresh_upstream &&
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
101 test_expect_success TTY 'push -q suppresses progress' '
102 ensure_fresh_upstream &&
104 test_terminal git push -u -q upstream main >out 2>err &&
105 test_i18ngrep ! "Writing objects" err
108 test_expect_success TTY 'push --no-progress suppresses progress' '
109 ensure_fresh_upstream &&
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
116 test_expect_success TTY 'quiet push' '
117 ensure_fresh_upstream &&
119 test_terminal git push --quiet --no-progress upstream main 2>&1 | tee output &&
120 test_must_be_empty output
123 test_expect_success TTY 'quiet push -u' '
124 ensure_fresh_upstream &&
126 test_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output &&
127 test_must_be_empty output
130 test_done