Skip to content

Commit ac14de1

Browse files
newrengitster
authored andcommitted
t4058: explore duplicate tree entry handling in a bit more detail
While creating the last commit, I found a number of other cases where git would segfault when faced with trees that have duplicate entries. None of these segfaults are in the diffcore-rename code (they all occur in cache-tree and unpack-trees). Further, to my knowledge, no one has ever been adversely affected by these bugs, and given that it has been 15 years and folks have fixed a few other issues with historical duplicate entries (as noted in the last commit), I am not sure we will ever run into anyone having problems with these. So I am not sure these are worth fixing, but it doesn't hurt to at least document these failures in the same test file that is concerned with duplicate tree entries. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5c72261 commit ac14de1

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

t/t4058-diff-duplicates.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,71 @@ test_expect_success 'diff-tree FROM duplicate tree, with renames' '
119119
test_cmp expect actual
120120
'
121121

122+
test_expect_success 'create a few commits' '
123+
git commit-tree -m "Duplicate Entries" two^{tree} >commit_id &&
124+
git branch base $(cat commit_id) &&
125+
126+
git commit-tree -p $(cat commit_id) -m "Just one" three^{tree} >up &&
127+
git branch update $(cat up) &&
128+
129+
git commit-tree -p $(cat up) -m "Back to weird" two^{tree} >final &&
130+
git branch final $(cat final) &&
131+
132+
rm commit_id up final
133+
'
134+
135+
test_expect_failure 'git read-tree does not segfault' '
136+
test_when_finished rm .git/index.lock &&
137+
test_might_fail git read-tree --reset base
138+
'
139+
140+
test_expect_failure 'reset --hard does not segfault' '
141+
test_when_finished rm .git/index.lock &&
142+
git checkout base &&
143+
test_might_fail git reset --hard
144+
'
145+
146+
test_expect_failure 'git diff HEAD does not segfault' '
147+
git checkout base &&
148+
GIT_TEST_CHECK_CACHE_TREE=false &&
149+
git reset --hard &&
150+
test_might_fail git diff HEAD
151+
'
152+
153+
test_expect_failure 'can switch to another branch when status is empty' '
154+
git clean -ffdqx &&
155+
git status --porcelain -uno >actual &&
156+
test_must_be_empty actual &&
157+
git checkout update
158+
'
159+
160+
test_expect_success 'forcibly switch to another branch, verify status empty' '
161+
git checkout -f update &&
162+
git status --porcelain -uno >actual &&
163+
test_must_be_empty actual
164+
'
165+
166+
test_expect_success 'fast-forward from non-duplicate entries to duplicate' '
167+
git merge final
168+
'
169+
170+
test_expect_failure 'clean status, switch branches, status still clean' '
171+
git status --porcelain -uno >actual &&
172+
test_must_be_empty actual &&
173+
git checkout base &&
174+
git status --porcelain -uno >actual &&
175+
test_must_be_empty actual
176+
'
177+
178+
test_expect_success 'switch to base branch and force status to be clean' '
179+
git checkout base &&
180+
GIT_TEST_CHECK_CACHE_TREE=false git reset --hard &&
181+
git status --porcelain -uno >actual &&
182+
test_must_be_empty actual
183+
'
184+
185+
test_expect_failure 'fast-forward from duplicate entries to non-duplicate' '
186+
git merge update
187+
'
188+
122189
test_done

0 commit comments

Comments
 (0)