From: Kristian Høgsberg Date: Tue, 4 Dec 2007 07:25:46 +0000 (-0500) Subject: Use a strbuf for copying the command line for the reflog. X-Git-Tag: v1.5.4-rc0~85 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2d324efad6a8f4808c5eec8fd299b79ab80a7ba3;p=git.git Use a strbuf for copying the command line for the reflog. Signed-off-by: Kristian Høgsberg Signed-off-by: Junio C Hamano --- diff --git a/builtin-fetch.c b/builtin-fetch.c index de9947e7a..f6d16fe96 100644 --- a/builtin-fetch.c +++ b/builtin-fetch.c @@ -14,7 +14,7 @@ static const char fetch_usage[] = "git-fetch [-a | --append] [--upload-pack name, check_old ? ref->old_sha1 : NULL, 0); @@ -543,16 +543,19 @@ static void set_option(const char *name, const char *value) int cmd_fetch(int argc, const char **argv, const char *prefix) { struct remote *remote; - int i, j, rla_offset; + int i; static const char **refs = NULL; int ref_nr = 0; - int cmd_len = 0; const char *upload_pack = NULL; int keep = 0; + /* Record the command line for the reflog */ + strbuf_addstr(&default_rla, "fetch"); + for (i = 1; i < argc; i++) + strbuf_addf(&default_rla, " %s", argv[i]); + for (i = 1; i < argc; i++) { const char *arg = argv[i]; - cmd_len += strlen(arg); if (arg[0] != '-') break; @@ -613,17 +616,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) usage(fetch_usage); } - for (j = i; j < argc; j++) - cmd_len += strlen(argv[j]); - - default_rla = xmalloc(cmd_len + 5 + argc + 1); - sprintf(default_rla, "fetch"); - rla_offset = strlen(default_rla); - for (j = 1; j < argc; j++) { - sprintf(default_rla + rla_offset, " %s", argv[j]); - rla_offset += strlen(argv[j]) + 1; - } - if (i == argc) remote = remote_get(NULL); else