t / t1514-rev-parse-push.shon commit promisor-remote: parse remote.*.partialclonefilter (fa3d1b6)
   1#!/bin/sh
   2
   3test_description='test <branch>@{push} syntax'
   4. ./test-lib.sh
   5
   6resolve () {
   7        echo "$2" >expect &&
   8        git rev-parse --symbolic-full-name "$1" >actual &&
   9        test_cmp expect actual
  10}
  11
  12test_expect_success 'setup' '
  13        git init --bare parent.git &&
  14        git init --bare other.git &&
  15        git remote add origin parent.git &&
  16        git remote add other other.git &&
  17        test_commit base &&
  18        git push origin HEAD &&
  19        git branch --set-upstream-to=origin/master master &&
  20        git branch --track topic origin/master &&
  21        git push origin topic &&
  22        git push other topic
  23'
  24
  25test_expect_success '@{push} with default=nothing' '
  26        test_config push.default nothing &&
  27        test_must_fail git rev-parse master@{push} &&
  28        test_must_fail git rev-parse master@{PUSH} &&
  29        test_must_fail git rev-parse master@{PuSH}
  30'
  31
  32test_expect_success '@{push} with default=simple' '
  33        test_config push.default simple &&
  34        resolve master@{push} refs/remotes/origin/master &&
  35        resolve master@{PUSH} refs/remotes/origin/master &&
  36        resolve master@{pUSh} refs/remotes/origin/master
  37'
  38
  39test_expect_success 'triangular @{push} fails with default=simple' '
  40        test_config push.default simple &&
  41        test_must_fail git rev-parse topic@{push}
  42'
  43
  44test_expect_success '@{push} with default=current' '
  45        test_config push.default current &&
  46        resolve topic@{push} refs/remotes/origin/topic
  47'
  48
  49test_expect_success '@{push} with default=matching' '
  50        test_config push.default matching &&
  51        resolve topic@{push} refs/remotes/origin/topic
  52'
  53
  54test_expect_success '@{push} with pushremote defined' '
  55        test_config push.default current &&
  56        test_config branch.topic.pushremote other &&
  57        resolve topic@{push} refs/remotes/other/topic
  58'
  59
  60test_expect_success '@{push} with push refspecs' '
  61        test_config push.default nothing &&
  62        test_config remote.origin.push refs/heads/*:refs/heads/magic/* &&
  63        git push &&
  64        resolve topic@{push} refs/remotes/origin/magic/topic
  65'
  66
  67test_expect_success 'resolving @{push} fails with a detached HEAD' '
  68        git checkout HEAD^0 &&
  69        test_when_finished "git checkout -" &&
  70        test_must_fail git rev-parse @{push}
  71'
  72
  73test_done