git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] column: fix off-by-one default width

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
May 11, 2018, 12:13 UTC
Message-ID
<20180511121329.16142-1-pclouds@gmail.com>
In-Reply-To
<20180511092515.GA9567@sigill.intra.peff.net>

By default we want to fill the whole screen if possible, but we do not want to use up _all_ terminal columns because the last character is going hit the border, push the cursor over and wrap. Keep it at default value zero, which will make print_columns() set the width at term_columns() - 1.

This affects the test in t7004 because effective column width before was 40 but now 39 so we need to compensate it by one or the output at 39 columns has a different layout.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/column.c | 1 -
 t/t7004-tag.sh   | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/builtin/column.c b/builtin/column.c
index 0c3223d64b..5228ccf37a 100644
--- a/builtin/column.c
+++ b/builtin/column.c
@@ -42,7 +42,6 @@ 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.padding = 1;
 	argc = parse_options(argc, argv, "", options, builtin_column_usage, 0);
 	if (argc)
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
Previous: Jeff KingNext: Duy Nguyen
Message 5 of 6 in “tag: fix column output not using all terminal space”
  1. tag: fix column output not using all terminal spaceNguyễn Thái Ngọc Duy, May 11, 2018
  2. Jeff KingMay 11, 2018
  3. Duy NguyenMay 11, 2018
  4. pager: set COLUMNS to term_columns()Jeff King, May 11, 2018
  5. column: fix off-by-one default widthNguyễn Thái Ngọc Duy, May 11, 2018
  6. Duy NguyenMay 11, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.