Re: [RFC PATCH 2/2] sha1-name: add core.validateAbbrev & relative core.abbrev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 6, 2018 at 12:27 PM, Ævar Arnfjörð Bjarmason
<avarab@xxxxxxxxx> wrote:

> +This setting changes that to `O(1)`, but with the trade-off that
> +depending on the value of `core.abbrev` way may be printing

s/way may be printing/we may be printing/

> +abbreviated hashes that collide. Too see how likely this is, try

s/Too see/To see/

> +running:

[...]

> +Even without `core.validateAbbrev=false` the results abbreviation
> +already a bit of a probability game.

s/the results abbreviation already a bit of/the resulting abbreviation
is already a bit of/ maybe?

> diff --git a/sha1-name.c b/sha1-name.c
> index 60d9ef3c7e..aa7ccea14d 100644
> --- a/sha1-name.c
> +++ b/sha1-name.c
> @@ -576,6 +576,7 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)
>         struct disambiguate_state ds;
>         struct min_abbrev_data mad;
>         struct object_id oid_ret;
> +       int dar = default_abbrev_relative;
>         if (len < 0) {
>                 unsigned long count = approximate_object_count();
>                 /*
> @@ -602,6 +603,20 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)
>         if (len == GIT_SHA1_HEXSZ || !len)
>                 return GIT_SHA1_HEXSZ;
>
> +       if (dar) {
> +               if (len + dar < MINIMUM_ABBREV) {
> +                       len = MINIMUM_ABBREV;
> +                       dar = 0;
> +               }
> +
> +               if (validate_abbrev) {
> +                       len += dar;
> +               } else {
> +                       hex[len + dar] = 0;
> +                       return len + dar;
> +               }

I wonder what happens if len + dar > GIT_SHA1_HEXSZ

> +       }




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux