diff options
author | Karthik Nayak <karthik.188@gmail.com> | 2017-01-10 14:19:50 +0530 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-31 12:43:04 -0800 |
commit | 6eac70fa6343a31b5b310a465a442adb6731a26b (patch) | |
tree | 10a2f4df32a34d24b1f12639aefd10d4f9863b90 /ref-filter.c | |
parent | 1a34728e6bb469083dd46ff35362fdfc6e489d07 (diff) | |
download | git-6eac70fa6343a31b5b310a465a442adb6731a26b.tar.gz |
ref-filter: allow porcelain to translate messages in the output
Introduce setup_ref_filter_porcelain_msg() so that the messages used in
the atom %(upstream:track) can be translated if needed. By default, keep
the messages untranslated, which is the right behavior for plumbing
commands. This is needed as we port branch.c to use ref-filter's
printing API's.
Written-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ref-filter.c')
-rw-r--r-- | ref-filter.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/ref-filter.c b/ref-filter.c index 47e292bc46..01b5c18ef0 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -16,6 +16,27 @@ #include "trailer.h" #include "wt-status.h" +static struct ref_msg { + const char *gone; + const char *ahead; + const char *behind; + const char *ahead_behind; +} msgs = { + /* Untranslated plumbing messages: */ + "gone", + "ahead %d", + "behind %d", + "ahead %d, behind %d" +}; + +void setup_ref_filter_porcelain_msg(void) +{ + msgs.gone = _("gone"); + msgs.ahead = _("ahead %d"); + msgs.behind = _("behind %d"); + msgs.ahead_behind = _("ahead %d, behind %d"); +} + typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type; typedef enum { COMPARE_EQUAL, COMPARE_UNEQUAL, COMPARE_NONE } cmp_status; @@ -1181,15 +1202,15 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname, else if (atom->u.remote_ref.option == RR_TRACK) { if (stat_tracking_info(branch, &num_ours, &num_theirs, NULL)) { - *s = xstrdup("gone"); + *s = xstrdup(msgs.gone); } else if (!num_ours && !num_theirs) *s = ""; else if (!num_ours) - *s = xstrfmt("behind %d", num_theirs); + *s = xstrfmt(msgs.behind, num_theirs); else if (!num_theirs) - *s = xstrfmt("ahead %d", num_ours); + *s = xstrfmt(msgs.ahead, num_ours); else - *s = xstrfmt("ahead %d, behind %d", + *s = xstrfmt(msgs.ahead_behind, num_ours, num_theirs); if (!atom->u.remote_ref.nobracket && *s[0]) { const char *to_free = *s; |