t / t1511-rev-parse-caret.shon commit submodule: add absorb-git-dir function (f6f8586)
   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        git branch modref &&
  23        echo changed! >>a-blob &&
  24        git add -u &&
  25        git commit -m !Exp &&
  26        git branch expref &&
  27        echo changed >>a-blob &&
  28        git add -u &&
  29        git commit -m Changed &&
  30        echo changed-again >>a-blob &&
  31        git add -u &&
  32        git commit -m Changed-again
  33'
  34
  35test_expect_success 'ref^{non-existent}' '
  36        test_must_fail git rev-parse ref^{non-existent}
  37'
  38
  39test_expect_success 'ref^{}' '
  40        git rev-parse ref >expected &&
  41        git rev-parse ref^{} >actual &&
  42        test_cmp expected actual &&
  43        git rev-parse commit-tag^{} >actual &&
  44        test_cmp expected actual
  45'
  46
  47test_expect_success 'ref^{commit}' '
  48        git rev-parse ref >expected &&
  49        git rev-parse ref^{commit} >actual &&
  50        test_cmp expected actual &&
  51        git rev-parse commit-tag^{commit} >actual &&
  52        test_cmp expected actual &&
  53        test_must_fail git rev-parse tree-tag^{commit} &&
  54        test_must_fail git rev-parse blob-tag^{commit}
  55'
  56
  57test_expect_success 'ref^{tree}' '
  58        echo $TREE_SHA1 >expected &&
  59        git rev-parse ref^{tree} >actual &&
  60        test_cmp expected actual &&
  61        git rev-parse commit-tag^{tree} >actual &&
  62        test_cmp expected actual &&
  63        git rev-parse tree-tag^{tree} >actual &&
  64        test_cmp expected actual &&
  65        test_must_fail git rev-parse blob-tag^{tree}
  66'
  67
  68test_expect_success 'ref^{tag}' '
  69        test_must_fail git rev-parse HEAD^{tag} &&
  70        git rev-parse commit-tag >expected &&
  71        git rev-parse commit-tag^{tag} >actual &&
  72        test_cmp expected actual
  73'
  74
  75test_expect_success 'ref^{/.}' '
  76        git rev-parse master >expected &&
  77        git rev-parse master^{/.} >actual &&
  78        test_cmp expected actual
  79'
  80
  81test_expect_success 'ref^{/non-existent}' '
  82        test_must_fail git rev-parse master^{/non-existent}
  83'
  84
  85test_expect_success 'ref^{/Initial}' '
  86        git rev-parse ref >expected &&
  87        git rev-parse master^{/Initial} >actual &&
  88        test_cmp expected actual
  89'
  90
  91test_expect_success 'ref^{/!Exp}' '
  92        test_must_fail git rev-parse master^{/!Exp}
  93'
  94
  95test_expect_success 'ref^{/!}' '
  96        test_must_fail git rev-parse master^{/!}
  97'
  98
  99test_expect_success 'ref^{/!!Exp}' '
 100        git rev-parse expref >expected &&
 101        git rev-parse master^{/!!Exp} >actual &&
 102        test_cmp expected actual
 103'
 104
 105test_expect_success 'ref^{/!-}' '
 106        test_must_fail git rev-parse master^{/!-}
 107'
 108
 109test_expect_success 'ref^{/!-.}' '
 110        test_must_fail git rev-parse master^{/!-.}
 111'
 112
 113test_expect_success 'ref^{/!-non-existent}' '
 114        git rev-parse master >expected &&
 115        git rev-parse master^{/!-non-existent} >actual &&
 116        test_cmp expected actual
 117'
 118
 119test_expect_success 'ref^{/!-Changed}' '
 120        git rev-parse expref >expected &&
 121        git rev-parse master^{/!-Changed} >actual &&
 122        test_cmp expected actual
 123'
 124
 125test_expect_success 'ref^{/!-!Exp}' '
 126        git rev-parse modref >expected &&
 127        git rev-parse expref^{/!-!Exp} >actual &&
 128        test_cmp expected actual
 129'
 130
 131test_done