From ae8e4c9ce10ea9439a88b79a40aeff4696d40416 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 7 Nov 2011 13:26:22 -0800 Subject: merge: make usage of commit->util more extensible The merge-recursive code uses the commit->util field directly to annotate the commit objects given from the command line, i.e. the remote heads to be merged, with a single string to be used to describe it in its trace messages and conflict markers. Correct this short-signtedness by redefining the field to be a pointer to a structure "struct merge_remote_desc" that later enhancements can add more information. Store the original objects we were told to merge in a field "obj" in this struct, so that we can recover the tag we were told to merge. Signed-off-by: Junio C Hamano --- commit.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'commit.c') diff --git a/commit.c b/commit.c index 73b7e00292..83ff5035a7 100644 --- a/commit.c +++ b/commit.c @@ -894,3 +894,22 @@ int commit_tree(const char *msg, unsigned char *tree, strbuf_release(&buffer); return result; } + +struct commit *get_merge_parent(const char *name) +{ + struct object *obj; + struct commit *commit; + unsigned char sha1[20]; + if (get_sha1(name, sha1)) + return NULL; + obj = parse_object(sha1); + commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT); + if (commit && !commit->util) { + struct merge_remote_desc *desc; + desc = xmalloc(sizeof(*desc)); + desc->obj = obj; + desc->name = strdup(name); + commit->util = desc; + } + return commit; +} -- cgit v1.2.1