diff options
author | René Scharfe <l.s.r@web.de> | 2020-09-05 17:49:30 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-09-06 23:15:46 +0300 |
commit | 1af8b8c0a570ee0b12a19fdd920a3ea09fb22a75 (patch) | |
tree | cd2da63870b04868b3da654be43241f2b5ce7f48 /remote.c | |
parent | 30035d9c66bc2a52352e3ad42b56047f06c20326 (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 'remote.c')
-rw-r--r-- | remote.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -287,19 +287,15 @@ static void read_branches_file(struct remote *remote) frag = (char *)git_default_branch_name(); add_url_alias(remote, strbuf_detach(&buf, NULL)); - strbuf_addf(&buf, "refs/heads/%s:refs/heads/%s", - frag, remote->name); - refspec_append(&remote->fetch, buf.buf); + refspec_appendf(&remote->fetch, "refs/heads/%s:refs/heads/%s", + frag, remote->name); /* * Cogito compatible push: push current HEAD to remote #branch * (master if missing) */ - strbuf_reset(&buf); - strbuf_addf(&buf, "HEAD:refs/heads/%s", frag); - refspec_append(&remote->push, buf.buf); + refspec_appendf(&remote->push, "HEAD:refs/heads/%s", frag); remote->fetch_tags = 1; /* always auto-follow */ - strbuf_release(&buf); } static int handle_config(const char *key, const char *value, void *cb) |