Re: [PATCH v7 05/17] ref-filter: move get_head_description() from branch.c
- From
Jacob Keller <jacob.keller@gmail.com>
- Date
- Nov 8, 2016, 23:31 UTC
- Message-ID
- <CA+P7+xo4M5g15B7zKzC-zJvd6O0Wfpks142-+C8tAqTfyEJ+nA@mail.gmail.com>
- In-Reply-To
- <20161108201211.25213-6-Karthik.188@gmail.com>
On Tue, Nov 8, 2016 at 12:11 PM, Karthik Nayak <karthik.188@gmail.com> wrote:
Show 10 quoted lines
> From: Karthik Nayak <karthik.188@gmail.com> > > 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.
Show 7 quoted lines
>
> - 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
Show 19 quoted lines
> + } 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
>