diff options
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | 2008-10-18 10:44:18 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-10-18 06:53:47 -0700 |
commit | 59c69c0c656ebce2f7ce870b4913512597a98390 (patch) | |
tree | f2bcd14377a483929861a09cf929286da0f1700a /remote.c | |
parent | b0b44bc7b26c8c4b4221a377ce6ba174b843cb8d (diff) | |
download | git-59c69c0c656ebce2f7ce870b4913512597a98390.tar.gz |
make alloc_ref_from_str() the new alloc_ref()
With all calls to alloc_ref() gone, we can remove it and then we're free
to give alloc_ref_from_str() the shorter name. It's a much nicer
interface, as the callers always need to have a name string when they
allocate a ref anyway and don't need to calculate and pass its length+1
any more.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r-- | remote.c | 21 |
1 files changed, 7 insertions, 14 deletions
@@ -759,15 +759,9 @@ static struct ref *alloc_ref_with_prefix(const char *prefix, size_t prefixlen, return ref; } -struct ref *alloc_ref(unsigned namelen) +struct ref *alloc_ref(const char *name) { - struct ref *ret = xcalloc(1, sizeof(struct ref) + namelen); - return ret; -} - -struct ref *alloc_ref_from_str(const char* str) -{ - return alloc_ref_with_prefix("", 0, str); + return alloc_ref_with_prefix("", 0, name); } static struct ref *copy_ref(const struct ref *ref) @@ -878,20 +872,20 @@ static struct ref *try_explicit_object_name(const char *name) struct ref *ref; if (!*name) { - ref = alloc_ref_from_str("(delete)"); + ref = alloc_ref("(delete)"); hashclr(ref->new_sha1); return ref; } if (get_sha1(name, sha1)) return NULL; - ref = alloc_ref_from_str(name); + ref = alloc_ref(name); hashcpy(ref->new_sha1, sha1); return ref; } static struct ref *make_linked_ref(const char *name, struct ref ***tail) { - struct ref *ret = alloc_ref_from_str(name); + struct ref *ret = alloc_ref(name); tail_link_ref(ret, tail); return ret; } @@ -1196,9 +1190,8 @@ static struct ref *get_local_ref(const char *name) if (!name) return NULL; - if (!prefixcmp(name, "refs/")) { - return alloc_ref_from_str(name); - } + if (!prefixcmp(name, "refs/")) + return alloc_ref(name); if (!prefixcmp(name, "heads/") || !prefixcmp(name, "tags/") || |