Re: [PATCH v2 4/5] diff.c: initialize hash algo when running in --no-index mode

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

 



On Sat, Feb 24, 2018 at 10:34 AM, Nguyễn Thái Ngọc Duy
<pclouds@xxxxxxxxx> wrote:
> @@ -3995,6 +3995,18 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
>                 return;
>         }
>
> +       /*
> +        * NEEDSWORK: When running in no-index mode (and no repo is
> +        * found, thus no hash algo conifugred), fall back to SHA-1
> +        * hashing (which is used by diff_fill_oid_info below) to
> +        * avoid regression in diff output.
> +        *
> +        * In future, perhaps we can allow the user to specify their
> +        * hash algorithm from command line in this mode.
> +        */
> +       if (o->flags.no_index && !the_hash_algo)
> +               the_hash_algo = &hash_algos[GIT_HASH_SHA1];

Brian, are we supposed to use the_hash_algo this way (i.e. as a
writable var)? Or should I stick to something like

    repo_set_hash_algo(the_repository, GIT_HASH_SHA1);

which allows us to notify other parts inside struct repository about
the hash algorithm change, if we ever need to?

If the_hash_algo is supposed to be read-only, maybe I should convert
that macro to an inline function to prevent people from accidentally
reassigning it?

> +
>         diff_fill_oid_info(one);
>         diff_fill_oid_info(two);
>
> --
> 2.16.1.435.g8f24da2e1a
>
-- 
Duy




[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