init_tree_desc(desc, tree->buffer, tree->size);
}
-static int git_merge_trees(struct merge_options *o,
- struct tree *common,
- struct tree *head,
- struct tree *merge)
+static int unpack_trees_start(struct merge_options *o,
+ struct tree *common,
+ struct tree *head,
+ struct tree *merge)
{
int rc;
struct tree_desc t[3];
return rc;
}
+static void unpack_trees_finish(struct merge_options *o)
+{
+ discard_index(&o->orig_index);
+ clear_unpack_trees_porcelain(&o->unpack_opts);
+}
+
struct tree *write_tree_from_memory(struct merge_options *o)
{
struct tree *result = NULL;
output(o, 3, _("Fast-forwarding submodule %s to the following commit:"), path);
output_commit_title(o, commit_b);
} else if (show(o, 2))
- output(o, 2, _("Fast-forwarding submodule %s to %s"), path, oid_to_hex(b));
+ output(o, 2, _("Fast-forwarding submodule %s"), path);
else
; /* no output */
output(o, 3, _("Fast-forwarding submodule %s to the following commit:"), path);
output_commit_title(o, commit_a);
} else if (show(o, 2))
- output(o, 2, _("Fast-forwarding submodule %s to %s"), path, oid_to_hex(a));
+ output(o, 2, _("Fast-forwarding submodule %s"), path);
else
; /* no output */
static struct dir_rename_entry *check_dir_renamed(const char *path,
struct hashmap *dir_renames)
{
- char temp[PATH_MAX];
+ char *temp = xstrdup(path);
char *end;
- struct dir_rename_entry *entry;
+ struct dir_rename_entry *entry = NULL;;
- strcpy(temp, path);
while ((end = strrchr(temp, '/'))) {
*end = '\0';
entry = dir_rename_find_entry(dir_renames, temp);
if (entry)
- return entry;
+ break;
}
- return NULL;
+ free(temp);
+ return entry;
}
static void compute_collisions(struct hashmap *collisions,
return 1;
}
- code = git_merge_trees(o, common, head, merge);
+ code = unpack_trees_start(o, common, head, merge);
if (code != 0) {
if (show(o, 4) || o->call_depth)
err(o, _("merging of trees %s and %s failed"),
oid_to_hex(&head->object.oid),
oid_to_hex(&merge->object.oid));
+ unpack_trees_finish(o);
return -1;
}
hashmap_free(&o->current_file_dir_set, 1);
- if (clean < 0)
+ if (clean < 0) {
+ unpack_trees_finish(o);
return clean;
+ }
}
else
clean = 1;
- /* Free the extra index left from git_merge_trees() */
- /*
- * FIXME: Need to also free data allocated by
- * setup_unpack_trees_porcelain() tucked away in o->unpack_opts.msgs,
- * but the problem is that only half of it refers to dynamically
- * allocated data, while the other half points at static strings.
- */
- discard_index(&o->orig_index);
+ unpack_trees_finish(o);
if (o->call_depth && !(*result = write_tree_from_memory(o)))
return -1;