3 test_description='push with --set-upstream'
 
   5 . "$TEST_DIRECTORY"/lib-terminal.sh
 
   7 ensure_fresh_upstream() {
 
   8         rm -rf parent && git init --bare parent
 
  11 test_expect_success 'setup bare parent' '
 
  12         ensure_fresh_upstream &&
 
  13         git remote add upstream parent
 
  16 test_expect_success 'setup local commit' '
 
  23         (echo $2; echo $3) >expect.$1
 
  24         (git config branch.$1.remote
 
  25          git config branch.$1.merge) >actual.$1
 
  26         test_cmp expect.$1 actual.$1
 
  29 test_expect_success 'push -u master:master' '
 
  30         git push -u upstream master:master &&
 
  31         check_config master upstream refs/heads/master
 
  34 test_expect_success 'push -u master:other' '
 
  35         git push -u upstream master:other &&
 
  36         check_config master upstream refs/heads/other
 
  39 test_expect_success 'push -u --dry-run master:otherX' '
 
  40         git push -u --dry-run upstream master:otherX &&
 
  41         check_config master upstream refs/heads/other
 
  44 test_expect_success 'push -u master2:master2' '
 
  46         git push -u upstream master2:master2 &&
 
  47         check_config master2 upstream refs/heads/master2
 
  50 test_expect_success 'push -u master2:other2' '
 
  51         git push -u upstream master2:other2 &&
 
  52         check_config master2 upstream refs/heads/other2
 
  55 test_expect_success 'push -u :master2' '
 
  56         git push -u upstream :master2 &&
 
  57         check_config master2 upstream refs/heads/other2
 
  60 test_expect_success 'push -u --all' '
 
  64         check_config all1 upstream refs/heads/all1 &&
 
  65         check_config all2 upstream refs/heads/all2
 
  68 test_expect_success 'push -u HEAD' '
 
  69         git checkout -b headbranch &&
 
  70         git push -u upstream HEAD &&
 
  71         check_config headbranch upstream refs/heads/headbranch
 
  74 test_expect_success TTY 'progress messages go to tty' '
 
  75         ensure_fresh_upstream &&
 
  77         test_terminal git push -u upstream master >out 2>err &&
 
  78         grep "Writing objects" err
 
  81 test_expect_success 'progress messages do not go to non-tty' '
 
  82         ensure_fresh_upstream &&
 
  84         # skip progress messages, since stderr is non-tty
 
  85         git push -u upstream master >out 2>err &&
 
  86         ! grep "Writing objects" err
 
  89 test_expect_success 'progress messages go to non-tty (forced)' '
 
  90         ensure_fresh_upstream &&
 
  92         # force progress messages to stderr, even though it is non-tty
 
  93         git push -u --progress upstream master >out 2>err &&
 
  94         grep "Writing objects" err
 
  97 test_expect_success TTY 'push -q suppresses progress' '
 
  98         ensure_fresh_upstream &&
 
 100         test_terminal git push -u -q upstream master >out 2>err &&
 
 101         ! grep "Writing objects" err
 
 104 test_expect_failure TTY 'push --no-progress suppresses progress' '
 
 105         ensure_fresh_upstream &&
 
 107         test_terminal git push -u --no-progress upstream master >out 2>err &&
 
 108         ! grep "Writing objects" err