at least it compiles

This commit is contained in:
Gerhard Hoffmann 2024-04-05 12:13:27 +02:00
parent 1d119cb63e
commit a3cbb20a53

View File

@ -383,13 +383,14 @@ static void opts_add_refish(struct merge_options *opts, const char *refish) {
assert(opts != NULL);
sz = ++opts->heads_count * sizeof(opts->heads[0]);
opts->heads = xrealloc((void *) opts->heads, sz);
if ((opts->heads = (const char **)realloc((void *) opts->heads, sz)) != 0) {
opts->heads[opts->heads_count - 1] = refish;
}
}
static int resolve_heads(git_repository *repo, struct merge_options *opts)
{
git_annotated_commit **annotated = calloc(opts->heads_count, sizeof(git_annotated_commit *));
git_annotated_commit **annotated = (git_annotated_commit **)calloc(opts->heads_count, sizeof(git_annotated_commit *));
size_t annotated_count = 0, i;
int err = 0;
@ -415,7 +416,14 @@ static int resolve_heads(git_repository *repo, struct merge_options *opts)
static int perform_fastforward(git_repository *repo, const git_oid *target_oid, int is_unborn)
{
git_checkout_options ff_checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
// git_checkout_options ff_checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
git_checkout_options ff_checkout_options;
// #define GIT_CHECKOUT_OPTIONS_INIT {GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE}
git_checkout_options_init(&ff_checkout_options, GIT_CHECKOUT_OPTIONS_VERSION);
ff_checkout_options.checkout_strategy = GIT_CHECKOUT_SAFE;
git_reference *target_ref;
git_reference *new_target_ref;
git_object *target = NULL;
@ -513,7 +521,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, struct me
git_reference *merge_ref = NULL;
git_annotated_commit *merge_commit;
git_reference *head_ref;
git_commit **parents = calloc(opts->annotated_count + 1, sizeof(git_commit *));
git_commit **parents = (git_commit **)calloc(opts->annotated_count + 1, sizeof(git_commit *));
const char *msg_target = NULL;
size_t msglen = 0;
char *msg;
@ -545,7 +553,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, struct me
msglen = snprintf(NULL, 0, MERGE_COMMIT_MSG, (merge_ref ? "branch" : "commit"), msg_target);
if (msglen > 0) msglen++;
msg = malloc(msglen);
msg = (char *)malloc(msglen);
err = snprintf(msg, msglen, MERGE_COMMIT_MSG, (merge_ref ? "branch" : "commit"), msg_target);
/* This is only to silence the compiler */
@ -568,7 +576,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, struct me
sign, sign,
NULL, msg,
tree,
opts->annotated_count + 1, parents);
opts->annotated_count + 1, (const git_commit **)parents);
check(err, "failed to create commit", NULL);
/* We're done merging, cleanup the repository state */
@ -591,7 +599,7 @@ static int merge(git_repository *repo) {
merge_options_init(&opts);
parse_options(&path, &opts);
state = git_repository_state(repo);
state = (git_repository_state_t)git_repository_state(repo);
if (state != GIT_REPOSITORY_STATE_NONE) {
fprintf(stderr, "repository is in unexpected state %d\n", state);
goto cleanup;
@ -626,8 +634,21 @@ static int merge(git_repository *repo) {
return perform_fastforward(repo, target_oid, (analysis & GIT_MERGE_ANALYSIS_UNBORN));
} else if (analysis & GIT_MERGE_ANALYSIS_NORMAL) {
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
//git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_merge_options merge_opts;
git_merge_options_init(&merge_opts, GIT_MERGE_OPTIONS_VERSION);
// TODO: check this...
// merge_opts.file_flags = GIT_MERGE_FIND_RENAMES;
// GIT_MERGE_OPTIONS_VERSION, GIT_MERGE_FIND_RENAMES }
//git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_checkout_options checkout_opts;
git_checkout_options_init(&checkout_opts, GIT_CHECKOUT_OPTIONS_VERSION);
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
merge_opts.flags = 0;
merge_opts.file_flags = GIT_MERGE_FILE_STYLE_DIFF3;