The fifth batch
[git.git] / t / t5523-push-upstream.sh
blob9fbe7f784d234af76f5616f0816f29c64bd0d379
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-lib.sh
8 . "$TEST_DIRECTORY"/lib-terminal.sh
10 ensure_fresh_upstream() {
11 rm -rf parent && git init --bare parent
14 test_expect_success 'setup bare parent' '
15 ensure_fresh_upstream &&
16 git remote add upstream parent
19 test_expect_success 'setup local commit' '
20 echo content >file &&
21 git add file &&
22 git commit -m one
25 check_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
32 test_expect_success 'push -u main:main' '
33 git push -u upstream main:main &&
34 check_config main upstream refs/heads/main
37 test_expect_success 'push -u main:other' '
38 git push -u upstream main:other &&
39 check_config main upstream refs/heads/other
42 test_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
47 test_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
53 test_expect_success 'push -u topic_2:other2' '
54 git push -u upstream topic_2:other2 &&
55 check_config topic_2 upstream refs/heads/other2
58 test_expect_success 'push -u :topic_2' '
59 git push -u upstream :topic_2 &&
60 check_config topic_2 upstream refs/heads/other2
63 test_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
71 test_expect_success 'push -u HEAD' '
72 git checkout -b headbranch &&
73 git push -u upstream HEAD &&
74 check_config headbranch upstream refs/heads/headbranch
77 test_expect_success TTY 'progress messages go to tty' '
78 ensure_fresh_upstream &&
80 test_terminal git push -u upstream main >out 2>err &&
81 test_i18ngrep "Writing objects" err
84 test_expect_success 'progress messages do not go to non-tty' '
85 ensure_fresh_upstream &&
87 # skip progress messages, since stderr is non-tty
88 git push -u upstream main >out 2>err &&
89 test_i18ngrep ! "Writing objects" err
92 test_expect_success 'progress messages go to non-tty (forced)' '
93 ensure_fresh_upstream &&
95 # force progress messages to stderr, even though it is non-tty
96 git push -u --progress upstream main >out 2>err &&
97 test_i18ngrep "Writing objects" err
100 test_expect_success TTY 'push -q suppresses progress' '
101 ensure_fresh_upstream &&
103 test_terminal git push -u -q upstream main >out 2>err &&
104 test_i18ngrep ! "Writing objects" err
107 test_expect_success TTY 'push --no-progress suppresses progress' '
108 ensure_fresh_upstream &&
110 test_terminal git push -u --no-progress upstream main >out 2>err &&
111 test_i18ngrep ! "Unpacking objects" err &&
112 test_i18ngrep ! "Writing objects" err
115 test_expect_success TTY 'quiet push' '
116 ensure_fresh_upstream &&
118 test_terminal git push --quiet --no-progress upstream main 2>&1 | tee output &&
119 test_must_be_empty output
122 test_done