1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 21:07:52 +01:00

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()
This commit is contained in:
Junio C Hamano 2018-05-23 14:38:13 +09:00
commit 05682ee270
3 changed files with 9 additions and 5 deletions

View file

@ -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)

11
pager.c
View file

@ -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);

View file

@ -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