Re: [PATCH v4 03/19] ref-filter: implement '--points-at' option

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

 



On Sun, Jun 21, 2015 at 4:48 PM, Karthik Nayak <karthik.188@xxxxxxxxx> 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 <peff@xxxxxxxx>
> Mentored-by: Christian Couder <christian.couder@xxxxxxxxx>
> Mentored-by: Matthieu Moy <matthieu.moy@xxxxxxxxxxxxxxx>
> Signed-off-by: Karthik Nayak <karthik.188@xxxxxxxxx>
> ---
> 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



[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]