Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-09-05 17:49:30 +0300
committerJunio C Hamano <gitster@pobox.com>2020-09-06 23:15:46 +0300
commit1af8b8c0a570ee0b12a19fdd920a3ea09fb22a75 (patch)
treecd2da63870b04868b3da654be43241f2b5ce7f48 /builtin/fetch.c
parent30035d9c66bc2a52352e3ad42b56047f06c20326 (diff)
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 a6d32686611..c5558369375 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]);
}