summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-23 14:38:13 +0900
committerJunio C Hamano <gitster@pobox.com>2018-05-23 14:38:13 +0900
commit05682ee270199fdfbc11883458b3639b2b1577df (patch)
tree471a24735f6e495a46c508390c3c1e28f77b3e01
parent798b029da81b456077daa7cd7b1a1ed5956fc766 (diff)
parentb5d5a567fbc1eda911f91a8c78731028065bbed8 (diff)
Merge branch 'nd/term-columns'
The code did not propagate the terminal width to subprocesses via COLUMNS environment variable, which it now does. This caused trouble to "git column" helper subprocess when "git tag --column=row" tried to list the existing tags on a display with non-default width. * nd/term-columns: column: fix off-by-one default width pager: set COLUMNS to term_columns()
-rw-r--r--builtin/column.c1
-rw-r--r--pager.c11
-rwxr-xr-xt/t7004-tag.sh2
3 files changed, 9 insertions, 5 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/pager.c b/pager.c
index 92b23e6cd1..226828f178 100644
--- a/pager.c
+++ b/pager.c
@@ -109,10 +109,15 @@ void setup_pager(void)
return;
/*
- * force computing the width of the terminal before we redirect
- * the standard output to the pager.
+ * After we redirect standard output, we won't be able to use an ioctl
+ * to get the terminal size. Let's grab it now, and then set $COLUMNS
+ * to communicate it to any sub-processes.
*/
- (void) term_columns();
+ {
+ char buf[64];
+ xsnprintf(buf, sizeof(buf), "%d", term_columns());
+ setenv("COLUMNS", buf, 0);
+ }
setenv("GIT_PAGER_IN_USE", "true", 1);
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