Skip to content

Commit 65bf820

Browse files
newrengitster
authored andcommitted
t6020: new test with interleaved lexicographic ordering of directories
If a repository has two files: foo/bar/baz foo/bar-2/baz then a simple lexicographic ordering of files and directories shows ... foo/bar foo/bar-2 foo/bar/baz ... and the appearance of foo/bar-2 between foo/bar and foo/bar/baz can trip up some codepaths. Add a test to catch such cases. t6020 might be a slight misfit since this testcase does not test any kind of file/directory conflict. However, it is similar in spirit to some tests (4-6) already in t6020 that check cases where a *file* sorted between a directory and the files underneath that directory. This testcase differs in that now there is a *directory* that sorts in the middle. Although merge-recursive currently has no problems with this simple testcase, I discovered that it's very possible to accidentally mess it up. Further, we have no other merge or cherry-pick or rebase testcases in the entire testsuite that cover such a case, so I felt like it would be a worthwhile addition to the testsuite. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9f697de commit 65bf820

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

t/t6020-merge-df.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,47 @@ test_expect_success 'modify/delete + directory/file conflict; other way' '
104104
test_path_is_file letters~HEAD
105105
'
106106

107+
test_expect_success 'Simple merge in repo with interesting pathnames' '
108+
# Simple lexicographic ordering of files and directories would be:
109+
# foo
110+
# foo/bar
111+
# foo/bar-2
112+
# foo/bar/baz
113+
# foo/bar-2/baz
114+
# The fact that foo/bar-2 appears between foo/bar and foo/bar/baz
115+
# can trip up some codepaths, and is the point of this test.
116+
test_create_repo name-ordering &&
117+
(
118+
cd name-ordering &&
119+
120+
mkdir -p foo/bar &&
121+
mkdir -p foo/bar-2 &&
122+
>foo/bar/baz &&
123+
>foo/bar-2/baz &&
124+
git add . &&
125+
git commit -m initial &&
126+
127+
git branch main &&
128+
git branch other &&
129+
130+
git checkout other &&
131+
echo other >foo/bar-2/baz &&
132+
git add -u &&
133+
git commit -m other &&
134+
135+
git checkout main &&
136+
echo main >foo/bar/baz &&
137+
git add -u &&
138+
git commit -m main &&
139+
140+
git merge other &&
141+
git ls-files -s >out &&
142+
test_line_count = 2 out &&
143+
git rev-parse :0:foo/bar/baz :0:foo/bar-2/baz >actual &&
144+
git rev-parse HEAD~1:foo/bar/baz other:foo/bar-2/baz >expect &&
145+
test_cmp expect actual
146+
)
147+
148+
'
149+
107150
test_done

0 commit comments

Comments
 (0)