Skip to content

Commit ba67aaf

Browse files
avargitster
authored andcommitted
git-sh-i18n--envsubst: our own envsubst(1) for eval_gettext()
Add a git-sh-i18n--envsubst program which is a stripped-down version of the GNU envsubst(1) program that comes with GNU gettext for use in the eval_gettext() fallback. We need a C helper program because implementing eval_gettext() purely in shell turned out to be unworkable. Digging through the Git mailing list archives will reveal two shell implementations of eval_gettext that are almost good enough, but fail on an edge case which is tested for in the tests which are part of this patch. These are the modifications I made to envsubst.c as I turned it into sh-i18n--envsubst.c: * Added our git-compat-util.h header for xrealloc() and friends. * Removed inclusion of gettext-specific headers. * Removed most of main() and replaced it with my own. The modified version only does option parsing for --variables. That's all it needs. * Modified error() invocations to use our error() instead of error(3). * Replaced the gettext XNMALLOC(n, size) macro with just xmalloc(n). Since XNMALLOC() only allocated char's. * Removed the string_list_destroy function. It's redundant (also in the upstream code). * Replaced the use of stdbool.h (a C99 header) by doing the following replacements on the code: * s/bool/unsigned short int/g * s/true/1/g * s/false/0/g Reported-by: Johannes Sixt <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4e3aa87 commit ba67aaf

File tree

5 files changed

+524
-0
lines changed

5 files changed

+524
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
/git-rm
128128
/git-send-email
129129
/git-send-pack
130+
/git-sh-i18n
131+
/git-sh-i18n--envsubst
130132
/git-sh-setup
131133
/git-shell
132134
/git-shortlog
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
git-sh-i18n--envsubst(1)
2+
========================
3+
4+
NAME
5+
----
6+
git-sh-i18n--envsubst - Git's own envsubst(1) for i18n fallbacks
7+
8+
DESCRIPTION
9+
-----------
10+
11+
This is not a command the end user would want to run. Ever.
12+
This documentation is meant for people who are studying the
13+
plumbing scripts and/or are writing new ones.
14+
15+
git-sh-i18n--envsubst is Git's stripped-down copy of the GNU
16+
`envsubst(1)` program that comes with the GNU gettext package. It's
17+
used internally by linkgit:git-sh-i18n[1] to interpolate the variables
18+
passed to the the `eval_gettext` function.
19+
20+
No promises are made about the interface, or that this
21+
program won't disappear without warning in the next version
22+
of Git. Don't use it.
23+
24+
GIT
25+
---
26+
Part of the linkgit:git[1] suite

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ PROGRAM_OBJS += shell.o
414414
PROGRAM_OBJS += show-index.o
415415
PROGRAM_OBJS += upload-pack.o
416416
PROGRAM_OBJS += http-backend.o
417+
PROGRAM_OBJS += sh-i18n--envsubst.o
417418

418419
PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
419420

0 commit comments

Comments
 (0)