summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b0b44bc)
raw | patch | inline | side by side (parent: b0b44bc)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sat, 18 Oct 2008 08:44:18 +0000 (10:44 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 18 Oct 2008 13:53:47 +0000 (06:53 -0700) |
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>
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>
builtin-fetch.c | patch | blob | history | |
connect.c | patch | blob | history | |
http-push.c | patch | blob | history | |
remote.c | patch | blob | history | |
remote.h | patch | blob | history | |
transport.c | patch | blob | history | |
walker.c | patch | blob | history |
diff --git a/builtin-fetch.c b/builtin-fetch.c
index ee93d3a93da0267caa485fa552c29d779aecfdf7..e008ee92ab1b2f78541a411603fa812fbb0c7139 100644 (file)
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
will_fetch(head, ref->old_sha1))) {
string_list_insert(ref_name, &new_refs);
- rm = alloc_ref_from_str(ref_name);
- rm->peer_ref = alloc_ref_from_str(ref_name);
+ rm = alloc_ref(ref_name);
+ rm->peer_ref = alloc_ref(ref_name);
hashcpy(rm->old_sha1, ref_sha1);
**tail = rm;
diff --git a/connect.c b/connect.c
index b69060bca0917cf84612f861dbc8be5d1c6f775c..0c50d0a26a493f4505eee16812d14c5d7d1b7392 100644 (file)
--- a/connect.c
+++ b/connect.c
continue;
if (nr_match && !path_match(name, nr_match, match))
continue;
- ref = alloc_ref_from_str(buffer + 41);
+ ref = alloc_ref(buffer + 41);
hashcpy(ref->old_sha1, old_sha1);
*list = ref;
list = &ref->next;
diff --git a/http-push.c b/http-push.c
index 42f4d78e54edbb73d14952f5fb3992f2cebb40ae..5cecef434a7740a3f853462978c3e071b4da7e74 100644 (file)
--- a/http-push.c
+++ b/http-push.c
struct ref *ref;
struct object *obj;
- ref = alloc_ref_from_str(refname);
+ ref = alloc_ref(refname);
if (http_fetch_ref(remote->url, ref) != 0) {
fprintf(stderr,
char *ref_info;
struct ref *ref;
- ref = alloc_ref_from_str(ls->dentry_name);
+ ref = alloc_ref(ls->dentry_name);
if (http_fetch_ref(remote->url, ref) != 0) {
fprintf(stderr,
diff --git a/remote.c b/remote.c
index 44d681da08f954f1c6680e71c022ac607b07db9c..e530a21e5c92e49012c459fba0eb7732672883c2 100644 (file)
--- a/remote.c
+++ b/remote.c
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)
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;
}
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/") ||
diff --git a/remote.h b/remote.h
index c6163ff5b1f7e7c96bedaa9a6b561a9f4a8ed7c2..d2e170ce664c0efd9ded356c171dabf4b26e452c 100644 (file)
--- a/remote.h
+++ b/remote.h
extern const struct refspec *tag_refspec;
-struct ref *alloc_ref(unsigned namelen);
-
-struct ref *alloc_ref_from_str(const char* str);
+struct ref *alloc_ref(const char *name);
struct ref *copy_ref_list(const struct ref *ref);
diff --git a/transport.c b/transport.c
index 3d034759bf78baefcb902aafd106788604fd32bb..cfb73500ec9058e7503787bd3c6de06aa3fed064 100644 (file)
--- a/transport.c
+++ b/transport.c
if (fd < 0)
continue;
- next = alloc_ref_from_str(path->buf + name_offset);
+ next = alloc_ref(path->buf + name_offset);
if (read_in_full(fd, buffer, 40) != 40 ||
get_sha1_hex(buffer, next->old_sha1)) {
close(fd);
(*list)->next->name)) > 0)
list = &(*list)->next;
if (!(*list)->next || cmp < 0) {
- struct ref *next = alloc_ref_from_str(buffer + 41);
+ struct ref *next = alloc_ref(buffer + 41);
buffer[40] = '\0';
if (get_sha1_hex(buffer, next->old_sha1)) {
warning ("invalid SHA-1: %s", buffer);
strbuf_release(&buffer);
- ref = alloc_ref_from_str("HEAD");
+ ref = alloc_ref("HEAD");
if (!walker->fetch_ref(walker, ref) &&
!resolve_remote_symref(ref, refs)) {
ref->next = refs;
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_from_str(e->name);
+ struct ref *ref = alloc_ref(e->name);
hashcpy(ref->old_sha1, e->sha1);
ref->next = result;
result = ref;
diff --git a/walker.c b/walker.c
index 6b4cf70c6af1289501f72cbde78cd04da57293f3..679adab6a0fccef460acaf90b116b8c6cb9bd460 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -191,7 +191,7 @@ static int interpret_target(struct walker *walker, char *target, unsigned char *
if (!get_sha1_hex(target, sha1))
return 0;
if (!check_ref_format(target)) {
- struct ref *ref = alloc_ref_from_str(target);
+ struct ref *ref = alloc_ref(target);
if (!walker->fetch_ref(walker, ref)) {
hashcpy(sha1, ref->old_sha1);
free(ref);