@matheusbsbs / matheus-bagliano / commits / 264b774ba6
Fork 0

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 <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed Nov 29, 2009 at 13:18 UTC 264b774ba6b27cc07ef4c33d52e491d9abf029bb
2 files changed +21 -13
merge-recursive.c
+18 -13
@@ -170,18 +170,6 @@ static int git_merge_trees(int index_only,
170 int rc;
171 struct tree_desc t[3];
172 struct unpack_trees_options opts;
173 - static const struct unpack_trees_error_msgs msgs = {
174 - /* would_overwrite */
175 - "Your local changes to '%s' would be overwritten by merge. Aborting.",
176 - /* not_uptodate_file */
177 - "Your local changes to '%s' would be overwritten by merge. Aborting.",
178 - /* not_uptodate_dir */
179 - "Updating '%s' would lose untracked files in it. Aborting.",
180 - /* would_lose_untracked */
181 - "Untracked working tree file '%s' would be %s by merge. Aborting",
182 - /* bind_overlap -- will not happen here */
183 - NULL,
184 - };
173
174 memset(&opts, 0, sizeof(opts));
175 if (index_only)
@@ -193,7 +181,7 @@ static int git_merge_trees(int index_only,
181 opts.fn = threeway_merge;
182 opts.src_index = &the_index;
183 opts.dst_index = &the_index;
196 - opts.msgs = msgs;
184 + opts.msgs = get_porcelain_error_msgs();
185
186 init_tree_desc_from_tree(t+0, common);
187 init_tree_desc_from_tree(t+1, head);
@@ -1180,6 +1168,23 @@ static int process_entry(struct merge_options *o,
1168 return clean_merge;
1169 }
1170
1171 +struct unpack_trees_error_msgs get_porcelain_error_msgs(void)
1172 +{
1173 + struct unpack_trees_error_msgs msgs = {
1174 + /* would_overwrite */
1175 + "Your local changes to '%s' would be overwritten by merge. Aborting.",
1176 + /* not_uptodate_file */
1177 + "Your local changes to '%s' would be overwritten by merge. Aborting.",
1178 + /* not_uptodate_dir */
1179 + "Updating '%s' would lose untracked files in it. Aborting.",
1180 + /* would_lose_untracked */
1181 + "Untracked working tree file '%s' would be %s by merge. Aborting",
1182 + /* bind_overlap -- will not happen here */
1183 + NULL,
1184 + };
1185 + return msgs;
1186 +}
1187 +
1188 int merge_trees(struct merge_options *o,
1189 struct tree *head,
1190 struct tree *merge,
merge-recursive.h
+3
@@ -17,6 +17,9 @@ struct merge_options {
17 struct string_list current_directory_set;
18 };
19
20 +/* Return a list of user-friendly error messages to be used by merge */
21 +struct unpack_trees_error_msgs get_porcelain_error_msgs(void);
22 +
23 /* merge_trees() but with recursive ancestor consolidation */
24 int merge_recursive(struct merge_options *o,
25 struct commit *h1,