Skip to content

Commit

Permalink
Merge branch 'mm/maint-merge-ff-error-message-fix'
Browse files Browse the repository at this point in the history
Conflicts:
	merge-recursive.c
  • Loading branch information
Junio C Hamano committed Nov 30, 2009
2 parents 22c4e72 + e2ced7d commit 045c050
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions builtin-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,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++])
Expand Down
41 changes: 23 additions & 18 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,6 @@ static int git_merge_trees(int index_only,
int rc;
struct tree_desc t[3];
struct unpack_trees_options opts;
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,
};
if (advice_commit_before_merge) {
msgs.would_overwrite = msgs.not_uptodate_file =
"Your local changes to '%s' would be overwritten by merge. Aborting.\n"
"Please, commit your changes or stash them before you can merge.";
}

memset(&opts, 0, sizeof(opts));
if (index_only)
Expand All @@ -200,7 +183,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);
Expand Down Expand Up @@ -1188,6 +1171,28 @@ 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,
};
if (advice_commit_before_merge) {
msgs.would_overwrite = msgs.not_uptodate_file =
"Your local changes to '%s' would be overwritten by merge. Aborting.\n"
"Please, commit your changes or stash them before you can merge.";
}
return msgs;
}

int merge_trees(struct merge_options *o,
struct tree *head,
struct tree *merge,
Expand Down
3 changes: 3 additions & 0 deletions merge-recursive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 045c050

Please sign in to comment.