On Sun, Jun 21, 2015 at 4:48 PM, Karthik Nayak <karthik....@gmail.com> wrote:
> In 'tag -l' we have '--points-at' option which lets users
> list only tags which point to a particular commit. Implement
> this option in 'ref-filter.{c,h}' so that other commands can
> benefit from this.
>
> This is duplicated from tag.c, we will eventually remove that
> when we port tag.c to use ref-filter APIs.
>
> Based-on-patch-by: Jeff King <p...@peff.net>
> Mentored-by: Christian Couder <christian.cou...@gmail.com>
> Mentored-by: Matthieu Moy <matthieu....@grenoble-inp.fr>
> Signed-off-by: Karthik Nayak <karthik....@gmail.com>
> ---
> diff --git a/builtin/tag.c b/builtin/tag.c
> index e36c43e..280981f 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -56,6 +56,10 @@ static int match_pattern(const char **patterns, const char 
> *ref)
>         return 0;
>  }
>
> +/*
> + * This is currently duplicated in ref-filter.c, and will eventually be
> + * removed as we port tag.c to use the ref-filter APIs.
> + */
>  static const unsigned char *match_points_at(const char *refname,
>                                             const unsigned char *sha1)
>  {
> diff --git a/ref-filter.c b/ref-filter.c
> index 43502a4..591e281 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -842,6 +842,29 @@ static int match_name_as_path(const char **pattern, 
> const char *refname)
>         return 0;
>  }
>
> +/*
> + * Given a ref (sha1, refname) see if it points to a one of the sha1s

s/a one/one/

> + * in a sha1_array.
> + */
> +static int match_points_at(struct sha1_array *points_at, const unsigned char 
> *sha1,
> +                          const char *refname)
> +{
> +       struct object *obj;
> +
> +       if (!points_at || !points_at->nr)
> +               return 1;
> +
> +       if (sha1_array_lookup(points_at, sha1) >= 0)
> +               return 1;
> +
> +       obj = parse_object_or_die(sha1, refname);
> +       if (obj->type == OBJ_TAG &&
> +           sha1_array_lookup(points_at, ((struct tag *)obj)->tagged->sha1) 
> >= 0)
> +               return 1;
> +
> +       return 0;
> +}
--
To unsubscribe from this list: send the line "unsubscribe git" in

Reply via email to