updated to latest
diff --git a/include/git2/merge.h b/include/git2/merge.h
index b861afa..98d419a 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -52,7 +52,7 @@
unsigned int resolve_flags;
} git_merge_trees_opts;
-#define GIT_MERGE_OPTS_INIT {0}
+#define GIT_MERGE_OPTS_INIT {0, GIT_MERGE_TREES_OPTS_INIT, 0, GIT_CHECKOUT_OPTS_INIT}
typedef struct {
unsigned int merge_flags;
diff --git a/src/checkout.c b/src/checkout.c
index ebbfe7a..80aafe2 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -237,29 +237,6 @@
git_buf_cstr(data->path), file->mode, data->can_symlink, data->opts);
}
-int git_checkout_blob(
- git_repository *repo,
- const git_oid *oid,
- const char *path,
- int mode,
- const git_checkout_opts *opts)
-{
- git_buf full_path = GIT_BUF_INIT;
- bool can_symlink = 0;
- int error = 0;
-
- if ((error = retrieve_symlink_caps(repo, &can_symlink)) < 0 ||
- git_buf_joinpath(&full_path, repo->workdir, path) < 0)
- goto done;
-
- error = checkout_blob_content(repo, oid, git_buf_cstr(&full_path), mode, can_symlink, opts);
-
-done:
- git_buf_free(&full_path);
-
- return error;
-}
-
static void normalize_options(
git_checkout_opts *normalized, git_checkout_opts *proposed)
{
@@ -287,6 +264,32 @@
normalized->file_open_flags = O_CREAT | O_TRUNC | O_WRONLY;
}
+int git_checkout_blob(
+ git_repository *repo,
+ const git_oid *oid,
+ const char *path,
+ int mode,
+ git_checkout_opts *opts)
+{
+ git_buf full_path = GIT_BUF_INIT;
+ git_checkout_opts checkout_opts;
+ bool can_symlink = 0;
+ int error = 0;
+
+ if ((error = retrieve_symlink_caps(repo, &can_symlink)) < 0 ||
+ git_buf_joinpath(&full_path, repo->workdir, path) < 0)
+ goto done;
+
+ normalize_options(&checkout_opts, opts);
+
+ error = checkout_blob_content(repo, oid, git_buf_cstr(&full_path), mode, can_symlink, &checkout_opts);
+
+done:
+ git_buf_free(&full_path);
+
+ return error;
+}
+
enum {
CHECKOUT_ACTION__NONE = 0,
CHECKOUT_ACTION__REMOVE = 1,
diff --git a/src/checkout.h b/src/checkout.h
index d37ea66..ce6798e 100644
--- a/src/checkout.h
+++ b/src/checkout.h
@@ -14,6 +14,6 @@
const git_oid *oid,
const char *path,
int mode,
- const git_checkout_opts *opts);
+ git_checkout_opts *opts);
#endif
diff --git a/src/diff_tree.c b/src/diff_tree.c
index 297ac09..7ebffd2 100644
--- a/src/diff_tree.c
+++ b/src/diff_tree.c
@@ -61,7 +61,7 @@
GITERR_CHECK_ALLOC(cur_items);
for (i = 0; i < trees_length; i++) {
- if ((error = git_iterator_for_tree(&iterators[i], repo, trees[i])) < 0)
+ if ((error = git_iterator_for_tree(&iterators[i], trees[i])) < 0)
return -1;
}
diff --git a/src/merge.c b/src/merge.c
index e900b28..59f3479 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -1019,9 +1019,8 @@
const git_diff_tree_entry *entry,
const char *path)
{
- git_checkout_opts opts;
+ git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
- memset(&opts, 0x0, sizeof(git_checkout_opts));
opts.file_open_flags = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL;
if (path == NULL)
@@ -1299,11 +1298,12 @@
if (!opts->checkout_opts.checkout_strategy)
opts->checkout_opts.checkout_strategy = default_checkout_strategy;
-
+
error = merge_trees_normalize_opts(&opts->merge_trees_opts, &given->merge_trees_opts);
} else {
- memset(opts, 0x0, sizeof(git_merge_opts));
-
+ git_merge_opts default_opts = GIT_MERGE_OPTS_INIT;
+ memcpy(opts, &default_opts, sizeof(git_merge_opts));
+
opts->checkout_opts.checkout_strategy = default_checkout_strategy;
error = merge_trees_normalize_opts(&opts->merge_trees_opts, NULL);
diff --git a/tests-clar/merge/trivial.c b/tests-clar/merge/trivial.c
index cdd774b..7087ab3 100644
--- a/tests-clar/merge/trivial.c
+++ b/tests-clar/merge/trivial.c
@@ -36,7 +36,6 @@
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
git_merge_result *result;
- memset(&checkout_opts, 0x0, sizeof(git_checkout_opts));
checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
opts.merge_trees_opts.resolve_flags |= automerge ? 0 : GIT_MERGE_RESOLVE_NO_REMOVED;