Re: [PATCH v5b 00/17] port branch.c to use ref-filter's printing options

2 messages, 2 authors, 2016-06-16 · open the first message on its own page

Re: [PATCH v5b 00/17] port branch.c to use ref-filter's printing options

From: Junio C Hamano <hidden>
Date: 2016-06-16 02:18:59

Karthik Nayak [off-list ref] writes:
This is part of unification of the commands 'git tag -l, git branch -l
and git for-each-ref'. This ports over branch.c to use ref-filter's
printing options.

Initially posted here: $(gmane/279226). It was decided that this series
would follow up after refactoring ref-filter parsing mechanism, which
is now merged into master (9606218b32344c5c756f7c29349d3845ef60b80c).

v1 can be found here: $(gmane/288342)
v2 can be found here: $(gmane/288863)
v3 can be found here: $(gmane/290299)
v4 can be found here: $(gmane/291106)

Changes in this version (v5b):
1. Added the first patch of the series which was missing in v5.
2. Rebased on top of 'master', which includes
   jk/branch-shortening-funny-symrefs.
quoted hunk
Interdiff:
diff --git a/builtin/branch.c b/builtin/branch.c
index c9a2e5b..6847ac3 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -288,9 +288,11 @@ static int calc_maxwidth(struct ref_array *refs, int remote_bonus)

                skip_prefix(it->refname, "refs/heads/", &desc);
                skip_prefix(it->refname, "refs/remotes/", &desc);
-               if (it->kind == FILTER_REFS_DETACHED_HEAD)
-                       w = strlen(get_head_description());
-               else
+               if (it->kind == FILTER_REFS_DETACHED_HEAD) {
+                       char *head_desc = get_head_description();
+                       w = strlen(head_desc);
+                       free(head_desc);
+               } else
                        w = utf8_strwidth(desc);
Presumably w is computed here to be used later for some kind of
alignment?  It is curious why we can assume that head_desc does not
need utf8_strwidth() here.

Re: [PATCH v5b 00/17] port branch.c to use ref-filter's printing options

From: Karthik Nayak <hidden>
Date: 2016-06-16 02:19:00

On Tue, Apr 26, 2016 at 3:17 AM, Junio C Hamano [off-list ref] wrote:
Karthik Nayak [off-list ref] writes:
quoted
This is part of unification of the commands 'git tag -l, git branch -l
and git for-each-ref'. This ports over branch.c to use ref-filter's
printing options.

Initially posted here: $(gmane/279226). It was decided that this series
would follow up after refactoring ref-filter parsing mechanism, which
is now merged into master (9606218b32344c5c756f7c29349d3845ef60b80c).

v1 can be found here: $(gmane/288342)
v2 can be found here: $(gmane/288863)
v3 can be found here: $(gmane/290299)
v4 can be found here: $(gmane/291106)

Changes in this version (v5b):
1. Added the first patch of the series which was missing in v5.
2. Rebased on top of 'master', which includes
   jk/branch-shortening-funny-symrefs.
quoted
Interdiff:
diff --git a/builtin/branch.c b/builtin/branch.c
index c9a2e5b..6847ac3 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -288,9 +288,11 @@ static int calc_maxwidth(struct ref_array *refs, int remote_bonus)

                skip_prefix(it->refname, "refs/heads/", &desc);
                skip_prefix(it->refname, "refs/remotes/", &desc);
-               if (it->kind == FILTER_REFS_DETACHED_HEAD)
-                       w = strlen(get_head_description());
-               else
+               if (it->kind == FILTER_REFS_DETACHED_HEAD) {
+                       char *head_desc = get_head_description();
+                       w = strlen(head_desc);
+                       free(head_desc);
+               } else
                        w = utf8_strwidth(desc);
Presumably w is computed here to be used later for some kind of
alignment?  It is curious why we can assume that head_desc does not
need utf8_strwidth() here.
Seems to be a bug, `get_head_description()`  is susceptible to be changed
due to translation and hence `utf8_strwidth()` would be a better candidate here
rather than `strlen()`.

Thanks.

-- 
Regards,
Karthik Nayak
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help