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:
commit
05682ee270
@ -42,7 +42,6 @@ int cmd_column(int argc, const char **argv, const char *prefix)
|
|||||||
git_config(column_config, NULL);
|
git_config(column_config, NULL);
|
||||||
|
|
||||||
memset(&copts, 0, sizeof(copts));
|
memset(&copts, 0, sizeof(copts));
|
||||||
copts.width = term_columns();
|
|
||||||
copts.padding = 1;
|
copts.padding = 1;
|
||||||
argc = parse_options(argc, argv, "", options, builtin_column_usage, 0);
|
argc = parse_options(argc, argv, "", options, builtin_column_usage, 0);
|
||||||
if (argc)
|
if (argc)
|
||||||
|
11
pager.c
11
pager.c
@ -109,10 +109,15 @@ void setup_pager(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* force computing the width of the terminal before we redirect
|
* After we redirect standard output, we won't be able to use an ioctl
|
||||||
* the standard output to the pager.
|
* 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);
|
setenv("GIT_PAGER_IN_USE", "true", 1);
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ test_expect_success 'tag -l <pattern> -l <pattern> works, as our buggy documenta
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'listing tags in column' '
|
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 &&
|
cat >expected <<\EOF &&
|
||||||
a1 aa1 cba t210 t211
|
a1 aa1 cba t210 t211
|
||||||
v0.2.1 v1.0 v1.0.1 v1.1.3
|
v0.2.1 v1.0 v1.0.1 v1.1.3
|
||||||
|
Loading…
Reference in New Issue
Block a user