t / t5528-push-default.shon commit Merge branch 'jc/push-upstream-sanity' (27da1cf)
   1#!/bin/sh
   2
   3test_description='check various push.default settings'
   4. ./test-lib.sh
   5
   6test_expect_success 'setup bare remotes' '
   7        git init --bare repo1 &&
   8        git remote add parent1 repo1 &&
   9        git init --bare repo2 &&
  10        git remote add parent2 repo2 &&
  11        test_commit one &&
  12        git push parent1 HEAD &&
  13        git push parent2 HEAD
  14'
  15
  16test_expect_success '"upstream" pushes to configured upstream' '
  17        git checkout master &&
  18        test_config branch.master.remote parent1 &&
  19        test_config branch.master.merge refs/heads/foo &&
  20        test_config push.default upstream &&
  21        test_commit two &&
  22        git push &&
  23        echo two >expect &&
  24        git --git-dir=repo1 log -1 --format=%s foo >actual &&
  25        test_cmp expect actual
  26'
  27
  28test_expect_success '"upstream" does not push on unconfigured remote' '
  29        git checkout master &&
  30        test_unconfig branch.master.remote &&
  31        test_config push.default upstream &&
  32        test_commit three &&
  33        test_must_fail git push
  34'
  35
  36test_expect_success '"upstream" does not push on unconfigured branch' '
  37        git checkout master &&
  38        test_config branch.master.remote parent1 &&
  39        test_unconfig branch.master.merge &&
  40        test_config push.default upstream
  41        test_commit four &&
  42        test_must_fail git push
  43'
  44
  45test_expect_success '"upstream" does not push when remotes do not match' '
  46        git checkout master &&
  47        test_config branch.master.remote parent1 &&
  48        test_config branch.master.merge refs/heads/foo &&
  49        test_config push.default upstream &&
  50        test_commit five &&
  51        test_must_fail git push parent2
  52'
  53
  54test_done