1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-30 13:57:54 +01:00

test-sha1-array: convert most code to struct object_id

This helper is very small, so convert the entire thing.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson 2017-03-26 16:01:32 +00:00 committed by Junio C Hamano
parent 9e1d7087dc
commit 57836f10ad

View file

@ -14,16 +14,16 @@ int cmd_main(int argc, const char **argv)
while (strbuf_getline(&line, stdin) != EOF) {
const char *arg;
unsigned char sha1[20];
struct object_id oid;
if (skip_prefix(line.buf, "append ", &arg)) {
if (get_sha1_hex(arg, sha1))
if (get_oid_hex(arg, &oid))
die("not a hexadecimal SHA1: %s", arg);
sha1_array_append(&array, sha1);
sha1_array_append(&array, oid.hash);
} else if (skip_prefix(line.buf, "lookup ", &arg)) {
if (get_sha1_hex(arg, sha1))
if (get_oid_hex(arg, &oid))
die("not a hexadecimal SHA1: %s", arg);
printf("%d\n", sha1_array_lookup(&array, sha1));
printf("%d\n", sha1_array_lookup(&array, oid.hash));
} else if (!strcmp(line.buf, "clear"))
sha1_array_clear(&array);
else if (!strcmp(line.buf, "for_each_unique"))