4 int cmd__sha1(int ac, const char **av)
7 unsigned char sha1[20];
13 if (!strcmp(av[1], "-b"))
16 bufsz = strtoul(av[1], NULL, 10) * 1024 * 1024;
22 while ((buffer = malloc(bufsz)) == NULL) {
23 fprintf(stderr, "bufsz %u is too big, halving...\n", bufsz);
34 unsigned room = bufsz;
37 sz = xread(0, cp, room);
41 die_errno("test-sha1");
48 git_SHA1_Update(&ctx, buffer, this_sz);
50 git_SHA1_Final(sha1, &ctx);
53 fwrite(sha1, 1, 20, stdout);
55 puts(sha1_to_hex(sha1));