]>
Commit | Line | Data |
---|---|---|
e9fcd1e2 IL |
1 | #!/bin/sh |
2 | ||
3 | test_description='push with --set-upstream' | |
3ac8f630 | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
6 | ||
e9fcd1e2 | 7 | . ./test-lib.sh |
8ac3ed27 | 8 | . "$TEST_DIRECTORY"/lib-terminal.sh |
e9fcd1e2 | 9 | |
2d59ced1 TRC |
10 | ensure_fresh_upstream() { |
11 | rm -rf parent && git init --bare parent | |
12 | } | |
13 | ||
e9fcd1e2 | 14 | test_expect_success 'setup bare parent' ' |
2d59ced1 | 15 | ensure_fresh_upstream && |
e9fcd1e2 IL |
16 | git remote add upstream parent |
17 | ' | |
18 | ||
19 | test_expect_success 'setup local commit' ' | |
20 | echo content >file && | |
21 | git add file && | |
22 | git commit -m one | |
23 | ' | |
24 | ||
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 | |
30 | } | |
31 | ||
3ac8f630 JS |
32 | test_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 |
37 | test_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 |
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 | |
e9fcd1e2 IL |
45 | ' |
46 | ||
b6211b89 JS |
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 | |
e9fcd1e2 IL |
51 | ' |
52 | ||
b6211b89 JS |
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 | |
e9fcd1e2 IL |
56 | ' |
57 | ||
b6211b89 JS |
58 | test_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 | ||
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 | |
69 | ' | |
70 | ||
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 | |
75 | ' | |
76 | ||
8ac3ed27 TRC |
77 | test_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 | 84 | test_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 | 92 | test_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 | ||
100 | test_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 | 107 | test_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 |
115 | test_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 |
122 | test_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 | 129 | test_done |