t / t1700-split-index.shon commit t/Makefile: add a rule to re-run previously-failed tests (93a04bb)
   1#!/bin/sh
   2
   3test_description='split index mode tests'
   4
   5. ./test-lib.sh
   6
   7# We need total control of index splitting here
   8sane_unset GIT_TEST_SPLIT_INDEX
   9
  10test_expect_success 'enable split index' '
  11        git update-index --split-index &&
  12        test-dump-split-index .git/index >actual &&
  13        indexversion=$(test-index-version <.git/index) &&
  14        if test "$indexversion" = "4"
  15        then
  16                own=432ef4b63f32193984f339431fd50ca796493569
  17                base=508851a7f0dfa8691e9f69c7f055865389012491
  18        else
  19                own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
  20                base=39d890139ee5356c7ef572216cebcd27aa41f9df
  21        fi &&
  22        cat >expect <<EOF &&
  23own $own
  24base $base
  25replacements:
  26deletions:
  27EOF
  28        test_cmp expect actual
  29'
  30
  31test_expect_success 'add one file' '
  32        : >one &&
  33        git update-index --add one &&
  34        git ls-files --stage >ls-files.actual &&
  35        cat >ls-files.expect <<EOF &&
  36100644 $EMPTY_BLOB 0    one
  37EOF
  38        test_cmp ls-files.expect ls-files.actual &&
  39
  40        test-dump-split-index .git/index | sed "/^own/d" >actual &&
  41        cat >expect <<EOF &&
  42base $base
  43100644 $EMPTY_BLOB 0    one
  44replacements:
  45deletions:
  46EOF
  47        test_cmp expect actual
  48'
  49
  50test_expect_success 'disable split index' '
  51        git update-index --no-split-index &&
  52        git ls-files --stage >ls-files.actual &&
  53        cat >ls-files.expect <<EOF &&
  54100644 $EMPTY_BLOB 0    one
  55EOF
  56        test_cmp ls-files.expect ls-files.actual &&
  57
  58        BASE=$(test-dump-split-index .git/index | grep "^own" | sed "s/own/base/") &&
  59        test-dump-split-index .git/index | sed "/^own/d" >actual &&
  60        cat >expect <<EOF &&
  61not a split index
  62EOF
  63        test_cmp expect actual
  64'
  65
  66test_expect_success 'enable split index again, "one" now belongs to base index"' '
  67        git update-index --split-index &&
  68        git ls-files --stage >ls-files.actual &&
  69        cat >ls-files.expect <<EOF &&
  70100644 $EMPTY_BLOB 0    one
  71EOF
  72        test_cmp ls-files.expect ls-files.actual &&
  73
  74        test-dump-split-index .git/index | sed "/^own/d" >actual &&
  75        cat >expect <<EOF &&
  76$BASE
  77replacements:
  78deletions:
  79EOF
  80        test_cmp expect actual
  81'
  82
  83test_expect_success 'modify original file, base index untouched' '
  84        echo modified >one &&
  85        git update-index one &&
  86        git ls-files --stage >ls-files.actual &&
  87        cat >ls-files.expect <<EOF &&
  88100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0       one
  89EOF
  90        test_cmp ls-files.expect ls-files.actual &&
  91
  92        test-dump-split-index .git/index | sed "/^own/d" >actual &&
  93        q_to_tab >expect <<EOF &&
  94$BASE
  95100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
  96replacements: 0
  97deletions:
  98EOF
  99        test_cmp expect actual
 100'
 101
 102test_expect_success 'add another file, which stays index' '
 103        : >two &&
 104        git update-index --add two &&
 105        git ls-files --stage >ls-files.actual &&
 106        cat >ls-files.expect <<EOF &&
 107100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0       one
 108100644 $EMPTY_BLOB 0    two
 109EOF
 110        test_cmp ls-files.expect ls-files.actual &&
 111
 112        test-dump-split-index .git/index | sed "/^own/d" >actual &&
 113        q_to_tab >expect <<EOF &&
 114$BASE
 115100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
 116100644 $EMPTY_BLOB 0    two
 117replacements: 0
 118deletions:
 119EOF
 120        test_cmp expect actual
 121'
 122
 123test_expect_success 'remove file not in base index' '
 124        git update-index --force-remove two &&
 125        git ls-files --stage >ls-files.actual &&
 126        cat >ls-files.expect <<EOF &&
 127100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0       one
 128EOF
 129        test_cmp ls-files.expect ls-files.actual &&
 130
 131        test-dump-split-index .git/index | sed "/^own/d" >actual &&
 132        q_to_tab >expect <<EOF &&
 133$BASE
 134100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
 135replacements: 0
 136deletions:
 137EOF
 138        test_cmp expect actual
 139'
 140
 141test_expect_success 'remove file in base index' '
 142        git update-index --force-remove one &&
 143        git ls-files --stage >ls-files.actual &&
 144        cat >ls-files.expect <<EOF &&
 145EOF
 146        test_cmp ls-files.expect ls-files.actual &&
 147
 148        test-dump-split-index .git/index | sed "/^own/d" >actual &&
 149        cat >expect <<EOF &&
 150$BASE
 151replacements:
 152deletions: 0
 153EOF
 154        test_cmp expect actual
 155'
 156
 157test_expect_success 'add original file back' '
 158        : >one &&
 159        git update-index --add one &&
 160        git ls-files --stage >ls-files.actual &&
 161        cat >ls-files.expect <<EOF &&
 162100644 $EMPTY_BLOB 0    one
 163EOF
 164        test_cmp ls-files.expect ls-files.actual &&
 165
 166        test-dump-split-index .git/index | sed "/^own/d" >actual &&
 167        cat >expect <<EOF &&
 168$BASE
 169100644 $EMPTY_BLOB 0    one
 170replacements:
 171deletions: 0
 172EOF
 173        test_cmp expect actual
 174'
 175
 176test_expect_success 'add new file' '
 177        : >two &&
 178        git update-index --add two &&
 179        git ls-files --stage >actual &&
 180        cat >expect <<EOF &&
 181100644 $EMPTY_BLOB 0    one
 182100644 $EMPTY_BLOB 0    two
 183EOF
 184        test_cmp expect actual
 185'
 186
 187test_expect_success 'unify index, two files remain' '
 188        git update-index --no-split-index &&
 189        git ls-files --stage >ls-files.actual &&
 190        cat >ls-files.expect <<EOF &&
 191100644 $EMPTY_BLOB 0    one
 192100644 $EMPTY_BLOB 0    two
 193EOF
 194        test_cmp ls-files.expect ls-files.actual &&
 195
 196        test-dump-split-index .git/index | sed "/^own/d" >actual &&
 197        cat >expect <<EOF &&
 198not a split index
 199EOF
 200        test_cmp expect actual
 201'
 202
 203test_done