Skip to content

Commit 045c050

Browse files
committed
Merge branch 'mm/maint-merge-ff-error-message-fix'
Conflicts: merge-recursive.c
2 parents 22c4e72 + e2ced7d commit 045c050

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

builtin-merge.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ static int checkout_fast_forward(unsigned char *head, unsigned char *remote)
656656
opts.verbose_update = 1;
657657
opts.merge = 1;
658658
opts.fn = twoway_merge;
659+
opts.msgs = get_porcelain_error_msgs();
659660

660661
trees[nr_trees] = parse_tree_indirect(head);
661662
if (!trees[nr_trees++])

merge-recursive.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,23 +172,6 @@ static int git_merge_trees(int index_only,
172172
int rc;
173173
struct tree_desc t[3];
174174
struct unpack_trees_options opts;
175-
struct unpack_trees_error_msgs msgs = {
176-
/* would_overwrite */
177-
"Your local changes to '%s' would be overwritten by merge. Aborting.",
178-
/* not_uptodate_file */
179-
"Your local changes to '%s' would be overwritten by merge. Aborting.",
180-
/* not_uptodate_dir */
181-
"Updating '%s' would lose untracked files in it. Aborting.",
182-
/* would_lose_untracked */
183-
"Untracked working tree file '%s' would be %s by merge. Aborting",
184-
/* bind_overlap -- will not happen here */
185-
NULL,
186-
};
187-
if (advice_commit_before_merge) {
188-
msgs.would_overwrite = msgs.not_uptodate_file =
189-
"Your local changes to '%s' would be overwritten by merge. Aborting.\n"
190-
"Please, commit your changes or stash them before you can merge.";
191-
}
192175

193176
memset(&opts, 0, sizeof(opts));
194177
if (index_only)
@@ -200,7 +183,7 @@ static int git_merge_trees(int index_only,
200183
opts.fn = threeway_merge;
201184
opts.src_index = &the_index;
202185
opts.dst_index = &the_index;
203-
opts.msgs = msgs;
186+
opts.msgs = get_porcelain_error_msgs();
204187

205188
init_tree_desc_from_tree(t+0, common);
206189
init_tree_desc_from_tree(t+1, head);
@@ -1188,6 +1171,28 @@ static int process_entry(struct merge_options *o,
11881171
return clean_merge;
11891172
}
11901173

1174+
struct unpack_trees_error_msgs get_porcelain_error_msgs(void)
1175+
{
1176+
struct unpack_trees_error_msgs msgs = {
1177+
/* would_overwrite */
1178+
"Your local changes to '%s' would be overwritten by merge. Aborting.",
1179+
/* not_uptodate_file */
1180+
"Your local changes to '%s' would be overwritten by merge. Aborting.",
1181+
/* not_uptodate_dir */
1182+
"Updating '%s' would lose untracked files in it. Aborting.",
1183+
/* would_lose_untracked */
1184+
"Untracked working tree file '%s' would be %s by merge. Aborting",
1185+
/* bind_overlap -- will not happen here */
1186+
NULL,
1187+
};
1188+
if (advice_commit_before_merge) {
1189+
msgs.would_overwrite = msgs.not_uptodate_file =
1190+
"Your local changes to '%s' would be overwritten by merge. Aborting.\n"
1191+
"Please, commit your changes or stash them before you can merge.";
1192+
}
1193+
return msgs;
1194+
}
1195+
11911196
int merge_trees(struct merge_options *o,
11921197
struct tree *head,
11931198
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)