mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
http-push: use strbuf instead of fwrite_buffer
The http-push code defines an fwrite_buffer function for use as a curl callback; it just writes to a strbuf. There's no reason we need to use it ourselves, as we know we have a strbuf. This lets us format directly into it, rather than dealing with an extra temporary buffer (which required manual length computation). While we're here, let's also remove the literal tabs from the source in favor of "\t", which is more visually obvious. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
df1ed03a6f
commit
7d0581a9ab
17
http-push.c
17
http-push.c
|
@ -1459,8 +1459,6 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)
|
||||||
{
|
{
|
||||||
struct strbuf *buf = (struct strbuf *)ls->userData;
|
struct strbuf *buf = (struct strbuf *)ls->userData;
|
||||||
struct object *o;
|
struct object *o;
|
||||||
int len;
|
|
||||||
char *ref_info;
|
|
||||||
struct ref *ref;
|
struct ref *ref;
|
||||||
|
|
||||||
ref = alloc_ref(ls->dentry_name);
|
ref = alloc_ref(ls->dentry_name);
|
||||||
|
@ -1484,23 +1482,14 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(ls->dentry_name) + 42;
|
strbuf_addf(buf, "%s\t%s\n",
|
||||||
ref_info = xcalloc(len + 1, 1);
|
|
||||||
sprintf(ref_info, "%s %s\n",
|
|
||||||
sha1_to_hex(ref->old_sha1), ls->dentry_name);
|
sha1_to_hex(ref->old_sha1), ls->dentry_name);
|
||||||
fwrite_buffer(ref_info, 1, len, buf);
|
|
||||||
free(ref_info);
|
|
||||||
|
|
||||||
if (o->type == OBJ_TAG) {
|
if (o->type == OBJ_TAG) {
|
||||||
o = deref_tag(o, ls->dentry_name, 0);
|
o = deref_tag(o, ls->dentry_name, 0);
|
||||||
if (o) {
|
if (o)
|
||||||
len = strlen(ls->dentry_name) + 45;
|
strbuf_addf(buf, "%s\t%s^{}\n",
|
||||||
ref_info = xcalloc(len + 1, 1);
|
|
||||||
sprintf(ref_info, "%s %s^{}\n",
|
|
||||||
sha1_to_hex(o->sha1), ls->dentry_name);
|
sha1_to_hex(o->sha1), ls->dentry_name);
|
||||||
fwrite_buffer(ref_info, 1, len, buf);
|
|
||||||
free(ref_info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free(ref);
|
free(ref);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue