Skip to content

Commit 264b774

Browse files
moygitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 78d553b commit 264b774

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

merge-recursive.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,6 @@ static int git_merge_trees(int index_only,
170170
int rc;
171171
struct tree_desc t[3];
172172
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-
};
185173

186174
memset(&opts, 0, sizeof(opts));
187175
if (index_only)
@@ -193,7 +181,7 @@ static int git_merge_trees(int index_only,
193181
opts.fn = threeway_merge;
194182
opts.src_index = &the_index;
195183
opts.dst_index = &the_index;
196-
opts.msgs = msgs;
184+
opts.msgs = get_porcelain_error_msgs();
197185

198186
init_tree_desc_from_tree(t+0, common);
199187
init_tree_desc_from_tree(t+1, head);
@@ -1180,6 +1168,23 @@ static int process_entry(struct merge_options *o,
11801168
return clean_merge;
11811169
}
11821170

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+
11831188
int merge_trees(struct merge_options *o,
11841189
struct tree *head,
11851190
struct tree *merge,

merge-recursive.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ struct merge_options {
1717
struct string_list current_directory_set;
1818
};
1919

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+
2023
/* merge_trees() but with recursive ancestor consolidation */
2124
int merge_recursive(struct merge_options *o,
2225
struct commit *h1,

0 commit comments

Comments
 (0)