http-push: convert process_ls_object and descendants to object_id

Rename one function to reflect that it now uses struct object_id. This conversion is a prerequisite for converting parse_object. Note that while the use of a buffer that is exactly forty bytes long looks questionable, get_oid_hex reads exactly the right number of bytes and does not require the data to be NUL-terminated. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 6, 2017 at 22:10 UTC 1aa40df6b15c1114264ba19897579cec9f063f30
1 file changed +11 -11
http-push.c
+11 -11
@@ -718,13 +718,13 @@ static int fetch_indices(void)
718 return ret;
719 }
720
721 -static void one_remote_object(const unsigned char *sha1)
721 +static void one_remote_object(const struct object_id *oid)
722 {
723 struct object *obj;
724
725 - obj = lookup_object(sha1);
725 + obj = lookup_object(oid->hash);
726 if (!obj)
727 - obj = parse_object(sha1);
727 + obj = parse_object(oid->hash);
728
729 /* Ignore remote objects that don't exist locally */
730 if (!obj)
@@ -1013,26 +1013,26 @@ static void remote_ls(const char *path, int flags,
1013 void *userData);
1014
1015 /* extract hex from sharded "xx/x{40}" filename */
1016 -static int get_sha1_hex_from_objpath(const char *path, unsigned char *sha1)
1016 +static int get_oid_hex_from_objpath(const char *path, struct object_id *oid)
1017 {
1018 - char hex[40];
1018 + char hex[GIT_MAX_HEXSZ];
1019
1020 - if (strlen(path) != 41)
1020 + if (strlen(path) != GIT_SHA1_HEXSZ + 1)
1021 return -1;
1022
1023 memcpy(hex, path, 2);
1024 path += 2;
1025 path++; /* skip '/' */
1026 - memcpy(hex, path, 38);
1026 + memcpy(hex, path, GIT_SHA1_HEXSZ - 2);
1027
1028 - return get_sha1_hex(hex, sha1);
1028 + return get_oid_hex(hex, oid);
1029 }
1030
1031 static void process_ls_object(struct remote_ls_ctx *ls)
1032 {
1033 unsigned int *parent = (unsigned int *)ls->userData;
1034 const char *path = ls->dentry_name;
1035 - unsigned char sha1[20];
1035 + struct object_id oid;
1036
1037 if (!strcmp(ls->path, ls->dentry_name) && (ls->flags & IS_DIR)) {
1038 remote_dir_exists[*parent] = 1;
@@ -1040,10 +1040,10 @@ static void process_ls_object(struct remote_ls_ctx *ls)
1040 }
1041
1042 if (!skip_prefix(path, "objects/", &path) ||
1043 - get_sha1_hex_from_objpath(path, sha1))
1043 + get_oid_hex_from_objpath(path, &oid))
1044 return;
1045
1046 - one_remote_object(sha1);
1046 + one_remote_object(&oid);
1047 }
1048
1049 static void process_ls_ref(struct remote_ls_ctx *ls)