Re: [PATCH v5 2/8] read-cache: make_cache_entry should take object_id struct
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 28, 2018, 17:14 UTC
- Message-ID
- <xmqqin62ygsp.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180628135932.225288-3-jamill@microsoft.com>
Jameson Miller <jamill@microsoft.com> writes:
> The make_cache_entry function should take an object_id struct instead > of sha.
The name of the hash is SHA-1, not sha ;-)
It is not worth a reroll, but I do not think "should" is a particularly good thing to say in the title or justification in the log message in this case. It is more like you (or somebody else who commented) _want_ to make it take an oid for _some_ reason. "teach make_cache_entry() to take object_id" is probably a better title that admits that we do not explicitly say _why_ we are doing so, than saying "it should", which equally is not explicit ;-)
Show 26 quoted lines
> diff --git a/read-cache.c b/read-cache.c
> index fa8366ecab..9624ce1784 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -746,8 +746,10 @@ int add_file_to_index(struct index_state *istate, const char *path, int flags)
> }
>
> struct cache_entry *make_cache_entry(unsigned int mode,
> - const unsigned char *sha1, const char *path, int stage,
> - unsigned int refresh_options)
> + const struct object_id *oid,
> + const char *path,
> + int stage,
> + unsigned int refresh_options)
> {
> int size, len;
> struct cache_entry *ce, *ret;
> @@ -761,7 +763,7 @@ struct cache_entry *make_cache_entry(unsigned int mode,
> size = cache_entry_size(len);
> ce = xcalloc(1, size);
>
> - hashcpy(ce->oid.hash, sha1);
> + hashcpy(ce->oid.hash, oid->hash);
> memcpy(ce->name, path, len);
> ce->ce_flags = create_ce_flags(stage);
> ce->ce_namelen = len;The patch itself looks good.
Thanks.