The eleventh batch
[alt-git.git] / t / t5523-push-upstream.sh
blob4ad36a31e185085c487fd13ea3effd0b01bb51b4
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(the same behavior with--branches)' '
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 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
80 test_expect_success 'push -u HEAD' '
81 git checkout -b headbranch &&
82 git push -u upstream HEAD &&
83 check_config headbranch upstream refs/heads/headbranch
86 test_expect_success TTY 'progress messages go to tty' '
87 ensure_fresh_upstream &&
89 test_terminal git push -u upstream main >out 2>err &&
90 test_grep "Writing objects" err
93 test_expect_success 'progress messages do not go to non-tty' '
94 ensure_fresh_upstream &&
96 # skip progress messages, since stderr is non-tty
97 git push -u upstream main >out 2>err &&
98 test_grep ! "Writing objects" err
101 test_expect_success 'progress messages go to non-tty (forced)' '
102 ensure_fresh_upstream &&
104 # force progress messages to stderr, even though it is non-tty
105 git push -u --progress upstream main >out 2>err &&
106 test_grep "Writing objects" err
109 test_expect_success TTY 'push -q suppresses progress' '
110 ensure_fresh_upstream &&
112 test_terminal git push -u -q upstream main >out 2>err &&
113 test_grep ! "Writing objects" err
116 test_expect_success TTY 'push --no-progress suppresses progress' '
117 ensure_fresh_upstream &&
119 test_terminal git push -u --no-progress upstream main >out 2>err &&
120 test_grep ! "Unpacking objects" err &&
121 test_grep ! "Writing objects" err
124 test_expect_success TTY 'quiet push' '
125 ensure_fresh_upstream &&
127 test_terminal git push --quiet --no-progress upstream main >output 2>&1 &&
128 test_must_be_empty output
131 test_expect_success TTY 'quiet push -u' '
132 ensure_fresh_upstream &&
134 test_terminal git push --quiet -u --no-progress upstream main >output 2>&1 &&
135 test_must_be_empty output
138 test_done