Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [BUG] git-am silently applying patches incorrectly

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:43
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
quoted hunk
...
So here is my exercise for preparing the new code for upcoming i18n.
Does it look sane?

Do we want a new wrapper similar to _() that would easily make this into a
noop under NO_GETTEXT in the proposed i18n infrastructure?

 builtin/apply.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index a231c0c..f084250 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -2644,7 +2644,10 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
 			if (apply_in_reverse)
 				offset = 0 - offset;
 			fprintf(stderr,
+				ngettext(
+				"Hunk #%d succeeded at %d (offset %d line).\n",
 				"Hunk #%d succeeded at %d (offset %d lines).\n",
+				(offset < 0 ? (0 - offset) : offset)),
 				nth_fragment, applied_pos + 1, offset);
 		}
 
If we were to do i18n, we would probably need to include something like
the following in the early fast-tracked part of the series, perhaps as
part of the e6bb27e (i18n: add no-op _() and N_() wrappers, 2011-02-22)



 gettext.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/gettext.h b/gettext.h
index 6949d73..1510c5d 100644
--- a/gettext.h
+++ b/gettext.h
@@ -23,4 +23,10 @@ static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
 /* Mark msgid for translation but do not translate it. */
 #define N_(msgid) (msgid)
 
+static inline const char *ngettext(const char *msgid, const char *plu, unsigned long n)
+{
+	/* fallback ngettext() without using libintl */
+	return (n == 1) ? msgid : plu;
+}
+
 #endif
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help