Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
get_remote_heads: convert to struct object_id
author
brian m. carlson
<sandals@crustytoothpaste.net>
Tue, 10 Nov 2015 02:22:23 +0000
(
02:22
+0000)
committer
Jeff King
<peff@peff.net>
Fri, 20 Nov 2015 13:02:05 +0000
(08:02 -0500)
Replace an unsigned char array with struct object_id and express several
hard-coded constants in terms of GIT_SHA1_HEXSZ.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Jeff King <peff@peff.net>
connect.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
8338c91
)
diff --git
a/connect.c
b/connect.c
index d13a10a94c72a2d7e3272393fb5a1a502720e204..fd7ffe1840e64417cf94d208840cf97c91e962b7 100644
(file)
--- a/
connect.c
+++ b/
connect.c
@@
-120,7
+120,7
@@
struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
*list = NULL;
for (;;) {
struct ref *ref;
*list = NULL;
for (;;) {
struct ref *ref;
-
unsigned char old_sha1[20]
;
+
struct object_id old_oid
;
char *name;
int len, name_len;
char *buffer = packet_buffer;
char *name;
int len, name_len;
char *buffer = packet_buffer;
@@
-139,34
+139,36
@@
struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
if (len > 4 && skip_prefix(buffer, "ERR ", &arg))
die("remote error: %s", arg);
if (len > 4 && skip_prefix(buffer, "ERR ", &arg))
die("remote error: %s", arg);
- if (len == 48 && skip_prefix(buffer, "shallow ", &arg)) {
- if (get_sha1_hex(arg, old_sha1))
+ if (len == GIT_SHA1_HEXSZ + strlen("shallow ") &&
+ skip_prefix(buffer, "shallow ", &arg)) {
+ if (get_oid_hex(arg, &old_oid))
die("protocol error: expected shallow sha-1, got '%s'", arg);
if (!shallow_points)
die("repository on the other end cannot be shallow");
die("protocol error: expected shallow sha-1, got '%s'", arg);
if (!shallow_points)
die("repository on the other end cannot be shallow");
- sha1_array_append(shallow_points, old_
sha1
);
+ sha1_array_append(shallow_points, old_
oid.hash
);
continue;
}
continue;
}
- if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
+ if (len < GIT_SHA1_HEXSZ + 2 || get_oid_hex(buffer, &old_oid) ||
+ buffer[GIT_SHA1_HEXSZ] != ' ')
die("protocol error: expected sha/ref, got '%s'", buffer);
die("protocol error: expected sha/ref, got '%s'", buffer);
- name = buffer +
4
1;
+ name = buffer +
GIT_SHA1_HEXSZ +
1;
name_len = strlen(name);
name_len = strlen(name);
- if (len != name_len +
4
1) {
+ if (len != name_len +
GIT_SHA1_HEXSZ +
1) {
free(server_capabilities);
server_capabilities = xstrdup(name + name_len + 1);
}
if (extra_have && !strcmp(name, ".have")) {
free(server_capabilities);
server_capabilities = xstrdup(name + name_len + 1);
}
if (extra_have && !strcmp(name, ".have")) {
- sha1_array_append(extra_have, old_
sha1
);
+ sha1_array_append(extra_have, old_
oid.hash
);
continue;
}
if (!check_ref(name, flags))
continue;
continue;
}
if (!check_ref(name, flags))
continue;
- ref = alloc_ref(buffer +
4
1);
-
hashcpy(ref->old_oid.hash, old_sha1
);
+ ref = alloc_ref(buffer +
GIT_SHA1_HEXSZ +
1);
+
oidcpy(&ref->old_oid, &old_oid
);
*list = ref;
list = &ref->next;
got_at_least_one_head = 1;
*list = ref;
list = &ref->next;
got_at_least_one_head = 1;