]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit: use strbuf_add() to add a length-limited string
authorRené Scharfe <l.s.r@web.de>
Sat, 7 Dec 2019 11:16:04 +0000 (12:16 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Dec 2019 19:25:27 +0000 (11:25 -0800)
This is shorter and simpler.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c

index 1c9e8e2228c7ce58375bc247c4ad5850a1bd7d2d..599fd10a3e77c490f40e216d72aabee652d85040 100644 (file)
@@ -534,7 +534,7 @@ static void export_one(const char *var, const char *s, const char *e, int hack)
        struct strbuf buf = STRBUF_INIT;
        if (hack)
                strbuf_addch(&buf, hack);
-       strbuf_addf(&buf, "%.*s", (int)(e - s), s);
+       strbuf_add(&buf, s, e - s);
        setenv(var, buf.buf, 1);
        strbuf_release(&buf);
 }