From 264b774ba6b27cc07ef4c33d52e491d9abf029bb Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Sun, 29 Nov 2009 13:18:32 +0100 Subject: merge-recursive: make the error-message generation an extern function The construction of the struct unpack_trees_error_msgs was done within git_merge_trees(), which prevented using the same messages easily from another function. [jc: backported for 1.6.5 maint before advice_commit_before_merge] Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano diff --git a/merge-recursive.c b/merge-recursive.c index f55b7eb..72bfbaf 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -170,18 +170,6 @@ static int git_merge_trees(int index_only, int rc; struct tree_desc t[3]; struct unpack_trees_options opts; - static const struct unpack_trees_error_msgs msgs = { - /* would_overwrite */ - "Your local changes to '%s' would be overwritten by merge. Aborting.", - /* not_uptodate_file */ - "Your local changes to '%s' would be overwritten by merge. Aborting.", - /* not_uptodate_dir */ - "Updating '%s' would lose untracked files in it. Aborting.", - /* would_lose_untracked */ - "Untracked working tree file '%s' would be %s by merge. Aborting", - /* bind_overlap -- will not happen here */ - NULL, - }; memset(&opts, 0, sizeof(opts)); if (index_only) @@ -193,7 +181,7 @@ static int git_merge_trees(int index_only, opts.fn = threeway_merge; opts.src_index = &the_index; opts.dst_index = &the_index; - opts.msgs = msgs; + opts.msgs = get_porcelain_error_msgs(); init_tree_desc_from_tree(t+0, common); init_tree_desc_from_tree(t+1, head); @@ -1180,6 +1168,23 @@ static int process_entry(struct merge_options *o, return clean_merge; } +struct unpack_trees_error_msgs get_porcelain_error_msgs(void) +{ + struct unpack_trees_error_msgs msgs = { + /* would_overwrite */ + "Your local changes to '%s' would be overwritten by merge. Aborting.", + /* not_uptodate_file */ + "Your local changes to '%s' would be overwritten by merge. Aborting.", + /* not_uptodate_dir */ + "Updating '%s' would lose untracked files in it. Aborting.", + /* would_lose_untracked */ + "Untracked working tree file '%s' would be %s by merge. Aborting", + /* bind_overlap -- will not happen here */ + NULL, + }; + return msgs; +} + int merge_trees(struct merge_options *o, struct tree *head, struct tree *merge, diff --git a/merge-recursive.h b/merge-recursive.h index fd138ca..d8bc729 100644 --- a/merge-recursive.h +++ b/merge-recursive.h @@ -17,6 +17,9 @@ struct merge_options { struct string_list current_directory_set; }; +/* Return a list of user-friendly error messages to be used by merge */ +struct unpack_trees_error_msgs get_porcelain_error_msgs(void); + /* merge_trees() but with recursive ancestor consolidation */ int merge_recursive(struct merge_options *o, struct commit *h1, -- cgit v0.10.2-6-g49f6 From e2ced7de19c85f3b246480bfacdcc934c98c08ca Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Sun, 29 Nov 2009 13:18:33 +0100 Subject: builtin-merge: show user-friendly error messages for fast-forward too. fadd069d03 (merge-recursive: give less scary messages when merge did not start, Sep 7 2009) introduced some friendlier error message for merge failure, but the messages were shown only for non-fast forward merges. This patch uses the same for fast-forward. Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano diff --git a/builtin-merge.c b/builtin-merge.c index b6b8428..56ecc68 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -650,6 +650,7 @@ static int checkout_fast_forward(unsigned char *head, unsigned char *remote) opts.verbose_update = 1; opts.merge = 1; opts.fn = twoway_merge; + opts.msgs = get_porcelain_error_msgs(); trees[nr_trees] = parse_tree_indirect(head); if (!trees[nr_trees++]) -- cgit v0.10.2-6-g49f6