aboutsummaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorKrzysztof Kowalczyk <kkowalczyk@gmail.com>2008-05-10 16:26:58 -0700
committerJunio C Hamano <gitster@pobox.com>2008-05-11 09:04:37 -0700
commit737922aa648c43bc6a61170bee5bfd46ff953f32 (patch)
treeebcdb2c587f0a5b781f0613a711f5501d6b89860 /transport.c
parent1f8115b113def8ee03701aa87b26c5e8b7c94434 (diff)
downloadgit-737922aa648c43bc6a61170bee5bfd46ff953f32.tar.gz
git-737922aa648c43bc6a61170bee5bfd46ff953f32.tar.xz
alloc_ref_from_str(): factor out a common pattern of alloc_ref from string
Also fix an underallocation in walker.c::interpret_target(). Signed-off-by: Krzysztof Kowalczyk <kkowalczyk@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/transport.c b/transport.c
index b012a2833..1bc16f2b6 100644
--- a/transport.c
+++ b/transport.c
@@ -504,8 +504,7 @@ static struct ref *get_refs_via_curl(struct transport *transport)
strbuf_release(&buffer);
- ref = alloc_ref(strlen("HEAD") + 1);
- strcpy(ref->name, "HEAD");
+ ref = alloc_ref_from_str("HEAD");
if (!walker->fetch_ref(walker, ref) &&
!resolve_remote_symref(ref, refs)) {
ref->next = refs;
@@ -546,9 +545,8 @@ static struct ref *get_refs_from_bundle(struct transport *transport)
die ("Could not read bundle '%s'.", transport->url);
for (i = 0; i < data->header.references.nr; i++) {
struct ref_list_entry *e = data->header.references.list + i;
- struct ref *ref = alloc_ref(strlen(e->name) + 1);
+ struct ref *ref = alloc_ref_from_str(e->name);
hashcpy(ref->old_sha1, e->sha1);
- strcpy(ref->name, e->name);
ref->next = result;
result = ref;
}