Skip to content

Commit 65029d8

Browse files
committed
Merge branch 'nd/i18n-branch-lego'
Fix yet another message construction by concatenating pieces of sentenes, which is unfriendly to i18n. By Nguyễn Thái Ngọc Duy * nd/i18n-branch-lego: branch: remove lego in i18n tracking info strings
2 parents 0ef576d + 21dfc09 commit 65029d8

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

builtin/branch.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
391391
int show_upstream_ref)
392392
{
393393
int ours, theirs;
394+
char *ref = NULL;
394395
struct branch *branch = branch_get(branch_name);
395396

396397
if (!stat_tracking_info(branch, &ours, &theirs)) {
@@ -401,16 +402,29 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
401402
return;
402403
}
403404

404-
strbuf_addch(stat, '[');
405405
if (show_upstream_ref)
406-
strbuf_addf(stat, "%s: ",
407-
shorten_unambiguous_ref(branch->merge[0]->dst, 0));
408-
if (!ours)
409-
strbuf_addf(stat, _("behind %d] "), theirs);
410-
else if (!theirs)
411-
strbuf_addf(stat, _("ahead %d] "), ours);
412-
else
413-
strbuf_addf(stat, _("ahead %d, behind %d] "), ours, theirs);
406+
ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
407+
if (!ours) {
408+
if (ref)
409+
strbuf_addf(stat, _("[%s: behind %d]"), ref, theirs);
410+
else
411+
strbuf_addf(stat, _("[behind %d]"), theirs);
412+
413+
} else if (!theirs) {
414+
if (ref)
415+
strbuf_addf(stat, _("[%s: ahead %d]"), ref, ours);
416+
else
417+
strbuf_addf(stat, _("[ahead %d]"), ours);
418+
} else {
419+
if (ref)
420+
strbuf_addf(stat, _("[%s: ahead %d, behind %d]"),
421+
ref, ours, theirs);
422+
else
423+
strbuf_addf(stat, _("[ahead %d, behind %d]"),
424+
ours, theirs);
425+
}
426+
strbuf_addch(stat, ' ');
427+
free(ref);
414428
}
415429

416430
static int matches_merge_filter(struct commit *commit)

0 commit comments

Comments
 (0)