All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tag: fix column output not using all terminal space
@ 2018-05-11  7:56 Nguyễn Thái Ngọc Duy
  2018-05-11  8:28 ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-05-11  7:56 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

git-tag runs a separate git-column command via run_column_filter().
This makes the new 'git-column' process fail to pick up the terminal
width for some reason and fall back to default width. Just explicitly
pass terminal width and avoid this terminal width detection business
in subprocesses.

While at there, fix an off-by-one column setting in git-column. We do
not want to use up _all_ terminal columns because the last character
is going hit the border and wrap. Keep it at term_columns() - 1 like
print_columns() does. This affects the test in t7004 because effective
column width before was 40 but now 39 so we need to adjust it back.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/column.c | 2 +-
 column.c         | 2 ++
 t/t7004-tag.sh   | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/builtin/column.c b/builtin/column.c
index 0c3223d64b..182c84f778 100644
--- a/builtin/column.c
+++ b/builtin/column.c
@@ -42,7 +42,7 @@ int cmd_column(int argc, const char **argv, const char *prefix)
 		git_config(column_config, NULL);
 
 	memset(&copts, 0, sizeof(copts));
-	copts.width = term_columns();
+	copts.width = term_columns() - 1;
 	copts.padding = 1;
 	argc = parse_options(argc, argv, "", options, builtin_column_usage, 0);
 	if (argc)
diff --git a/column.c b/column.c
index 49ab85b769..382537b324 100644
--- a/column.c
+++ b/column.c
@@ -381,6 +381,8 @@ int run_column_filter(int colopts, const struct column_options *opts)
 	argv_array_pushf(argv, "--raw-mode=%d", colopts);
 	if (opts && opts->width)
 		argv_array_pushf(argv, "--width=%d", opts->width);
+	else
+		argv_array_pushf(argv, "--width=%d", term_columns() - 1);
 	if (opts && opts->indent)
 		argv_array_pushf(argv, "--indent=%s", opts->indent);
 	if (opts && opts->padding)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index e3f1e014aa..d7b319e919 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -363,7 +363,7 @@ test_expect_success 'tag -l <pattern> -l <pattern> works, as our buggy documenta
 '
 
 test_expect_success 'listing tags in column' '
-	COLUMNS=40 git tag -l --column=row >actual &&
+	COLUMNS=41 git tag -l --column=row >actual &&
 	cat >expected <<\EOF &&
 a1      aa1     cba     t210    t211
 v0.2.1  v1.0    v1.0.1  v1.1.3
-- 
2.17.0.705.g3525833791


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-11 12:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-11  7:56 [PATCH] tag: fix column output not using all terminal space Nguyễn Thái Ngọc Duy
2018-05-11  8:28 ` Jeff King
2018-05-11  8:43   ` Duy Nguyen
2018-05-11  9:25     ` [PATCH] pager: set COLUMNS to term_columns() Jeff King
2018-05-11 12:13       ` [PATCH] column: fix off-by-one default width Nguyễn Thái Ngọc Duy
2018-05-11 12:16       ` [PATCH] pager: set COLUMNS to term_columns() Duy Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.