summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2007-09-10 12:35:05 +0200
committerJunio C Hamano <gitster@pobox.com>2007-09-10 12:48:33 -0700
commit4acfd1b799acf43642a28a22cc794266c25129ef (patch)
treece3f9ee6de2a335e06d600b459c5679710a80f84 /commit.c
parentf1696ee398e92bcea3cdc7b3da85d8e0f77f6c50 (diff)
downloadgit-4acfd1b799acf43642a28a22cc794266c25129ef.tar.gz
Change semantics of interpolate to work like snprintf.
Also fix many off-by-ones and a useless memset. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/commit.c b/commit.c
index 99f65cee0e..25781cc833 100644
--- a/commit.c
+++ b/commit.c
@@ -923,15 +923,14 @@ long format_commit_message(const struct commit *commit, const void *format,
do {
char *buf = *buf_p;
- unsigned long space = *space_p;
+ unsigned long len;
- space = interpolate(buf, space, format,
+ len = interpolate(buf, *space_p, format,
table, ARRAY_SIZE(table));
- if (!space)
+ if (len < *space_p)
break;
- buf = xrealloc(buf, space);
+ ALLOC_GROW(buf, len + 1, *space_p);
*buf_p = buf;
- *space_p = space;
} while (1);
interp_clear_table(table, ARRAY_SIZE(table));