t / t1511-rev-parse-caret.shon commit Merge branch 'mo/perl-bidi-pipe-envfix' (8e949a4)
   1#!/bin/sh
   2
   3test_description='tests for ref^{stuff}'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'setup' '
   8        echo blob >a-blob &&
   9        git tag -a -m blob blob-tag `git hash-object -w a-blob`
  10        mkdir a-tree &&
  11        echo moreblobs >a-tree/another-blob &&
  12        git add . &&
  13        TREE_SHA1=`git write-tree` &&
  14        git tag -a -m tree tree-tag "$TREE_SHA1" &&
  15        git commit -m Initial &&
  16        git tag -a -m commit commit-tag &&
  17        git branch ref &&
  18        git checkout master &&
  19        echo modified >>a-blob &&
  20        git add -u &&
  21        git commit -m Modified
  22'
  23
  24test_expect_success 'ref^{non-existent}' '
  25        test_must_fail git rev-parse ref^{non-existent}
  26'
  27
  28test_expect_success 'ref^{}' '
  29        git rev-parse ref >expected &&
  30        git rev-parse ref^{} >actual &&
  31        test_cmp expected actual &&
  32        git rev-parse commit-tag^{} >actual &&
  33        test_cmp expected actual
  34'
  35
  36test_expect_success 'ref^{commit}' '
  37        git rev-parse ref >expected &&
  38        git rev-parse ref^{commit} >actual &&
  39        test_cmp expected actual &&
  40        git rev-parse commit-tag^{commit} >actual &&
  41        test_cmp expected actual &&
  42        test_must_fail git rev-parse tree-tag^{commit} &&
  43        test_must_fail git rev-parse blob-tag^{commit}
  44'
  45
  46test_expect_success 'ref^{tree}' '
  47        echo $TREE_SHA1 >expected &&
  48        git rev-parse ref^{tree} >actual &&
  49        test_cmp expected actual &&
  50        git rev-parse commit-tag^{tree} >actual &&
  51        test_cmp expected actual &&
  52        git rev-parse tree-tag^{tree} >actual &&
  53        test_cmp expected actual &&
  54        test_must_fail git rev-parse blob-tag^{tree}
  55'
  56
  57test_expect_success 'ref^{/.}' '
  58        git rev-parse master >expected &&
  59        git rev-parse master^{/.} >actual &&
  60        test_cmp expected actual
  61'
  62
  63test_expect_success 'ref^{/non-existent}' '
  64        test_must_fail git rev-parse master^{/non-existent}
  65'
  66
  67test_expect_success 'ref^{/Initial}' '
  68        git rev-parse ref >expected &&
  69        git rev-parse master^{/Initial} >actual &&
  70        test_cmp expected actual
  71'
  72
  73test_done