Re: [PATCH v7 05/17] ref-filter: move get_head_description() from branch.c

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

 



On Tue, Nov 8, 2016 at 12:11 PM, Karthik Nayak <karthik.188@xxxxxxxxx> wrote:
> From: Karthik Nayak <karthik.188@xxxxxxxxx>
>
> Move the implementation of get_head_description() from branch.c to
> ref-filter.  This gives a description of the HEAD ref if called. This
> is used as the refname for the HEAD ref whenever the
> FILTER_REFS_DETACHED_HEAD option is used. Make it public because we
> need it to calculate the length of the HEAD refs description in
> branch.c:calc_maxwidth() when we port branch.c to use ref-filter
> APIs.
>

Makes sense.

>
> -               if (starts_with(name, "refname"))
> +               if (starts_with(name, "refname")) {
>                         refname = ref->refname;
> -               else if (starts_with(name, "symref"))
> +                       if (ref->kind & FILTER_REFS_DETACHED_HEAD)
> +                               refname = get_head_description();

Since this (I think?) changes behavior of refname would it make sense
to add a test for this?

Thanks,
Jake

> +               } else if (starts_with(name, "symref"))
>                         refname = ref->symref ? ref->symref : "";
>                 else if (starts_with(name, "upstream")) {
>                         const char *branch_name;
> diff --git a/ref-filter.h b/ref-filter.h
> index 14d435e..4aea594 100644
> --- a/ref-filter.h
> +++ b/ref-filter.h
> @@ -106,5 +106,7 @@ int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset);
>  struct ref_sorting *ref_default_sorting(void);
>  /*  Function to parse --merged and --no-merged options */
>  int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset);
> +/*  Get the current HEAD's description */
> +char *get_head_description(void);
>
>  #endif /*  REF_FILTER_H  */
> --
> 2.10.2
>



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