summaryrefslogtreecommitdiff
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-09-05 14:49:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-06 20:15:46 (GMT)
commit1af8b8c0a570ee0b12a19fdd920a3ea09fb22a75 (patch)
treecd2da63870b04868b3da654be43241f2b5ce7f48 /builtin/fetch.c
parent30035d9c66bc2a52352e3ad42b56047f06c20326 (diff)
downloadgit-1af8b8c0a570ee0b12a19fdd920a3ea09fb22a75.zip
git-1af8b8c0a570ee0b12a19fdd920a3ea09fb22a75.tar.gz
git-1af8b8c0a570ee0b12a19fdd920a3ea09fb22a75.tar.bz2
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 a6d3268..c555836 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]);
}