diff options
author | Pierre Habouzit <madcoder@debian.org> | 2007-09-10 12:35:05 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-09-10 12:48:33 -0700 |
commit | 4acfd1b799acf43642a28a22cc794266c25129ef (patch) | |
tree | ce3f9ee6de2a335e06d600b459c5679710a80f84 /commit.c | |
parent | f1696ee398e92bcea3cdc7b3da85d8e0f77f6c50 (diff) | |
download | git-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.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -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)); |