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 | |
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.
-rw-r--r-- | include/git2/apply.h | 32 | ||||
-rw-r--r-- | src/apply.c | 26 | ||||
-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 |
6 files changed, 66 insertions, 108 deletions
diff --git a/include/git2/apply.h b/include/git2/apply.h index 3bf6aad63..cdeb9ed4c 100644 --- a/include/git2/apply.h +++ b/include/git2/apply.h @@ -22,6 +22,21 @@ GIT_BEGIN_DECL /** + * Apply options structure + * + * Initialize with `GIT_APPLY_OPTIONS_INIT`. Alternatively, you can + * use `git_apply_init_options`. + * + * @see git_apply_to_tree, git_apply + */ +typedef struct { + unsigned int version; +} git_apply_options; + +#define GIT_APPLY_OPTIONS_VERSION 1 +#define GIT_APPLY_OPTIONS_INIT {GIT_APPLY_OPTIONS_VERSION} + +/** * Apply a `git_diff` to a `git_tree`, and return the resulting image * as an index. * @@ -29,12 +44,14 @@ GIT_BEGIN_DECL * @param repo the repository to apply * @param preimage the tree to apply the diff to * @param diff the diff to apply + * @param options the options for the apply (or null for defaults) */ GIT_EXTERN(int) git_apply_to_tree( git_index **out, git_repository *repo, git_tree *preimage, - git_diff *diff); + git_diff *diff, + const git_apply_options *options); typedef enum { /** @@ -56,27 +73,20 @@ typedef enum { GIT_APPLY_LOCATION_BOTH = 2, } git_apply_location_t; -typedef struct { - unsigned int version; - - git_apply_location_t location; -} git_apply_options; - -#define GIT_APPLY_OPTIONS_VERSION 1 -#define GIT_APPLY_OPTIONS_INIT {GIT_APPLY_OPTIONS_VERSION} - /** * Apply a `git_diff` to the given repository, making changes directly * in the working directory, the index, or both. * * @param repo the repository to apply to * @param diff the diff to apply + * @param location the location to apply (workdir, index or both) * @param options the options for the apply (or null for defaults) */ GIT_EXTERN(int) git_apply( git_repository *repo, git_diff *diff, - git_apply_options *options); + git_apply_location_t location, + const git_apply_options *options); /** @} */ GIT_END_DECL diff --git a/src/apply.c b/src/apply.c index d098f962e..e6c2ae15b 100644 --- a/src/apply.c +++ b/src/apply.c @@ -472,10 +472,12 @@ int git_apply_to_tree( git_index **out, git_repository *repo, git_tree *preimage, - git_diff *diff) + git_diff *diff, + const git_apply_options *given_opts) { git_index *postimage = NULL; git_reader *pre_reader = NULL; + git_apply_options opts = GIT_APPLY_OPTIONS_INIT; const git_diff_delta *delta; size_t i; int error = 0; @@ -484,6 +486,9 @@ int git_apply_to_tree( *out = NULL; + if (given_opts) + memcpy(&opts, given_opts, sizeof(git_apply_options)); + if ((error = git_reader_for_tree(&pre_reader, preimage)) < 0) goto done; @@ -529,6 +534,7 @@ static int git_apply__to_workdir( git_diff *diff, git_index *preimage, git_index *postimage, + git_apply_location_t location, git_apply_options *opts) { git_vector paths = GIT_VECTOR_INIT; @@ -537,6 +543,8 @@ static int git_apply__to_workdir( size_t i; int error; + GIT_UNUSED(opts); + /* * Limit checkout to the paths affected by the diff; this ensures * that other modifications in the working directory are unaffected. @@ -559,7 +567,7 @@ static int git_apply__to_workdir( checkout_opts.checkout_strategy |= GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH; checkout_opts.checkout_strategy |= GIT_CHECKOUT_DONT_WRITE_INDEX; - if (opts->location == GIT_APPLY_LOCATION_WORKDIR) + if (location == GIT_APPLY_LOCATION_WORKDIR) checkout_opts.checkout_strategy |= GIT_CHECKOUT_DONT_UPDATE_INDEX; checkout_opts.paths.strings = (char **)paths.contents; @@ -636,7 +644,8 @@ done: int git_apply( git_repository *repo, git_diff *diff, - git_apply_options *given_opts) + git_apply_location_t location, + const git_apply_options *given_opts) { git_indexwriter indexwriter = GIT_INDEXWRITER_INIT; git_index *index = NULL, *preimage = NULL, *postimage = NULL; @@ -658,7 +667,7 @@ int git_apply( * in `--cached` or `--index` mode, we apply to the contents already * in the index. */ - switch (opts.location) { + switch (location) { case GIT_APPLY_LOCATION_BOTH: error = git_reader_for_workdir(&pre_reader, repo, true); break; @@ -695,15 +704,15 @@ int git_apply( goto done; } - switch (opts.location) { + switch (location) { case GIT_APPLY_LOCATION_BOTH: - error = git_apply__to_workdir(repo, diff, preimage, postimage, &opts); + error = git_apply__to_workdir(repo, diff, preimage, postimage, location, &opts); break; case GIT_APPLY_LOCATION_INDEX: error = git_apply__to_index(repo, diff, preimage, postimage, &opts); break; case GIT_APPLY_LOCATION_WORKDIR: - error = git_apply__to_workdir(repo, diff, preimage, postimage, &opts); + error = git_apply__to_workdir(repo, diff, preimage, postimage, location, &opts); break; default: assert(false); @@ -712,9 +721,6 @@ int git_apply( if (error < 0) goto done; - if (error < 0) - goto done; - error = git_indexwriter_commit(&indexwriter); done: 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); |