Derrick Stolee <dsto...@microsoft.com> writes:

> diff --git a/t/helper/test-abbrev.c b/t/helper/test-abbrev.c
> new file mode 100644
> index 000000000..6866896eb
> --- /dev/null
> +++ b/t/helper/test-abbrev.c
> @@ -0,0 +1,19 @@
> +#include "cache.h"
> +#include <stdio.h>

Same comment on <stdio.h> as [1/5] applies.

> +
> +int cmd_main(int ac, const char **av)
> +{
> +     struct object_id oid;
> +     char hex[GIT_MAX_HEXSZ + 2];

Why +2 (as opposed to +1)?

> +     const char *end;
> +
> +     setup_git_directory();
> +
> +     while (fgets(hex, GIT_MAX_HEXSZ + 2, stdin)) {
> +             hex[GIT_MAX_HEXSZ] = 0;
> +             if (!parse_oid_hex(hex, &oid, &end))
> +                     find_unique_abbrev(oid.hash, MINIMUM_ABBREV);
> +     }
> +
> +     exit(0);
> +}
> diff --git a/t/perf/p0008-abbrev.sh b/t/perf/p0008-abbrev.sh
> new file mode 100755
> index 000000000..ba25e7824
> --- /dev/null
> +++ b/t/perf/p0008-abbrev.sh
> @@ -0,0 +1,22 @@
> +#!/bin/bash
> +
> +test_description='Test object disambiguation through abbreviations'
> +. ./perf-lib.sh
> +
> +test_perf_large_repo
> +
> +test-list-objects 100000 | sort -R > objs.txt

I thought "sort randomly" was a GNUism.  Does it work across
platforms?  I think not.

> +
> +test_perf 'find_unique_abbrev() for existing objects' '
> +     test-abbrev < objs.txt
> +'
> +
> +test-list-objects 100000 --missing | sort -R > objs.txt
> +
> +test_perf 'find_unique_abbrev() for missing objects' '
> +     test-abbrev < objs.txt
> +'
> +
> +rm objs.txt
> +
> +test_done

Reply via email to