mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 09:36:47 +00:00
Sometimes a zero byte file is just a zero byte file
Don't go to the ODB to resolve zero byte files in the workdir
This commit is contained in:
parent
2b678ce5b4
commit
410a8e6fed
@ -472,7 +472,7 @@ static int similarity_init(
|
|||||||
info->blob = NULL;
|
info->blob = NULL;
|
||||||
git_buf_init(&info->data, 0);
|
git_buf_init(&info->data, 0);
|
||||||
|
|
||||||
if (info->file->size > 0)
|
if (info->file->size > 0 || info->src == GIT_ITERATOR_TYPE_WORKDIR)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return git_diff_file__resolve_zero_size(
|
return git_diff_file__resolve_zero_size(
|
||||||
|
@ -555,3 +555,31 @@ void test_status_renames__both_casechange_two(void)
|
|||||||
|
|
||||||
git_index_free(index);
|
git_index_free(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_status_renames__zero_byte_file_does_not_fail(void)
|
||||||
|
{
|
||||||
|
git_status_list *statuslist;
|
||||||
|
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
|
||||||
|
status_entry_counts counts = {0};
|
||||||
|
|
||||||
|
struct status_entry expected[] = {
|
||||||
|
{ GIT_STATUS_WT_DELETED, "ikeepsix.txt", "ikeepsix.txt" },
|
||||||
|
{ GIT_STATUS_WT_NEW, "zerobyte.txt", "zerobyte.txt" },
|
||||||
|
};
|
||||||
|
|
||||||
|
opts.flags |= GIT_STATUS_OPT_RENAMES_FROM_REWRITES |
|
||||||
|
GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX |
|
||||||
|
GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR |
|
||||||
|
GIT_STATUS_OPT_INCLUDE_IGNORED |
|
||||||
|
GIT_STATUS_OPT_INCLUDE_UNTRACKED |
|
||||||
|
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS |
|
||||||
|
GIT_STATUS_SHOW_INDEX_AND_WORKDIR |
|
||||||
|
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS;
|
||||||
|
|
||||||
|
p_unlink("renames/ikeepsix.txt");
|
||||||
|
cl_git_mkfile("renames/zerobyte.txt", "");
|
||||||
|
|
||||||
|
cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
|
||||||
|
test_status(statuslist, expected, 2);
|
||||||
|
git_status_list_free(statuslist);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user