From 55246aac6717e86c14f31391ac903ed810d1a9a0 Mon Sep 17 00:00:00 2001 From: Michal Vitecek Date: Tue, 25 Sep 2007 16:38:46 +0200 Subject: Don't use "" for placeholders and suppress printing of empty user formats. This changes the interporate() to replace entries with NULL values by the empty string, and uses it to interpolate missing fields in custom format output used in git-log and friends. It is most useful to avoid output from %b format for a commit log message that lack any body text. Signed-off-by: Junio C Hamano --- interpolate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'interpolate.c') diff --git a/interpolate.c b/interpolate.c index 00826778f..2f727cd05 100644 --- a/interpolate.c +++ b/interpolate.c @@ -76,8 +76,12 @@ unsigned long interpolate(char *result, unsigned long reslen, /* Check for valid interpolation. */ if (i < ninterps) { value = interps[i].value; - valuelen = strlen(value); + if (!value) { + src += namelen; + continue; + } + valuelen = strlen(value); if (newlen + valuelen + 1 < reslen) { /* Substitute. */ strncpy(dest, value, valuelen); -- cgit v1.2.1