Re: [PATCH v2 4/5] diff.c: initialize hash algo when running in --no-index mode
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Feb 24, 2018, 14:36 UTC
- Message-ID
- <CACsJy8AUXf4uA-zymrhWUagW84bUzfB6JBQLyaHDJtudTcNy=A@mail.gmail.com>
- In-Reply-To
- <20180224033429.9656-5-pclouds@gmail.com>
On Sat, Feb 24, 2018 at 10:34 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 15 quoted lines
> @@ -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?
Show 7 quoted lines
> + > diff_fill_oid_info(one); > diff_fill_oid_info(two); > > -- > 2.16.1.435.g8f24da2e1a >
-- Duy