Skip to content

Commit 8d4d980

Browse files
committed
merge_files: test with zero-byte file
Test handing a zero byte but extant file to merge_files.
1 parent cefc409 commit 8d4d980

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

tests/libgit2/merge/files.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,36 @@ void test_merge_files__automerge_from_index(void)
175175
git_merge_file_result_free(&result);
176176
}
177177

178+
void test_merge_files__automerge_zero_byte(void)
179+
{
180+
git_merge_file_result result = {0};
181+
git_index_entry ancestor, theirs, ours;
182+
183+
git_oid_from_string(&ancestor.id, "d427e0b2e138501a3d15cc376077a3631e15bd46", GIT_OID_SHA1);
184+
ancestor.path = "automergeable.txt";
185+
ancestor.mode = GIT_FILEMODE_BLOB;
186+
187+
git_oid_from_string(&ours.id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", GIT_OID_SHA1);
188+
ours.path = "empty.txt";
189+
ours.mode = GIT_FILEMODE_BLOB;
190+
191+
git_oid_from_string(&theirs.id, "d427e0b2e138501a3d15cc376077a3631e15bd46", GIT_OID_SHA1);
192+
theirs.path = "automergeable.txt";
193+
theirs.mode = GIT_FILEMODE_BLOB;
194+
195+
cl_git_pass(git_merge_file_from_index(&result, repo,
196+
&ancestor, &ours, &theirs, 0));
197+
198+
cl_assert_equal_i(1, result.automergeable);
199+
200+
cl_assert_equal_s("empty.txt", result.path);
201+
cl_assert_equal_i(GIT_FILEMODE_BLOB, result.mode);
202+
203+
cl_assert_equal_i(0, result.len);
204+
205+
git_merge_file_result_free(&result);
206+
}
207+
178208
void test_merge_files__automerge_from_index_delete_file(void)
179209
{
180210
git_merge_file_result result = {0};

0 commit comments

Comments
 (0)