From d4919bb288e46c81b92d6fe02c4f4564b8477fd3 Mon Sep 17 00:00:00 2001 From: Karthik Nayak Date: Tue, 10 Jan 2017 14:19:38 +0530 Subject: ref-filter: move get_head_description() from branch.c 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. Mentored-by: Christian Couder Mentored-by: Matthieu Moy Signed-off-by: Karthik Nayak Signed-off-by: Junio C Hamano --- ref-filter.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ref-filter.h') diff --git a/ref-filter.h b/ref-filter.h index fc55fa3574..f78323de0c 100644 --- a/ref-filter.h +++ b/ref-filter.h @@ -108,5 +108,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 */ -- cgit v1.2.3 From 99c6a71d4f7f4197f5e8600b0edec2a6a9fd9988 Mon Sep 17 00:00:00 2001 From: Karthik Nayak Date: Tue, 10 Jan 2017 14:19:39 +0530 Subject: ref-filter: introduce format_ref_array_item() To allow column display, we will need to first render the output in a string list to allow print_columns() to compute the proper size of each column before starting the actual output. Introduce the function format_ref_array_item() that does the formatting of a ref_array_item to an strbuf. show_ref_array_item() is kept as a convenience wrapper around it which obtains the strbuf and prints it the standard output. Mentored-by: Christian Couder Mentored-by: Matthieu Moy Signed-off-by: Karthik Nayak Signed-off-by: Junio C Hamano --- ref-filter.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ref-filter.h') diff --git a/ref-filter.h b/ref-filter.h index f78323de0c..630e7c2b91 100644 --- a/ref-filter.h +++ b/ref-filter.h @@ -100,6 +100,9 @@ int parse_ref_filter_atom(const char *atom, const char *ep); int verify_ref_format(const char *format); /* Sort the given ref_array as per the ref_sorting provided */ void ref_array_sort(struct ref_sorting *sort, struct ref_array *array); +/* Based on the given format and quote_style, fill the strbuf */ +void format_ref_array_item(struct ref_array_item *info, const char *format, + int quote_style, struct strbuf *final_buf); /* Print the ref using the given format and quote_style */ void show_ref_array_item(struct ref_array_item *info, const char *format, int quote_style); /* Callback function for parsing the sort option */ -- cgit v1.2.3 From 6eac70fa6343a31b5b310a465a442adb6731a26b Mon Sep 17 00:00:00 2001 From: Karthik Nayak Date: Tue, 10 Jan 2017 14:19:50 +0530 Subject: ref-filter: allow porcelain to translate messages in the output Introduce setup_ref_filter_porcelain_msg() so that the messages used in the atom %(upstream:track) can be translated if needed. By default, keep the messages untranslated, which is the right behavior for plumbing commands. This is needed as we port branch.c to use ref-filter's printing API's. Written-by: Matthieu Moy Mentored-by: Christian Couder Mentored-by: Matthieu Moy Signed-off-by: Karthik Nayak Signed-off-by: Junio C Hamano --- ref-filter.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ref-filter.h') diff --git a/ref-filter.h b/ref-filter.h index 630e7c2b91..44b36eded0 100644 --- a/ref-filter.h +++ b/ref-filter.h @@ -113,5 +113,7 @@ struct ref_sorting *ref_default_sorting(void); 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); +/* Set up translated strings in the output. */ +void setup_ref_filter_porcelain_msg(void); #endif /* REF_FILTER_H */ -- cgit v1.2.3