
With the new "unsafe" SHA-1 build knob, it is convenient to have a test-tool that can exercise Git's unsafe SHA-1 wrappers for testing, similar to 't/helper/test-tool sha1'. Implement that helper by altering the implementation of that test-tool (in cmd_hash_impl(), which is generic and parameterized over different hash functions) to conditionally run the unsafe variants of the chosen hash function, and expose the new behavior via a new 'sha1-unsafe' test helper. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 lines
365 B
C
21 lines
365 B
C
#include "test-tool.h"
|
|
#include "hash.h"
|
|
|
|
int cmd__sha1(int ac, const char **av)
|
|
{
|
|
return cmd_hash_impl(ac, av, GIT_HASH_SHA1, 0);
|
|
}
|
|
|
|
int cmd__sha1_is_sha1dc(int argc UNUSED, const char **argv UNUSED)
|
|
{
|
|
#ifdef platform_SHA_IS_SHA1DC
|
|
return 0;
|
|
#endif
|
|
return 1;
|
|
}
|
|
|
|
int cmd__sha1_unsafe(int ac, const char **av)
|
|
{
|
|
return cmd_hash_impl(ac, av, GIT_HASH_SHA1, 1);
|
|
}
|