Brandon Williams <bmw...@google.com> writes:

> Convert the remaining parts of grep to use struct object_id.
>
> Signed-off-by: Brandon Williams <bmw...@google.com>
> ---
>  builtin/grep.c | 22 +++++++++++-----------
>  cache.h        |  7 +++++++
>  grep.c         | 17 ++++++++---------
>  grep.h         |  2 +-
>  4 files changed, 27 insertions(+), 21 deletions(-)
> ...
> +static inline struct object_id *oiddup(const struct object_id *src)
> +{
> +     struct object_id *dst = xmalloc(sizeof(struct object_id));
> +     oidcpy(dst, src);
> +     return dst;
> +}
> +
>  static inline void hashclr(unsigned char *hash)
>  {
>       memset(hash, 0, GIT_SHA1_RAWSZ);
> diff --git a/grep.c b/grep.c
> index 47cee4506..a240b4cdb 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -1747,9 +1747,8 @@ void grep_source_init(struct grep_source *gs, enum 
> grep_source_type type,
>                * If the identifier is non-NULL (in the submodule case) it
>                * will be a SHA1 that needs to be copied.
>                */
> -     case GREP_SOURCE_SHA1:
> -             gs->identifier = xmalloc(20);
> -             hashcpy(gs->identifier, identifier);
> +     case GREP_SOURCE_OID:
> +             gs->identifier = oiddup(identifier);
>               break;
>       case GREP_SOURCE_BUF:
>               gs->identifier = NULL;

These hunks triggered my "Huh?" meter a bit, simply because I tend
to wonder not just "is this useful in many other places?" but also
"is it a good idea to encourage the use of this thing?"; these look
OK.

Thanks.

Reply via email to