diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2018-07-08 16:12:58 +0100 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-11-05 15:53:58 +0000 |
| commit | 37b25ac57f78dc72e6bf4e516e24dc5010098cee (patch) | |
| tree | 4d87b64b67f8332cf7d16d661e3bcbea7af0e224 /tests/apply | |
| parent | 2d27ddc02e22a3cffbfafcb42e6eac04baf7256f (diff) | |
| download | libgit2-37b25ac57f78dc72e6bf4e516e24dc5010098cee.tar.gz | |
apply: move location to an argument, not the opts
Move the location option to an argument, out of the options structure.
This allows the options structure to be re-used for functions that don't
need to know the location, since it's implicit in their functionality.
For example, `git_apply_tree` should not take a location, but is
expected to take all the other options.
Diffstat (limited to 'tests/apply')
| -rw-r--r-- | tests/apply/both.c | 50 | ||||
| -rw-r--r-- | tests/apply/index.c | 45 | ||||
| -rw-r--r-- | tests/apply/tree.c | 2 | ||||
| -rw-r--r-- | tests/apply/workdir.c | 19 |
4 files changed, 29 insertions, 87 deletions
diff --git a/tests/apply/both.c b/tests/apply/both.c index db8cb827a..e93716689 100644 --- a/tests/apply/both.c +++ b/tests/apply/both.c @@ -30,7 +30,6 @@ void test_apply_both__generated_diff(void) git_tree *a_tree, *b_tree; git_diff *diff; git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; struct merge_index_entry both_expected[] = { { 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" }, @@ -52,9 +51,7 @@ void test_apply_both__generated_diff(void) cl_git_pass(git_commit_tree(&b_tree, b_commit)); cl_git_pass(git_diff_tree_to_tree(&diff, repo, a_tree, b_tree, &diff_opts)); - - opts.location = GIT_APPLY_LOCATION_BOTH; - cl_git_pass(git_apply(repo, diff, &opts)); + 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); @@ -69,7 +66,6 @@ void test_apply_both__generated_diff(void) void test_apply_both__parsed_diff(void) { git_diff *diff; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; struct merge_index_entry both_expected[] = { { 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" }, @@ -84,9 +80,7 @@ void test_apply_both__parsed_diff(void) cl_git_pass(git_diff_from_buffer(&diff, DIFF_MODIFY_TWO_FILES, strlen(DIFF_MODIFY_TWO_FILES))); - - opts.location = GIT_APPLY_LOCATION_BOTH; - cl_git_pass(git_apply(repo, diff, &opts)); + 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); @@ -97,7 +91,6 @@ void test_apply_both__parsed_diff(void) void test_apply_both__removes_file(void) { git_diff *diff; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; struct merge_index_entry both_expected[] = { { 0100644, "f51658077d85f2264fa179b4d0848268cb3475c3", 0, "asparagus.txt" }, @@ -111,9 +104,7 @@ void test_apply_both__removes_file(void) cl_git_pass(git_diff_from_buffer(&diff, DIFF_DELETE_FILE, strlen(DIFF_DELETE_FILE))); - - opts.location = GIT_APPLY_LOCATION_BOTH; - cl_git_pass(git_apply(repo, diff, &opts)); + 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); @@ -124,7 +115,6 @@ void test_apply_both__removes_file(void) void test_apply_both__adds_file(void) { git_diff *diff; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; struct merge_index_entry both_expected[] = { { 0100644, "f51658077d85f2264fa179b4d0848268cb3475c3", 0, "asparagus.txt" }, @@ -140,9 +130,7 @@ void test_apply_both__adds_file(void) cl_git_pass(git_diff_from_buffer(&diff, DIFF_ADD_FILE, strlen(DIFF_ADD_FILE))); - - opts.location = GIT_APPLY_LOCATION_BOTH; - cl_git_pass(git_apply(repo, diff, &opts)); + 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); @@ -154,7 +142,6 @@ void test_apply_both__application_failure_leaves_index_unmodified(void) { git_diff *diff; git_index *index; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_MODIFY_TWO_FILES; @@ -175,9 +162,7 @@ void test_apply_both__application_failure_leaves_index_unmodified(void) git_index_free(index); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_BOTH; - cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, &opts)); + cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_workdir_unchanged(repo); @@ -190,7 +175,6 @@ void test_apply_both__index_must_match_workdir(void) git_diff *diff; git_index *index; git_index_entry idx_entry; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_MODIFY_TWO_FILES; @@ -215,9 +199,7 @@ void test_apply_both__index_must_match_workdir(void) git_index_free(index); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_BOTH; - cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, &opts)); + cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL)); git_diff_free(diff); } @@ -226,7 +208,6 @@ void test_apply_both__application_failure_leaves_workdir_unmodified(void) { git_diff *diff; git_index *index; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_MODIFY_TWO_FILES; @@ -251,9 +232,7 @@ void test_apply_both__application_failure_leaves_workdir_unmodified(void) git_index_free(index); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_BOTH; - cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, &opts)); + cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL)); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -265,7 +244,6 @@ void test_apply_both__keeps_nonconflicting_changes(void) git_diff *diff; git_index *index; git_index_entry idx_entry; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_MODIFY_TWO_FILES; @@ -307,9 +285,7 @@ void test_apply_both__keeps_nonconflicting_changes(void) cl_git_rewritefile("merge-recursive/gravy.txt", "Hello, world.\n"); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_BOTH; - cl_git_pass(git_apply(repo, diff, &opts)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -321,7 +297,6 @@ void test_apply_both__can_apply_nonconflicting_file_changes(void) { git_diff *diff; git_index *index; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_MODIFY_TWO_FILES; @@ -350,9 +325,7 @@ void test_apply_both__can_apply_nonconflicting_file_changes(void) git_index_free(index); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_BOTH; - cl_git_pass(git_apply(repo, diff, &opts)); + 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); @@ -365,7 +338,6 @@ void test_apply_both__honors_crlf_attributes(void) git_diff *diff; git_oid oid; git_commit *commit; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_MODIFY_TWO_FILES; @@ -403,9 +375,7 @@ void test_apply_both__honors_crlf_attributes(void) git_commit_free(commit); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_BOTH; - cl_git_pass(git_apply(repo, diff, &opts)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); diff --git a/tests/apply/index.c b/tests/apply/index.c index 5f6321a3b..9c9094cce 100644 --- a/tests/apply/index.c +++ b/tests/apply/index.c @@ -30,7 +30,6 @@ void test_apply_index__generate_diff(void) git_tree *a_tree, *b_tree; git_diff *diff; git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; struct merge_index_entry index_expected[] = { { 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" }, @@ -52,9 +51,7 @@ void test_apply_index__generate_diff(void) cl_git_pass(git_commit_tree(&b_tree, b_commit)); cl_git_pass(git_diff_tree_to_tree(&diff, repo, a_tree, b_tree, &diff_opts)); - - opts.location = GIT_APPLY_LOCATION_INDEX; - cl_git_pass(git_apply(repo, diff, &opts)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_INDEX, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_workdir_unchanged(repo); @@ -69,7 +66,6 @@ void test_apply_index__generate_diff(void) void test_apply_index__parsed_diff(void) { git_diff *diff; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; struct merge_index_entry index_expected[] = { { 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" }, @@ -84,9 +80,7 @@ void test_apply_index__parsed_diff(void) cl_git_pass(git_diff_from_buffer(&diff, DIFF_MODIFY_TWO_FILES, strlen(DIFF_MODIFY_TWO_FILES))); - - opts.location = GIT_APPLY_LOCATION_INDEX; - cl_git_pass(git_apply(repo, diff, &opts)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_INDEX, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_workdir_unchanged(repo); @@ -97,7 +91,6 @@ void test_apply_index__parsed_diff(void) void test_apply_index__removes_file(void) { git_diff *diff; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; struct merge_index_entry index_expected[] = { { 0100644, "f51658077d85f2264fa179b4d0848268cb3475c3", 0, "asparagus.txt" }, @@ -111,9 +104,7 @@ void test_apply_index__removes_file(void) cl_git_pass(git_diff_from_buffer(&diff, DIFF_DELETE_FILE, strlen(DIFF_DELETE_FILE))); - - opts.location = GIT_APPLY_LOCATION_INDEX; - cl_git_pass(git_apply(repo, diff, &opts)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_INDEX, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_workdir_unchanged(repo); @@ -124,7 +115,6 @@ void test_apply_index__removes_file(void) void test_apply_index__adds_file(void) { git_diff *diff; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; struct merge_index_entry index_expected[] = { { 0100644, "f51658077d85f2264fa179b4d0848268cb3475c3", 0, "asparagus.txt" }, @@ -140,9 +130,7 @@ void test_apply_index__adds_file(void) cl_git_pass(git_diff_from_buffer(&diff, DIFF_ADD_FILE, strlen(DIFF_ADD_FILE))); - - opts.location = GIT_APPLY_LOCATION_INDEX; - cl_git_pass(git_apply(repo, diff, &opts)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_INDEX, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_workdir_unchanged(repo); @@ -153,7 +141,6 @@ void test_apply_index__adds_file(void) void test_apply_index__modified_workdir_with_unmodified_index_is_ok(void) { git_diff *diff; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_MODIFY_TWO_FILES; @@ -183,9 +170,7 @@ void test_apply_index__modified_workdir_with_unmodified_index_is_ok(void) cl_git_rewritefile("merge-recursive/veal.txt", "Hello, world.\n"); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_INDEX; - cl_git_pass(git_apply(repo, diff, &opts)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_INDEX, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -197,7 +182,6 @@ void test_apply_index__application_failure_leaves_index_unmodified(void) { git_diff *diff; git_index *index; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_MODIFY_TWO_FILES; @@ -218,9 +202,7 @@ void test_apply_index__application_failure_leaves_index_unmodified(void) git_index_free(index); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_INDEX; - cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, &opts)); + cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, GIT_APPLY_LOCATION_INDEX, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); @@ -232,7 +214,6 @@ void test_apply_index__keeps_nonconflicting_changes(void) git_diff *diff; git_index *index; git_index_entry idx_entry; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_MODIFY_TWO_FILES; @@ -260,9 +241,7 @@ void test_apply_index__keeps_nonconflicting_changes(void) git_index_free(index); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_INDEX; - cl_git_pass(git_apply(repo, diff, &opts)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_INDEX, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_workdir_unchanged(repo); @@ -275,7 +254,6 @@ void test_apply_index__can_apply_nonconflicting_file_changes(void) git_diff *diff; git_index *index; git_index_entry idx_entry; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_MODIFY_TWO_FILES; @@ -308,9 +286,7 @@ void test_apply_index__can_apply_nonconflicting_file_changes(void) git_index_free(index); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_INDEX; - cl_git_pass(git_apply(repo, diff, &opts)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_INDEX, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_workdir_unchanged(repo); @@ -321,7 +297,6 @@ void test_apply_index__can_apply_nonconflicting_file_changes(void) void test_apply_index__change_mode(void) { git_diff *diff; - git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const char *diff_file = DIFF_EXECUTABLE_FILE; @@ -337,9 +312,7 @@ void test_apply_index__change_mode(void) sizeof(struct merge_index_entry); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - - opts.location = GIT_APPLY_LOCATION_INDEX; - cl_git_pass(git_apply(repo, diff, &opts)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_INDEX, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_workdir_unchanged(repo); diff --git a/tests/apply/tree.c b/tests/apply/tree.c index 38c64c0f8..f35b13ce0 100644 --- a/tests/apply/tree.c +++ b/tests/apply/tree.c @@ -45,7 +45,7 @@ void test_apply_tree__one(void) cl_git_pass(git_diff_tree_to_tree(&diff, repo, a_tree, b_tree, &opts)); - cl_git_pass(git_apply_to_tree(&index, repo, a_tree, diff)); + cl_git_pass(git_apply_to_tree(&index, repo, a_tree, diff, NULL)); merge_test_index(index, expected, 6); git_index_free(index); diff --git a/tests/apply/workdir.c b/tests/apply/workdir.c index dc304a1a1..ab1dc2556 100644 --- a/tests/apply/workdir.c +++ b/tests/apply/workdir.c @@ -50,8 +50,7 @@ void test_apply_workdir__generated_diff(void) cl_git_pass(git_commit_tree(&b_tree, b_commit)); cl_git_pass(git_diff_tree_to_tree(&diff, repo, a_tree, b_tree, &opts)); - - cl_git_pass(git_apply(repo, diff, NULL)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_WORKDIR, NULL)); validate_index_unchanged(repo); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -80,7 +79,7 @@ void test_apply_workdir__parsed_diff(void) cl_git_pass(git_diff_from_buffer(&diff, DIFF_MODIFY_TWO_FILES, strlen(DIFF_MODIFY_TWO_FILES))); - cl_git_pass(git_apply(repo, diff, NULL)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_WORKDIR, NULL)); validate_index_unchanged(repo); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -104,7 +103,7 @@ void test_apply_workdir__removes_file(void) cl_git_pass(git_diff_from_buffer(&diff, DIFF_DELETE_FILE, strlen(DIFF_DELETE_FILE))); - cl_git_pass(git_apply(repo, diff, NULL)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_WORKDIR, NULL)); validate_index_unchanged(repo); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -130,7 +129,7 @@ void test_apply_workdir__adds_file(void) cl_git_pass(git_diff_from_buffer(&diff, DIFF_ADD_FILE, strlen(DIFF_ADD_FILE))); - cl_git_pass(git_apply(repo, diff, NULL)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_WORKDIR, NULL)); validate_index_unchanged(repo); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -179,7 +178,7 @@ void test_apply_workdir__modified_index_with_unmodified_workdir_is_ok(void) cl_git_pass(git_index_write(index)); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - cl_git_pass(git_apply(repo, diff, NULL)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_WORKDIR, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -210,7 +209,7 @@ void test_apply_workdir__application_failure_leaves_workdir_unmodified(void) "This is a modification.\n"); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, NULL)); + cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, GIT_APPLY_LOCATION_WORKDIR, NULL)); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -236,7 +235,7 @@ void test_apply_workdir__keeps_nonconflicting_changes(void) cl_git_pass(git_diff_from_buffer(&diff, DIFF_MODIFY_TWO_FILES, strlen(DIFF_MODIFY_TWO_FILES))); - cl_git_pass(git_apply(repo, diff, NULL)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_WORKDIR, NULL)); validate_index_unchanged(repo); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -270,7 +269,7 @@ void test_apply_workdir__can_apply_nonconflicting_file_changes(void) "This line is added in the workdir.\n"); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - cl_git_pass(git_apply(repo, diff, NULL)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_WORKDIR, NULL)); validate_index_unchanged(repo); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); @@ -297,7 +296,7 @@ void test_apply_workdir__change_mode(void) sizeof(struct merge_index_entry); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); - cl_git_pass(git_apply(repo, diff, NULL)); + cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_WORKDIR, NULL)); validate_index_unchanged(repo); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); |
