aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-09-05 16:49:30 +0200
committerJunio C Hamano <gitster@pobox.com>2020-09-06 13:15:46 -0700
commit1af8b8c0a570ee0b12a19fdd920a3ea09fb22a75 (patch)
treecd2da63870b04868b3da654be43241f2b5ce7f48 /builtin/fetch.c
parentpush: release strbufs used for refspec formatting (diff)
downloadgit-1af8b8c0a570ee0b12a19fdd920a3ea09fb22a75.tar.gz
git-1af8b8c0a570ee0b12a19fdd920a3ea09fb22a75.zip
refspec: add and use refspec_appendf()
Add a function for building a refspec using printf-style formatting. It frees callers from managing their own buffer. Use it throughout the tree to shorten and simplify its callers. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index a6d3268661..c555836937 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1738,15 +1738,12 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "tag")) {
- char *tag;
i++;
if (i >= argc)
die(_("You need to specify a tag name."));
- tag = xstrfmt("refs/tags/%s:refs/tags/%s",
- argv[i], argv[i]);
- refspec_append(&rs, tag);
- free(tag);
+ refspec_appendf(&rs, "refs/tags/%s:refs/tags/%s",
+ argv[i], argv[i]);
} else {
refspec_append(&rs, argv[i]);
}