mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
![Johannes Schindelin](/assets/img/avatar_default.png)
Carefully excluding t5526, which sees independent development elsewhere at the time of writing, we use `main` as the default branch name in t55[23]*. This trick was performed via $ (cd t && sed -i -e 's/master/main/g' -e 's/MASTER/MAIN/g' \ -e 's/Master/Main/g' -e 's/naster/nain/g' -- \ t55[23]*.sh && git checkout HEAD -- t5526\*) Note that t5533 contains a variation of the name `master` (`naster`) that we rename here, too. This commit allows us to define `GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main` for that range of tests. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
123 lines
3 KiB
Bash
Executable file
123 lines
3 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='push with --set-upstream'
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
. ./test-lib.sh
|
|
. "$TEST_DIRECTORY"/lib-terminal.sh
|
|
|
|
ensure_fresh_upstream() {
|
|
rm -rf parent && git init --bare parent
|
|
}
|
|
|
|
test_expect_success 'setup bare parent' '
|
|
ensure_fresh_upstream &&
|
|
git remote add upstream parent
|
|
'
|
|
|
|
test_expect_success 'setup local commit' '
|
|
echo content >file &&
|
|
git add file &&
|
|
git commit -m one
|
|
'
|
|
|
|
check_config() {
|
|
(echo $2; echo $3) >expect.$1
|
|
(git config branch.$1.remote
|
|
git config branch.$1.merge) >actual.$1
|
|
test_cmp expect.$1 actual.$1
|
|
}
|
|
|
|
test_expect_success 'push -u main:main' '
|
|
git push -u upstream main:main &&
|
|
check_config main upstream refs/heads/main
|
|
'
|
|
|
|
test_expect_success 'push -u main:other' '
|
|
git push -u upstream main:other &&
|
|
check_config main upstream refs/heads/other
|
|
'
|
|
|
|
test_expect_success 'push -u --dry-run main:otherX' '
|
|
git push -u --dry-run upstream main:otherX &&
|
|
check_config main upstream refs/heads/other
|
|
'
|
|
|
|
test_expect_success 'push -u topic_2:topic_2' '
|
|
git branch topic_2 &&
|
|
git push -u upstream topic_2:topic_2 &&
|
|
check_config topic_2 upstream refs/heads/topic_2
|
|
'
|
|
|
|
test_expect_success 'push -u topic_2:other2' '
|
|
git push -u upstream topic_2:other2 &&
|
|
check_config topic_2 upstream refs/heads/other2
|
|
'
|
|
|
|
test_expect_success 'push -u :topic_2' '
|
|
git push -u upstream :topic_2 &&
|
|
check_config topic_2 upstream refs/heads/other2
|
|
'
|
|
|
|
test_expect_success 'push -u --all' '
|
|
git branch all1 &&
|
|
git branch all2 &&
|
|
git push -u --all &&
|
|
check_config all1 upstream refs/heads/all1 &&
|
|
check_config all2 upstream refs/heads/all2
|
|
'
|
|
|
|
test_expect_success 'push -u HEAD' '
|
|
git checkout -b headbranch &&
|
|
git push -u upstream HEAD &&
|
|
check_config headbranch upstream refs/heads/headbranch
|
|
'
|
|
|
|
test_expect_success TTY 'progress messages go to tty' '
|
|
ensure_fresh_upstream &&
|
|
|
|
test_terminal git push -u upstream main >out 2>err &&
|
|
test_i18ngrep "Writing objects" err
|
|
'
|
|
|
|
test_expect_success 'progress messages do not go to non-tty' '
|
|
ensure_fresh_upstream &&
|
|
|
|
# skip progress messages, since stderr is non-tty
|
|
git push -u upstream main >out 2>err &&
|
|
test_i18ngrep ! "Writing objects" err
|
|
'
|
|
|
|
test_expect_success 'progress messages go to non-tty (forced)' '
|
|
ensure_fresh_upstream &&
|
|
|
|
# force progress messages to stderr, even though it is non-tty
|
|
git push -u --progress upstream main >out 2>err &&
|
|
test_i18ngrep "Writing objects" err
|
|
'
|
|
|
|
test_expect_success TTY 'push -q suppresses progress' '
|
|
ensure_fresh_upstream &&
|
|
|
|
test_terminal git push -u -q upstream main >out 2>err &&
|
|
test_i18ngrep ! "Writing objects" err
|
|
'
|
|
|
|
test_expect_success TTY 'push --no-progress suppresses progress' '
|
|
ensure_fresh_upstream &&
|
|
|
|
test_terminal git push -u --no-progress upstream main >out 2>err &&
|
|
test_i18ngrep ! "Unpacking objects" err &&
|
|
test_i18ngrep ! "Writing objects" err
|
|
'
|
|
|
|
test_expect_success TTY 'quiet push' '
|
|
ensure_fresh_upstream &&
|
|
|
|
test_terminal git push --quiet --no-progress upstream main 2>&1 | tee output &&
|
|
test_must_be_empty output
|
|
'
|
|
|
|
test_done
|