Adds a new function that will be used in a later patch as well as the current code to reduce redundancy. Signed-off-by: Jared Hance <jaredhance@xxxxxxxxx> --- builtin/merge.c | 32 +++++++++++++++++++------------- 1 files changed, 19 insertions(+), 13 deletions(-) diff --git a/builtin/merge.c b/builtin/merge.c index 42fff38..bc1ae94 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -911,6 +911,24 @@ static int evaluate_result(void) return cnt; } +static void setup_merge_commit(struct strbuf *buf, + struct commit_list ***remotes, const char *s) +{ + struct object *o; + struct commit *commit; + + o = peel_to_type(s, 0, NULL, OBJ_COMMIT); + if (!o) + die("%s - not something we can merge", s); + commit = lookup_commit(o->sha1); + commit->util = (void *)s; + *remotes = &commit_list_insert(commit, *remotes)->next; + + strbuf_addf(buf, "GITHEAD_%s", sha1_to_hex(o->sha1)); + setenv(buf->buf, s, 1); + strbuf_reset(buf); +} + int cmd_merge(int argc, const char **argv, const char *prefix) { unsigned char result_tree[20]; @@ -1059,19 +1077,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) strbuf_reset(&buf); for (i = 0; i < argc; i++) { - struct object *o; - struct commit *commit; - - o = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT); - if (!o) - die("%s - not something we can merge", argv[i]); - commit = lookup_commit(o->sha1); - commit->util = (void *)argv[i]; - remotes = &commit_list_insert(commit, remotes)->next; - - strbuf_addf(&buf, "GITHEAD_%s", sha1_to_hex(o->sha1)); - setenv(buf.buf, argv[i], 1); - strbuf_reset(&buf); + setup_merge_commit(&buf, &remotes, argv[i]); } if (!use_strategies) { -- 1.7.4 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html