git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
2e2a6a0c696acd90c1070ca3780375bc1232f671 blob 4744 bytes (raw)

  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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
 
#!/bin/sh

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

. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.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 &&
	git ls-files >expect-two
'

test_expect_success '--protect-untracked option sanity checks' '
	read_tree_u_must_fail --reset --protect-untracked HEAD &&
	read_tree_u_must_fail --reset --no-protect-untracked HEAD &&
	read_tree_u_must_fail -m -u --protect-untracked HEAD &&
	read_tree_u_must_fail -m -u --no-protect-untracked
'

test_expect_success 'exclude option sanity checks' '
	read_tree_u_must_fail --reset -u --exclude-standard HEAD &&
	read_tree_u_must_fail --reset --protect-untracked --exclude-standard &&
	read_tree_u_must_fail --reset -u --protect-untracked \
			      --exclude-standard \
			      --exclude-per-directory=.gitignore HEAD &&
	read_tree_u_must_fail --reset -u --protect-untracked \
			      --exclude-per-directory=gitignore \
			      --exclude-per-directory=.gitignore HEAD &&
	read_tree_u_must_fail --reset --exclude-per-directory=.gitignore HEAD &&
	read_tree_u_must_succeed --reset -u --exclude-per-directory=.gitignore \
				 HEAD
'

test_expect_success 'reset should reset worktree' '
	echo changed >df &&
	read_tree_u_must_succeed -u --reset HEAD^ &&
	git ls-files >actual &&
	test_cmp expect actual
'

test_expect_success 'reset --protect-untracked protects untracked file' '
	echo changed >new &&
	read_tree_u_must_fail_save_err -u --reset --protect-untracked HEAD &&
	echo "error: Untracked working tree file '\'new\'' would be overwritten by merge." >expected-err &&
	test_cmp expected-err actual-err
'

test_expect_success 'reset --protect-untracked protects untracked directory' '
	rm new &&
	mkdir new &&
	echo untracked >new/untracked &&
	read_tree_u_must_fail_save_err -u --reset --protect-untracked HEAD &&
	echo "error: Updating '\'new\'' would lose untracked files in it" >expected-err &&
	test_cmp expected-err actual-err
'

test_expect_success 'reset --protect-untracked --exclude-standard overwrites ignored path' '
	test_when_finished "rm .git/info/exclude" &&
	echo missing >.git/info/exclude &&
	read_tree_u_must_fail -u --reset --protect-untracked \
			      --exclude-standard HEAD &&
	echo new >.git/info/exclude &&
	echo changed >df/file &&
	read_tree_u_must_succeed -u --reset --protect-untracked \
				 --exclude-standard HEAD &&
	git ls-files >actual &&
	test_cmp expect-two actual
'

test_expect_success 'reset --protect-untracked resets' '
	echo changed >df &&
	read_tree_u_must_succeed -u --reset --protect-untracked HEAD^ &&
	git ls-files >actual &&
	test_cmp expect actual
'

test_expect_success 'reset should remove remnants from a failed merge' '
	read_tree_u_must_succeed --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 &&
	read_tree_u_must_succeed --reset -u HEAD &&
	git ls-files -s >actual &&
	! test -f old
'

test_expect_success 'two-way reset should remove remnants too' '
	read_tree_u_must_succeed --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 &&
	read_tree_u_must_succeed --reset -u HEAD HEAD &&
	git ls-files -s >actual &&
	! test -f old
'

test_expect_success 'Porcelain reset should remove remnants too' '
	read_tree_u_must_succeed --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' '
	read_tree_u_must_succeed --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' '
	read_tree_u_must_succeed --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
debug log:

solving 2e2a6a0c69 ...
found 2e2a6a0c69 in https://public-inbox.org/git/20190501101403.20294-3-phillip.wood123@gmail.com/
found 6c9dd6805b in https://public-inbox.org/git/20190501101403.20294-2-phillip.wood123@gmail.com/
found 83b09e1310 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 83b09e1310676cc4ca092ff30c6da50aa6e635fd	t/t1005-read-tree-reset.sh

applying [1/2] https://public-inbox.org/git/20190501101403.20294-2-phillip.wood123@gmail.com/
diff --git a/t/t1005-read-tree-reset.sh b/t/t1005-read-tree-reset.sh
index 83b09e1310..6c9dd6805b 100755


applying [2/2] https://public-inbox.org/git/20190501101403.20294-3-phillip.wood123@gmail.com/
diff --git a/t/t1005-read-tree-reset.sh b/t/t1005-read-tree-reset.sh
index 6c9dd6805b..2e2a6a0c69 100755

Checking patch t/t1005-read-tree-reset.sh...
Applied patch t/t1005-read-tree-reset.sh cleanly.
Checking patch t/t1005-read-tree-reset.sh...
Applied patch t/t1005-read-tree-reset.sh cleanly.

index at:
100755 2e2a6a0c696acd90c1070ca3780375bc1232f671	t/t1005-read-tree-reset.sh

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).