summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2010-08-11 08:38:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-08-11 17:36:00 (GMT)
commit08353ebbab2dfdee50a6daa616ec8b6483cb07c8 (patch)
tree57062a345dc79288eac8aa243ecbf16cd5d12d67 /merge-recursive.c
parent64fdc08dac6694d1e754580e7acb82dfa4988bb9 (diff)
downloadgit-08353ebbab2dfdee50a6daa616ec8b6483cb07c8.zip
git-08353ebbab2dfdee50a6daa616ec8b6483cb07c8.tar.gz
git-08353ebbab2dfdee50a6daa616ec8b6483cb07c8.tar.bz2
Turn unpack_trees_options.msgs into an array + enum
The list of error messages was introduced as a structure, but an array indexed over an enum is more flexible, since it allows one to store a type of error message (index in the array) in a variable. This change needs to rename would_lose_untracked -> would_lose_untracked_file to avoid a clash with the function would_lose_untracked in merge-recursive.c. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index fb6aa4a..d3bd963 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -185,7 +185,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 = get_porcelain_error_msgs();
+ set_porcelain_error_msgs(opts.msgs);
init_tree_desc_from_tree(t+0, common);
init_tree_desc_from_tree(t+1, head);
@@ -1178,26 +1178,19 @@ static int process_entry(struct merge_options *o,
return clean_merge;
}
-struct unpack_trees_error_msgs get_porcelain_error_msgs(void)
+void set_porcelain_error_msgs(const char **msgs)
{
- 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 =
+ if (advice_commit_before_merge)
+ msgs[ERROR_WOULD_OVERWRITE] = msgs[ERROR_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;
+ else
+ msgs[ERROR_WOULD_OVERWRITE] = msgs[ERROR_NOT_UPTODATE_FILE] =
+ "Your local changes to '%s' would be overwritten by merge. Aborting.";
+ msgs[ERROR_NOT_UPTODATE_DIR] =
+ "Updating '%s' would lose untracked files in it. Aborting.";
+ msgs[ERROR_WOULD_LOSE_UNTRACKED] =
+ "Untracked working tree file '%s' would be %s by merge. Aborting";
}
int merge_trees(struct merge_options *o,