Skip to content

Commit a3436cd

Browse files
committed
libgit2#6154 git_status_list_new case insensitive fix
1 parent 50b4d53 commit a3436cd

File tree

6 files changed

+64
-1
lines changed

6 files changed

+64
-1
lines changed

src/diff_tform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static int apply_splits_and_deletes(
375375
size_t i;
376376
git_diff_delta *delta;
377377

378-
if (git_vector_init(&onto, expected_size, git_diff_delta__cmp) < 0)
378+
if (git_vector_init(&onto, expected_size, diff->deltas._cmp) < 0)
379379
return -1;
380380

381381
/* build new delta list without TO_DELETE and splitting TO_SPLIT */
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
x��KN�0DY��GD��#!��C���K�=�8pz���Z�[ԫ��{`g�4:3`N����?����E�� �Bp�8��=w��L�, �`u��bΜh���#�V�S���ᣬop��}��%��s�m�ǃ�c���}���2nNK���Do�%x�E'��I�׃�kO]�J]A��0 �ƃ Z�ʟ���Ɔ_[
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
41a766bb079e18ff6a24571831bd751168799a02

tests/status/renames.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,3 +718,64 @@ void test_status_renames__precomposed_unicode_toggle_is_rename(void)
718718
#endif
719719
}
720720

721+
void test_status_renames__case_insensitive_h2i_and_i2wc(void)
722+
{
723+
git_status_list *statuslist;
724+
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
725+
git_reference *head, *test_branch;
726+
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
727+
git_str path_to_delete = GIT_STR_INIT;
728+
git_str path_to_edit = GIT_STR_INIT;
729+
git_index *index;
730+
git_strarray paths = { NULL, 0 };
731+
732+
struct status_entry expected[] = {
733+
{ GIT_STATUS_INDEX_RENAMED | GIT_STATUS_WT_MODIFIED, "sixserving.txt", "sixserving-renamed.txt" },
734+
{ GIT_STATUS_INDEX_DELETED, "Wow.txt", "Wow.txt" }
735+
};
736+
737+
738+
// Checkout the correct branch
739+
checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
740+
cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
741+
cl_git_pass(git_reference_symbolic_set_target(
742+
&test_branch, head, "refs/heads/case-insensitive-status", NULL));
743+
cl_git_pass(git_checkout_head(g_repo, &checkout_opts));
744+
745+
cl_git_pass(git_repository_index(&index, g_repo));
746+
747+
748+
// Rename sixserving.txt, delete Wow.txt, and stage those changes
749+
rename_file(g_repo, "sixserving.txt", "sixserving-renamed.txt");
750+
cl_git_pass(git_str_joinpath(
751+
&path_to_delete, git_repository_workdir(g_repo), "Wow.txt"));
752+
cl_git_rmfile(path_to_delete.ptr);
753+
754+
cl_git_pass(git_index_add_all(index, &paths, GIT_INDEX_ADD_FORCE, NULL, NULL));
755+
cl_git_pass(git_index_write(index));
756+
757+
758+
// Change content of sixserving-renamed.txt
759+
cl_git_pass(git_str_joinpath(
760+
&path_to_edit, git_repository_workdir(g_repo), "sixserving-renamed.txt"));
761+
cl_git_append2file(path_to_edit.ptr, "New content\n");
762+
763+
764+
// Run status
765+
opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED;
766+
opts.flags |= GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR;
767+
opts.flags |= GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX;
768+
opts.flags |= GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY;
769+
770+
cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
771+
check_status(statuslist, expected, 2);
772+
git_status_list_free(statuslist);
773+
774+
git_index_free(index);
775+
776+
git_str_dispose(&path_to_delete);
777+
git_str_dispose(&path_to_edit);
778+
779+
git_reference_free(head);
780+
git_reference_free(test_branch);
781+
}

0 commit comments

Comments
 (0)