diff options
Diffstat (limited to 'notes-merge.c')
-rw-r--r-- | notes-merge.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/notes-merge.c b/notes-merge.c index fd5fae255d..34bfac0c68 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -280,7 +280,7 @@ static void check_notes_merge_worktree(struct notes_merge_options *o) "(%s exists).", git_path("NOTES_MERGE_*")); } - if (safe_create_leading_directories(git_path( + if (safe_create_leading_directories_const(git_path( NOTES_MERGE_WORKTREE "/.test"))) die_errno("unable to create directory %s", git_path(NOTES_MERGE_WORKTREE)); @@ -295,8 +295,8 @@ static void write_buf_to_worktree(const unsigned char *obj, const char *buf, unsigned long size) { int fd; - char *path = git_path(NOTES_MERGE_WORKTREE "/%s", sha1_to_hex(obj)); - if (safe_create_leading_directories(path)) + char *path = git_pathdup(NOTES_MERGE_WORKTREE "/%s", sha1_to_hex(obj)); + if (safe_create_leading_directories_const(path)) die_errno("unable to create directory for '%s'", path); if (file_exists(path)) die("found existing file at '%s'", path); @@ -320,6 +320,7 @@ static void write_buf_to_worktree(const unsigned char *obj, } close(fd); + free(path); } static void write_note_to_worktree(const unsigned char *obj, @@ -549,7 +550,7 @@ int notes_merge(struct notes_merge_options *o, o->local_ref, o->remote_ref); /* Dereference o->local_ref into local_sha1 */ - if (read_ref_full(o->local_ref, local_sha1, 0, NULL)) + if (read_ref_full(o->local_ref, 0, local_sha1, NULL)) die("Failed to resolve local notes ref '%s'", o->local_ref); else if (!check_refname_format(o->local_ref, 0) && is_null_sha1(local_sha1)) @@ -594,22 +595,22 @@ int notes_merge(struct notes_merge_options *o, assert(local && remote); /* Find merge bases */ - bases = get_merge_bases(local, remote, 1); + bases = get_merge_bases(local, remote); if (!bases) { base_sha1 = null_sha1; base_tree_sha1 = EMPTY_TREE_SHA1_BIN; if (o->verbosity >= 4) printf("No merge base found; doing history-less merge\n"); } else if (!bases->next) { - base_sha1 = bases->item->object.sha1; - base_tree_sha1 = bases->item->tree->object.sha1; + base_sha1 = bases->item->object.oid.hash; + base_tree_sha1 = bases->item->tree->object.oid.hash; if (o->verbosity >= 4) printf("One merge base found (%.7s)\n", sha1_to_hex(base_sha1)); } else { /* TODO: How to handle multiple merge-bases? */ - base_sha1 = bases->item->object.sha1; - base_tree_sha1 = bases->item->tree->object.sha1; + base_sha1 = bases->item->object.oid.hash; + base_tree_sha1 = bases->item->tree->object.oid.hash; if (o->verbosity >= 3) printf("Multiple merge bases found. Using the first " "(%.7s)\n", sha1_to_hex(base_sha1)); @@ -617,27 +618,27 @@ int notes_merge(struct notes_merge_options *o, if (o->verbosity >= 4) printf("Merging remote commit %.7s into local commit %.7s with " - "merge-base %.7s\n", sha1_to_hex(remote->object.sha1), - sha1_to_hex(local->object.sha1), + "merge-base %.7s\n", oid_to_hex(&remote->object.oid), + oid_to_hex(&local->object.oid), sha1_to_hex(base_sha1)); - if (!hashcmp(remote->object.sha1, base_sha1)) { + if (!hashcmp(remote->object.oid.hash, base_sha1)) { /* Already merged; result == local commit */ if (o->verbosity >= 2) printf("Already up-to-date!\n"); - hashcpy(result_sha1, local->object.sha1); + hashcpy(result_sha1, local->object.oid.hash); goto found_result; } - if (!hashcmp(local->object.sha1, base_sha1)) { + if (!hashcmp(local->object.oid.hash, base_sha1)) { /* Fast-forward; result == remote commit */ if (o->verbosity >= 2) printf("Fast-forward\n"); - hashcpy(result_sha1, remote->object.sha1); + hashcpy(result_sha1, remote->object.oid.hash); goto found_result; } - result = merge_from_diffs(o, base_tree_sha1, local->tree->object.sha1, - remote->tree->object.sha1, local_tree); + result = merge_from_diffs(o, base_tree_sha1, local->tree->object.oid.hash, + remote->tree->object.oid.hash, local_tree); if (result != 0) { /* non-trivial merge (with or without conflicts) */ /* Commit (partial) result */ |