t / t1005-read-tree-reset.shon commit Merge branch 'db/delta-applier' into svn-fe (a8d3d26)
   1#!/bin/sh
   2
   3test_description='read-tree -u --reset'
   4
   5. ./test-lib.sh
   6
   7# two-tree test
   8
   9test_expect_success 'setup' '
  10  git init &&
  11  mkdir df &&
  12  echo content >df/file &&
  13  git add df/file &&
  14  git commit -m one &&
  15  git ls-files >expect &&
  16  rm -rf df &&
  17  echo content >df &&
  18  git add df &&
  19  echo content >new &&
  20  git add new &&
  21  git commit -m two
  22'
  23
  24test_expect_success 'reset should work' '
  25  git read-tree -u --reset HEAD^ &&
  26  git ls-files >actual &&
  27  test_cmp expect actual
  28'
  29
  30test_expect_success 'reset should remove remnants from a failed merge' '
  31  git read-tree --reset -u HEAD &&
  32  git ls-files -s >expect &&
  33  sha1=$(git rev-parse :new) &&
  34  (
  35        echo "100644 $sha1 1    old"
  36        echo "100644 $sha1 3    old"
  37  ) | git update-index --index-info &&
  38  >old &&
  39  git ls-files -s &&
  40  git read-tree --reset -u HEAD &&
  41  git ls-files -s >actual &&
  42  ! test -f old
  43'
  44
  45test_expect_success 'Porcelain reset should remove remnants too' '
  46  git read-tree --reset -u HEAD &&
  47  git ls-files -s >expect &&
  48  sha1=$(git rev-parse :new) &&
  49  (
  50        echo "100644 $sha1 1    old"
  51        echo "100644 $sha1 3    old"
  52  ) | git update-index --index-info &&
  53  >old &&
  54  git ls-files -s &&
  55  git reset --hard &&
  56  git ls-files -s >actual &&
  57  ! test -f old
  58'
  59
  60test_expect_success 'Porcelain checkout -f should remove remnants too' '
  61  git read-tree --reset -u HEAD &&
  62  git ls-files -s >expect &&
  63  sha1=$(git rev-parse :new) &&
  64  (
  65        echo "100644 $sha1 1    old"
  66        echo "100644 $sha1 3    old"
  67  ) | git update-index --index-info &&
  68  >old &&
  69  git ls-files -s &&
  70  git checkout -f &&
  71  git ls-files -s >actual &&
  72  ! test -f old
  73'
  74
  75test_expect_success 'Porcelain checkout -f HEAD should remove remnants too' '
  76  git read-tree --reset -u HEAD &&
  77  git ls-files -s >expect &&
  78  sha1=$(git rev-parse :new) &&
  79  (
  80        echo "100644 $sha1 1    old"
  81        echo "100644 $sha1 3    old"
  82  ) | git update-index --index-info &&
  83  >old &&
  84  git ls-files -s &&
  85  git checkout -f HEAD &&
  86  git ls-files -s >actual &&
  87  ! test -f old
  88'
  89
  90test_done