2010-01-17 00:45:31 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='push with --set-upstream'
|
|
|
|
. ./test-lib.sh
|
2010-10-16 22:37:02 +04:00
|
|
|
. "$TEST_DIRECTORY"/lib-terminal.sh
|
2010-01-17 00:45:31 +03:00
|
|
|
|
2010-10-16 22:37:01 +04:00
|
|
|
ensure_fresh_upstream() {
|
|
|
|
rm -rf parent && git init --bare parent
|
|
|
|
}
|
|
|
|
|
2010-01-17 00:45:31 +03:00
|
|
|
test_expect_success 'setup bare parent' '
|
2010-10-16 22:37:01 +04:00
|
|
|
ensure_fresh_upstream &&
|
2010-01-17 00:45:31 +03:00
|
|
|
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 master:master' '
|
|
|
|
git push -u upstream master:master &&
|
|
|
|
check_config master upstream refs/heads/master
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push -u master:other' '
|
|
|
|
git push -u upstream master:other &&
|
|
|
|
check_config master upstream refs/heads/other
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push -u --dry-run master:otherX' '
|
|
|
|
git push -u --dry-run upstream master:otherX &&
|
|
|
|
check_config master upstream refs/heads/other
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push -u master2:master2' '
|
|
|
|
git branch master2 &&
|
|
|
|
git push -u upstream master2:master2 &&
|
|
|
|
check_config master2 upstream refs/heads/master2
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push -u master2:other2' '
|
|
|
|
git push -u upstream master2:other2 &&
|
|
|
|
check_config master2 upstream refs/heads/other2
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push -u :master2' '
|
|
|
|
git push -u upstream :master2 &&
|
|
|
|
check_config master2 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
|
|
|
|
'
|
|
|
|
|
2010-10-16 22:37:02 +04:00
|
|
|
test_expect_success TTY 'progress messages go to tty' '
|
|
|
|
ensure_fresh_upstream &&
|
|
|
|
|
|
|
|
test_terminal git push -u upstream master >out 2>err &&
|
2016-06-17 23:21:07 +03:00
|
|
|
test_i18ngrep "Writing objects" err
|
2010-10-16 22:37:02 +04:00
|
|
|
'
|
|
|
|
|
2010-10-16 22:37:03 +04:00
|
|
|
test_expect_success 'progress messages do not go to non-tty' '
|
2010-10-16 22:37:02 +04:00
|
|
|
ensure_fresh_upstream &&
|
|
|
|
|
|
|
|
# skip progress messages, since stderr is non-tty
|
|
|
|
git push -u upstream master >out 2>err &&
|
2016-06-17 23:21:11 +03:00
|
|
|
test_i18ngrep ! "Writing objects" err
|
2010-10-16 22:37:02 +04:00
|
|
|
'
|
|
|
|
|
2010-10-16 22:37:03 +04:00
|
|
|
test_expect_success 'progress messages go to non-tty (forced)' '
|
2010-10-16 22:37:02 +04:00
|
|
|
ensure_fresh_upstream &&
|
|
|
|
|
|
|
|
# force progress messages to stderr, even though it is non-tty
|
|
|
|
git push -u --progress upstream master >out 2>err &&
|
2016-06-17 23:21:07 +03:00
|
|
|
test_i18ngrep "Writing objects" err
|
2010-10-16 22:37:02 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success TTY 'push -q suppresses progress' '
|
|
|
|
ensure_fresh_upstream &&
|
|
|
|
|
|
|
|
test_terminal git push -u -q upstream master >out 2>err &&
|
2016-06-17 23:21:11 +03:00
|
|
|
test_i18ngrep ! "Writing objects" err
|
2010-10-16 22:37:02 +04:00
|
|
|
'
|
|
|
|
|
2012-02-14 00:17:15 +04:00
|
|
|
test_expect_success TTY 'push --no-progress suppresses progress' '
|
2010-10-16 22:37:02 +04:00
|
|
|
ensure_fresh_upstream &&
|
|
|
|
|
|
|
|
test_terminal git push -u --no-progress upstream master >out 2>err &&
|
2016-06-17 23:21:11 +03:00
|
|
|
test_i18ngrep ! "Unpacking objects" err &&
|
|
|
|
test_i18ngrep ! "Writing objects" err
|
2010-10-16 22:37:02 +04:00
|
|
|
'
|
|
|
|
|
2012-01-09 01:06:20 +04:00
|
|
|
test_expect_success TTY 'quiet push' '
|
|
|
|
ensure_fresh_upstream &&
|
|
|
|
|
|
|
|
test_terminal git push --quiet --no-progress upstream master 2>&1 | tee output &&
|
|
|
|
test_cmp /dev/null output
|
|
|
|
'
|
|
|
|
|
2010-01-17 00:45:31 +03:00
|
|
|
test_done
|