t / t1405-main-ref-store.shon commit cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch (f8adbec)
   1#!/bin/sh
   2
   3test_description='test main ref store api'
   4
   5. ./test-lib.sh
   6
   7RUN="test-tool ref-store main"
   8
   9test_expect_success 'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' '
  10        test_commit one &&
  11        N=`find .git/refs -type f | wc -l` &&
  12        test "$N" != 0 &&
  13        $RUN pack-refs 3 &&
  14        N=`find .git/refs -type f | wc -l`
  15'
  16
  17test_expect_success 'peel_ref(new-tag)' '
  18        git rev-parse HEAD >expected &&
  19        git tag -a -m new-tag new-tag HEAD &&
  20        $RUN peel-ref refs/tags/new-tag >actual &&
  21        test_cmp expected actual
  22'
  23
  24test_expect_success 'create_symref(FOO, refs/heads/master)' '
  25        $RUN create-symref FOO refs/heads/master nothing &&
  26        echo refs/heads/master >expected &&
  27        git symbolic-ref FOO >actual &&
  28        test_cmp expected actual
  29'
  30
  31test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' '
  32        git rev-parse FOO -- &&
  33        git rev-parse refs/tags/new-tag -- &&
  34        $RUN delete-refs 0 nothing FOO refs/tags/new-tag &&
  35        test_must_fail git rev-parse FOO -- &&
  36        test_must_fail git rev-parse refs/tags/new-tag --
  37'
  38
  39test_expect_success 'rename_refs(master, new-master)' '
  40        git rev-parse master >expected &&
  41        $RUN rename-ref refs/heads/master refs/heads/new-master &&
  42        git rev-parse new-master >actual &&
  43        test_cmp expected actual &&
  44        test_commit recreate-master
  45'
  46
  47test_expect_success 'for_each_ref(refs/heads/)' '
  48        $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
  49        cat >expected <<-\EOF &&
  50        master 0x0
  51        new-master 0x0
  52        EOF
  53        test_cmp expected actual
  54'
  55
  56test_expect_success 'for_each_ref() is sorted' '
  57        $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
  58        sort actual > expected &&
  59        test_cmp expected actual
  60'
  61
  62test_expect_success 'resolve_ref(new-master)' '
  63        SHA1=`git rev-parse new-master` &&
  64        echo "$SHA1 refs/heads/new-master 0x0" >expected &&
  65        $RUN resolve-ref refs/heads/new-master 0 >actual &&
  66        test_cmp expected actual
  67'
  68
  69test_expect_success 'verify_ref(new-master)' '
  70        $RUN verify-ref refs/heads/new-master
  71'
  72
  73test_expect_success 'for_each_reflog()' '
  74        $RUN for-each-reflog | sort -k2 | cut -d" " -f 2- >actual &&
  75        cat >expected <<-\EOF &&
  76        HEAD 0x1
  77        refs/heads/master 0x0
  78        refs/heads/new-master 0x0
  79        EOF
  80        test_cmp expected actual
  81'
  82
  83test_expect_success 'for_each_reflog_ent()' '
  84        $RUN for-each-reflog-ent HEAD >actual &&
  85        head -n1 actual | grep one &&
  86        tail -n2 actual | head -n1 | grep recreate-master
  87'
  88
  89test_expect_success 'for_each_reflog_ent_reverse()' '
  90        $RUN for-each-reflog-ent-reverse HEAD >actual &&
  91        head -n1 actual | grep recreate-master &&
  92        tail -n2 actual | head -n1 | grep one
  93'
  94
  95test_expect_success 'reflog_exists(HEAD)' '
  96        $RUN reflog-exists HEAD
  97'
  98
  99test_expect_success 'delete_reflog(HEAD)' '
 100        $RUN delete-reflog HEAD &&
 101        ! test -f .git/logs/HEAD
 102'
 103
 104test_expect_success 'create-reflog(HEAD)' '
 105        $RUN create-reflog HEAD 1 &&
 106        test -f .git/logs/HEAD
 107'
 108
 109test_expect_success 'delete_ref(refs/heads/foo)' '
 110        git checkout -b foo &&
 111        FOO_SHA1=`git rev-parse foo` &&
 112        git checkout --detach &&
 113        test_commit bar-commit &&
 114        git checkout -b bar &&
 115        BAR_SHA1=`git rev-parse bar` &&
 116        $RUN update-ref updating refs/heads/foo $BAR_SHA1 $FOO_SHA1 0 &&
 117        echo $BAR_SHA1 >expected &&
 118        git rev-parse refs/heads/foo >actual &&
 119        test_cmp expected actual
 120'
 121
 122test_expect_success 'delete_ref(refs/heads/foo)' '
 123        SHA1=`git rev-parse foo` &&
 124        git checkout --detach &&
 125        $RUN delete-ref msg refs/heads/foo $SHA1 0 &&
 126        test_must_fail git rev-parse refs/heads/foo --
 127'
 128
 129test_done