Re: [PATCH v7 05/17] ref-filter: move get_head_description() from branch.c
From: Jacob Keller <hidden>
Date: 2016-11-08 23:32:06
On Tue, Nov 8, 2016 at 12:11 PM, Karthik Nayak [off-list ref] wrote:
From: Karthik Nayak <redacted> 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
quoted hunk ↗ jump to hunk
+ } 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