summaryrefslogtreecommitdiff
path: root/tests/apply/both.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-11-04 11:58:20 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2018-11-05 15:53:59 +0000
commit89b5a56e400dbc7b41f664566a37da802f405aae (patch)
tree07a7c7d1110ac3b9c4322c69b0cf84d4e999abdd /tests/apply/both.c
parent6fecf4d127bb6dd4257885ff6c71c12f92e66b94 (diff)
downloadlibgit2-89b5a56e400dbc7b41f664566a37da802f405aae.tar.gz
apply: test rename A -> B -> C scenarios
Test that we can rename some file from B->C and then rename some other file from A->B. Do this with both exact rename patches (eg `rename from ...` / `rename to ...`) and patches that remove the files and replace them entirely.
Diffstat (limited to 'tests/apply/both.c')
-rw-r--r--tests/apply/both.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/apply/both.c b/tests/apply/both.c
index 15b201698..0e6d672c8 100644
--- a/tests/apply/both.c
+++ b/tests/apply/both.c
@@ -449,3 +449,53 @@ void test_apply_both__rename_and_modify(void)
git_diff_free(diff);
}
+
+void test_apply_both__rename_a_to_b_to_c(void)
+{
+ git_diff *diff;
+
+ struct merge_index_entry both_expected[] = {
+ { 0100644, "f51658077d85f2264fa179b4d0848268cb3475c3", 0, "beef.txt" },
+ { 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" },
+ { 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" },
+ { 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "notbeef.txt" },
+ { 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" },
+ { 0100644, "94d2c01087f48213bd157222d54edfefd77c9bba", 0, "veal.txt" },
+ };
+ size_t both_expected_cnt = sizeof(both_expected) /
+ sizeof(struct merge_index_entry);
+
+ cl_git_pass(git_diff_from_buffer(&diff, DIFF_RENAME_A_TO_B_TO_C,
+ strlen(DIFF_RENAME_A_TO_B_TO_C)));
+ cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL));
+
+ validate_apply_index(repo, both_expected, both_expected_cnt);
+ validate_apply_workdir(repo, both_expected, both_expected_cnt);
+
+ git_diff_free(diff);
+}
+
+void test_apply_both__rename_a_to_b_to_c_exact(void)
+{
+ git_diff *diff;
+
+ struct merge_index_entry both_expected[] = {
+ { 0100644, "f51658077d85f2264fa179b4d0848268cb3475c3", 0, "beef.txt" },
+ { 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" },
+ { 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" },
+ { 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "notbeef.txt" },
+ { 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" },
+ { 0100644, "94d2c01087f48213bd157222d54edfefd77c9bba", 0, "veal.txt" },
+ };
+ size_t both_expected_cnt = sizeof(both_expected) /
+ sizeof(struct merge_index_entry);
+
+ cl_git_pass(git_diff_from_buffer(&diff, DIFF_RENAME_A_TO_B_TO_C_EXACT,
+ strlen(DIFF_RENAME_A_TO_B_TO_C_EXACT)));
+ cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL));
+
+ validate_apply_index(repo, both_expected, both_expected_cnt);
+ validate_apply_workdir(repo, both_expected, both_expected_cnt);
+
+ git_diff_free(diff);
+}