Skip to content

Commit 325f3a8

Browse files
stefanbellergitster
authored andcommitted
merge-recursive: i18n submodule merge output and respect verbosity
The submodule merge code now uses the output() function that is used by all the rest of the merge-recursive-code. This allows for respecting internationalisation as well as the verbosity setting. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 18cfc08 commit 325f3a8

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

merge-recursive.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,18 +1048,17 @@ static void print_commit(struct commit *commit)
10481048
strbuf_release(&sb);
10491049
}
10501050

1051-
#define MERGE_WARNING(path, msg) \
1052-
warning("Failed to merge submodule %s (%s)", path, msg);
1053-
1054-
static int merge_submodule(struct object_id *result, const char *path,
1051+
static int merge_submodule(struct merge_options *o,
1052+
struct object_id *result, const char *path,
10551053
const struct object_id *base, const struct object_id *a,
1056-
const struct object_id *b, int search)
1054+
const struct object_id *b)
10571055
{
10581056
struct commit *commit_base, *commit_a, *commit_b;
10591057
int parent_count;
10601058
struct object_array merges;
10611059

10621060
int i;
1061+
int search = !o->call_depth;
10631062

10641063
/* store a in result in case we fail */
10651064
oidcpy(result, a);
@@ -1073,21 +1072,21 @@ static int merge_submodule(struct object_id *result, const char *path,
10731072
return 0;
10741073

10751074
if (add_submodule_odb(path)) {
1076-
MERGE_WARNING(path, "not checked out");
1075+
output(o, 1, _("Failed to merge submodule %s (not checked out)"), path);
10771076
return 0;
10781077
}
10791078

10801079
if (!(commit_base = lookup_commit_reference(base)) ||
10811080
!(commit_a = lookup_commit_reference(a)) ||
10821081
!(commit_b = lookup_commit_reference(b))) {
1083-
MERGE_WARNING(path, "commits not present");
1082+
output(o, 1, _("Failed to merge submodule %s (commits not present)"), path);
10841083
return 0;
10851084
}
10861085

10871086
/* check whether both changes are forward */
10881087
if (!in_merge_bases(commit_base, commit_a) ||
10891088
!in_merge_bases(commit_base, commit_b)) {
1090-
MERGE_WARNING(path, "commits don't follow merge-base");
1089+
output(o, 1, _("Failed to merge submodule %s (commits don't follow merge-base)"), path);
10911090
return 0;
10921091
}
10931092

@@ -1116,25 +1115,24 @@ static int merge_submodule(struct object_id *result, const char *path,
11161115
parent_count = find_first_merges(&merges, path, commit_a, commit_b);
11171116
switch (parent_count) {
11181117
case 0:
1119-
MERGE_WARNING(path, "merge following commits not found");
1118+
output(o, 1, _("Failed to merge submodule %s (merge following commits not found)"), path);
11201119
break;
11211120

11221121
case 1:
1123-
MERGE_WARNING(path, "not fast-forward");
1124-
fprintf(stderr, "Found a possible merge resolution "
1125-
"for the submodule:\n");
1122+
output(o, 1, _("Failed to merge submodule %s (not fast-forward)"), path);
1123+
output(o, 2, _("Found a possible merge resolution for the submodule:\n"));
11261124
print_commit((struct commit *) merges.objects[0].item);
1127-
fprintf(stderr,
1125+
output(o, 2, _(
11281126
"If this is correct simply add it to the index "
11291127
"for example\n"
11301128
"by using:\n\n"
11311129
" git update-index --cacheinfo 160000 %s \"%s\"\n\n"
1132-
"which will accept this suggestion.\n",
1130+
"which will accept this suggestion.\n"),
11331131
oid_to_hex(&merges.objects[0].item->oid), path);
11341132
break;
11351133

11361134
default:
1137-
MERGE_WARNING(path, "multiple merges found");
1135+
output(o, 1, _("Failed to merge submodule %s (multiple merges found)"), path);
11381136
for (i = 0; i < merges.nr; i++)
11391137
print_commit((struct commit *) merges.objects[i].item);
11401138
}
@@ -1205,12 +1203,11 @@ static int merge_file_1(struct merge_options *o,
12051203
return ret;
12061204
result->clean = (merge_status == 0);
12071205
} else if (S_ISGITLINK(a->mode)) {
1208-
result->clean = merge_submodule(&result->oid,
1206+
result->clean = merge_submodule(o, &result->oid,
12091207
one->path,
12101208
&one->oid,
12111209
&a->oid,
1212-
&b->oid,
1213-
!o->call_depth);
1210+
&b->oid);
12141211
} else if (S_ISLNK(a->mode)) {
12151212
switch (o->recursive_variant) {
12161213
case MERGE_RECURSIVE_NORMAL:

0 commit comments

Comments
 (0)