From a3436cde9fbdb0ce9eb3c3e0727e3093560e10e9 Mon Sep 17 00:00:00 2001 From: Miguel Arroz <750683+arroz@users.noreply.github.com> Date: Sat, 1 Jan 2022 15:17:08 -0800 Subject: [PATCH 1/3] #6154 git_status_list_new case insensitive fix --- src/diff_tform.c | 2 +- .../41/a766bb079e18ff6a24571831bd751168799a02 | 1 + .../ba/8b004914491b129b4feff51b5fd8553b8e8156 | Bin 0 -> 191 bytes .../e5/6d39ca6d946331aa79c9c443d46c8a6ed4f550 | Bin 0 -> 36 bytes .../refs/heads/case-insensitive-status | 1 + tests/status/renames.c | 61 ++++++++++++++++++ 6 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tests/resources/renames/.gitted/objects/41/a766bb079e18ff6a24571831bd751168799a02 create mode 100644 tests/resources/renames/.gitted/objects/ba/8b004914491b129b4feff51b5fd8553b8e8156 create mode 100644 tests/resources/renames/.gitted/objects/e5/6d39ca6d946331aa79c9c443d46c8a6ed4f550 create mode 100644 tests/resources/renames/.gitted/refs/heads/case-insensitive-status diff --git a/src/diff_tform.c b/src/diff_tform.c index d14134071..f9836d245 100644 --- a/src/diff_tform.c +++ b/src/diff_tform.c @@ -375,7 +375,7 @@ static int apply_splits_and_deletes( size_t i; git_diff_delta *delta; - if (git_vector_init(&onto, expected_size, git_diff_delta__cmp) < 0) + if (git_vector_init(&onto, expected_size, diff->deltas._cmp) < 0) return -1; /* build new delta list without TO_DELETE and splitting TO_SPLIT */ diff --git a/tests/resources/renames/.gitted/objects/41/a766bb079e18ff6a24571831bd751168799a02 b/tests/resources/renames/.gitted/objects/41/a766bb079e18ff6a24571831bd751168799a02 new file mode 100644 index 000000000..4bd7592d5 --- /dev/null +++ b/tests/resources/renames/.gitted/objects/41/a766bb079e18ff6a24571831bd751168799a02 @@ -0,0 +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…ÊŸþ”êƆ_[ \ No newline at end of file diff --git a/tests/resources/renames/.gitted/objects/ba/8b004914491b129b4feff51b5fd8553b8e8156 b/tests/resources/renames/.gitted/objects/ba/8b004914491b129b4feff51b5fd8553b8e8156 new file mode 100644 index 0000000000000000000000000000000000000000..c61d650cecb718ea9a779e631961dfa6da2f49cb GIT binary patch literal 191 zcmV;w06_nE0V^p=O;s>5Fk&z?FfcPQQ3%g3*DI+gVR)Krc`A2Gvf--AlSiDdFT2P!>0ao|w%i_oTpS8BW%55gF5c5 teEU=gs<n literal 0 HcmV?d00001 diff --git a/tests/resources/renames/.gitted/objects/e5/6d39ca6d946331aa79c9c443d46c8a6ed4f550 b/tests/resources/renames/.gitted/objects/e5/6d39ca6d946331aa79c9c443d46c8a6ed4f550 new file mode 100644 index 0000000000000000000000000000000000000000..d6deb188d582582b5d73aed64a0772e19e78fa20 GIT binary patch literal 36 scmb Date: Thu, 6 Jan 2022 07:39:21 -0500 Subject: [PATCH 2/3] status: don't use `// ...` in tests, use `/* ... */` --- tests/status/renames.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/status/renames.c b/tests/status/renames.c index d17a94ca7..d6bb69707 100644 --- a/tests/status/renames.c +++ b/tests/status/renames.c @@ -723,7 +723,7 @@ void test_status_renames__rename_threshold(void) git_index *index; git_status_list *statuslist; git_status_options opts = GIT_STATUS_OPTIONS_INIT; - + _rename_helper(g_repo, "ikeepsix.txt", "newname.txt", "Line 1\n" \ "Line 2\n" \ @@ -735,49 +735,49 @@ void test_status_renames__rename_threshold(void) "Line 8\n" \ "Line 9\n" ); - + opts.flags |= GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR; opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED; - + cl_git_pass(git_repository_index(&index, g_repo)); - - // Default threshold + + /* Default threshold */ { struct status_entry expected[] = { { GIT_STATUS_WT_RENAMED | GIT_STATUS_WT_MODIFIED, "ikeepsix.txt", "newname.txt" }, }; - + cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts)); check_status(statuslist, expected, 1); git_status_list_free(statuslist); } - - // Threshold set to 90 + + /* Threshold set to 90 */ { struct status_entry expected[] = { { GIT_STATUS_WT_DELETED, "ikeepsix.txt", NULL }, { GIT_STATUS_WT_NEW, "newname.txt", NULL } }; - + opts.rename_threshold = 90; - + cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts)); check_status(statuslist, expected, 2); git_status_list_free(statuslist); } - - // Threshold set to 25 + + /* Threshold set to 25 */ { struct status_entry expected[] = { { GIT_STATUS_WT_RENAMED | GIT_STATUS_WT_MODIFIED, "ikeepsix.txt", "newname.txt" }, }; - + opts.rename_threshold = 25; - + cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts)); check_status(statuslist, expected, 1); git_status_list_free(statuslist); } - + git_index_free(index); } From 9faa9199026258b084ecd292d9b93ac56b81ee94 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 6 Jan 2022 07:42:01 -0500 Subject: [PATCH 3/3] status: don't use `// ...` in tests, use `/* ... */` --- tests/status/renames.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/status/renames.c b/tests/status/renames.c index 2e61c3865..d5cf87d07 100644 --- a/tests/status/renames.c +++ b/tests/status/renames.c @@ -799,7 +799,7 @@ void test_status_renames__case_insensitive_h2i_and_i2wc(void) }; - // Checkout the correct branch + /* Checkout the correct branch */ checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE; cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD")); cl_git_pass(git_reference_symbolic_set_target( @@ -809,7 +809,7 @@ void test_status_renames__case_insensitive_h2i_and_i2wc(void) cl_git_pass(git_repository_index(&index, g_repo)); - // Rename sixserving.txt, delete Wow.txt, and stage those changes + /* Rename sixserving.txt, delete Wow.txt, and stage those changes */ rename_file(g_repo, "sixserving.txt", "sixserving-renamed.txt"); cl_git_pass(git_str_joinpath( &path_to_delete, git_repository_workdir(g_repo), "Wow.txt")); @@ -819,13 +819,12 @@ void test_status_renames__case_insensitive_h2i_and_i2wc(void) cl_git_pass(git_index_write(index)); - // Change content of sixserving-renamed.txt + /* Change content of sixserving-renamed.txt */ cl_git_pass(git_str_joinpath( &path_to_edit, git_repository_workdir(g_repo), "sixserving-renamed.txt")); cl_git_append2file(path_to_edit.ptr, "New content\n"); - - // Run status + /* Run status */ opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED; opts.flags |= GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR; opts.flags |= GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX;