]> git.neil.brown.name Git - git.git/commit
branch: use ref-filter printing APIs
authorKarthik Nayak <karthik.188@gmail.com>
Tue, 10 Jan 2017 08:49:52 +0000 (14:19 +0530)
committerJunio C Hamano <gitster@pobox.com>
Tue, 31 Jan 2017 20:43:04 +0000 (12:43 -0800)
commit949af0684c1f84587504e2143fca6f9bb8504e31
treea54e7ba693e84d2a7e3837fd68df6e061721467f
parent56b43607f975841e70203e55bba3c0b0228da6b0
branch: use ref-filter printing APIs

Port branch.c to use ref-filter APIs for printing. This clears out
most of the code used in branch.c for printing and replaces them with
calls made to the ref-filter library.

Introduce build_format() which gets the format required for printing
of refs. Make amendments to print_ref_list() to reflect these changes.

The strings included in build_format() may not be safely quoted for
inclusion (i.e. it might contain '%' which needs to be escaped with an
additional '%'). Introduce quote_literal_for_format() as a helper
function which takes a string and returns a version of the string that
is safely quoted to be used in the for-each-ref format which is built
in build_format().

Change calc_maxwidth() to also account for the length of HEAD ref, by
calling ref-filter:get_head_discription().

Also change the test in t6040 to reflect the changes.

Before this patch, all cross-prefix symrefs weren't shortened. Since
we're using ref-filter APIs, we shorten all symrefs by default. We also
allow the user to change the format if needed with the introduction of
the '--format' option in the next patch.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Jeff King <peff@peff.net>
Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/branch.c
t/t3203-branch-output.sh
t/t6040-tracking-info.sh