#!/bin/sh global test_description := ''push with --set-upstream'' source ./test-lib.sh source "$TEST_DIRECTORY"/lib-terminal.sh proc 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 ' proc check_config { shell {echo $2; echo $3} >expect.$1 shell {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 ' test_expect_success TTY 'progress messages go to tty' ' ensure_fresh_upstream && test_terminal git push -u upstream master >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 master >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 master >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 master >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 master >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 master 2>&1 | tee output && test_cmp /dev/null output ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"push with --set-upstream">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-terminal.sh)}) (FuncDef name: ensure_fresh_upstream body: (BraceGroup children: [ (AndOr children: [(C {(rm)} {(-rf)} {(parent)}) (C {(git)} {(init)} {(--bare)} {(parent)})] op_id: Op_DAmp ) ] spids: [25] ) spids: [21 24] ) (C {(test_expect_success)} {(SQ <"setup bare parent">)} {(SQ <"\n"> <"\tensure_fresh_upstream &&\n"> <"\tgit remote add upstream parent\n">)} ) (C {(test_expect_success)} {(SQ <"setup local commit">)} {(SQ <"\n"> <"\techo content >file &&\n"> <"\tgit add file &&\n"> <"\tgit commit -m one\n">)} ) (FuncDef name: check_config body: (BraceGroup children: [ (Subshell child: (CommandList children: [ (Sentence child: (C {(echo)} {($ VSub_Number "$2")}) terminator: ) (C {(echo)} {($ VSub_Number "$3")}) ] ) redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(expect.) ($ VSub_Number "$1")} spids: [92] ) ] spids: [81 90] ) (Subshell child: (CommandList children: [ (C {(git)} {(config)} {(branch.) ($ VSub_Number "$1") (.remote)}) (C {(git)} {(config)} {(branch.) ($ VSub_Number "$1") (.merge)}) ] ) redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(actual.) ($ VSub_Number "$1")} spids: [116] ) ] spids: [97 114] ) (C {(test_cmp)} {(expect.) ($ VSub_Number "$1")} {(actual.) ($ VSub_Number "$1")}) ] spids: [78] ) spids: [74 77] ) (C {(test_expect_success)} {(SQ <"push -u master:master">)} { (SQ <"\n"> <"\tgit push -u upstream master:master &&\n"> <"\tcheck_config master upstream refs/heads/master\n"> ) } ) (C {(test_expect_success)} {(SQ <"push -u master:other">)} { (SQ <"\n"> <"\tgit push -u upstream master:other &&\n"> <"\tcheck_config master upstream refs/heads/other\n"> ) } ) (C {(test_expect_success)} {(SQ <"push -u --dry-run master:otherX">)} { (SQ <"\n"> <"\tgit push -u --dry-run upstream master:otherX &&\n"> <"\tcheck_config master upstream refs/heads/other\n"> ) } ) (C {(test_expect_success)} {(SQ <"push -u master2:master2">)} { (SQ <"\n"> <"\tgit branch master2 &&\n"> <"\tgit push -u upstream master2:master2 &&\n"> <"\tcheck_config master2 upstream refs/heads/master2\n"> ) } ) (C {(test_expect_success)} {(SQ <"push -u master2:other2">)} { (SQ <"\n"> <"\tgit push -u upstream master2:other2 &&\n"> <"\tcheck_config master2 upstream refs/heads/other2\n"> ) } ) (C {(test_expect_success)} {(SQ <"push -u :master2">)} { (SQ <"\n"> <"\tgit push -u upstream :master2 &&\n"> <"\tcheck_config master2 upstream refs/heads/other2\n"> ) } ) (C {(test_expect_success)} {(SQ <"push -u --all">)} { (SQ <"\n"> <"\tgit branch all1 &&\n"> <"\tgit branch all2 &&\n"> <"\tgit push -u --all &&\n"> <"\tcheck_config all1 upstream refs/heads/all1 &&\n"> <"\tcheck_config all2 upstream refs/heads/all2\n"> ) } ) (C {(test_expect_success)} {(SQ <"push -u HEAD">)} { (SQ <"\n"> <"\tgit checkout -b headbranch &&\n"> <"\tgit push -u upstream HEAD &&\n"> <"\tcheck_config headbranch upstream refs/heads/headbranch\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"progress messages go to tty">)} { (SQ <"\n"> <"\tensure_fresh_upstream &&\n"> <"\n"> <"\ttest_terminal git push -u upstream master >out 2>err &&\n"> <"\ttest_i18ngrep \"Writing objects\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"progress messages do not go to non-tty">)} { (SQ <"\n"> <"\tensure_fresh_upstream &&\n"> <"\n"> <"\t# skip progress messages, since stderr is non-tty\n"> <"\tgit push -u upstream master >out 2>err &&\n"> <"\ttest_i18ngrep ! \"Writing objects\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"progress messages go to non-tty (forced)">)} { (SQ <"\n"> <"\tensure_fresh_upstream &&\n"> <"\n"> <"\t# force progress messages to stderr, even though it is non-tty\n"> <"\tgit push -u --progress upstream master >out 2>err &&\n"> <"\ttest_i18ngrep \"Writing objects\" err\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"push -q suppresses progress">)} { (SQ <"\n"> <"\tensure_fresh_upstream &&\n"> <"\n"> <"\ttest_terminal git push -u -q upstream master >out 2>err &&\n"> <"\ttest_i18ngrep ! \"Writing objects\" err\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"push --no-progress suppresses progress">)} { (SQ <"\n"> <"\tensure_fresh_upstream &&\n"> <"\n"> <"\ttest_terminal git push -u --no-progress upstream master >out 2>err &&\n"> <"\ttest_i18ngrep ! \"Unpacking objects\" err &&\n"> <"\ttest_i18ngrep ! \"Writing objects\" err\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"quiet push">)} { (SQ <"\n"> <"\tensure_fresh_upstream &&\n"> <"\n"> <"\ttest_terminal git push --quiet --no-progress upstream master 2>&1 | tee output &&\n"> <"\ttest_cmp /dev/null output\n"> ) } ) (C {(test_done)}) ] )