4 int cmd_hash_impl(int ac
, const char **av
, int algo
)
7 unsigned char hash
[GIT_MAX_HEXSZ
];
11 const struct git_hash_algo
*algop
= &hash_algos
[algo
];
14 if (!strcmp(av
[1], "-b"))
17 bufsz
= strtoul(av
[1], NULL
, 10) * 1024 * 1024;
23 while ((buffer
= malloc(bufsz
)) == NULL
) {
24 fprintf(stderr
, "bufsz %u is too big, halving...\n", bufsz
);
35 unsigned room
= bufsz
;
38 sz
= xread(0, cp
, room
);
42 die_errno("test-hash");
49 algop
->update_fn(&ctx
, buffer
, this_sz
);
51 algop
->final_fn(hash
, &ctx
);
54 fwrite(hash
, 1, algop
->rawsz
, stdout
);
56 puts(hash_to_hex_algop(hash
, algop
));