summaryrefslogtreecommitdiff
path: root/t/t1005-read-tree-reset.sh
blob: 849911683a799981a565416a88fe9092b3727853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh

test_description='read-tree -u --reset'

. ./test-lib.sh

# two-tree test

test_expect_success 'setup' '
  git init &&
  mkdir df &&
  echo content >df/file &&
  git add df/file &&
  git commit -m one &&
  git ls-files >expect &&
  rm -rf df &&
  echo content >df &&
  git add df &&
  echo content >new &&
  git add new &&
  git commit -m two
'

test_expect_success 'reset should work' '
  git read-tree -u --reset HEAD^ &&
  git ls-files >actual &&
  test_cmp expect actual
'

test_expect_success 'reset should remove remnants from a failed merge' '
  git read-tree --reset -u HEAD &&
  git ls-files -s >expect &&
  sha1=$(git rev-parse :new) &&
  (
	echo "100644 $sha1 1	old"
	echo "100644 $sha1 3	old"
  ) | git update-index --index-info &&
  >old &&
  git ls-files -s &&
  git read-tree --reset -u HEAD &&
  git ls-files -s >actual &&
  ! test -f old
'

test_expect_success 'Porcelain reset should remove remnants too' '
  git read-tree --reset -u HEAD &&
  git ls-files -s >expect &&
  sha1=$(git rev-parse :new) &&
  (
	echo "100644 $sha1 1	old"
	echo "100644 $sha1 3	old"
  ) | git update-index --index-info &&
  >old &&
  git ls-files -s &&
  git reset --hard &&
  git ls-files -s >actual &&
  ! test -f old
'

test_expect_success 'Porcelain checkout -f should remove remnants too' '
  git read-tree --reset -u HEAD &&
  git ls-files -s >expect &&
  sha1=$(git rev-parse :new) &&
  (
	echo "100644 $sha1 1	old"
	echo "100644 $sha1 3	old"
  ) | git update-index --index-info &&
  >old &&
  git ls-files -s &&
  git checkout -f &&
  git ls-files -s >actual &&
  ! test -f old
'

test_expect_success 'Porcelain checkout -f HEAD should remove remnants too' '
  git read-tree --reset -u HEAD &&
  git ls-files -s >expect &&
  sha1=$(git rev-parse :new) &&
  (
	echo "100644 $sha1 1	old"
	echo "100644 $sha1 3	old"
  ) | git update-index --index-info &&
  >old &&
  git ls-files -s &&
  git checkout -f HEAD &&
  git ls-files -s >actual &&
  ! test -f old
'

test_done