Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass terminal dimensions to git by setting COLUMNS and LINES
This partially reverts "Show diff stats as wide as the terminal" (commit a7eb305) which passed the terminal width to git-diff using `--stat=%(width)`. This feature was introduced in Git version 1.7.10 released 2013-04-06 and causes problems for older versions of Git. It turns out that Git will automatically read $COLUMNS when showing diff stats, so the same effect can be achieved by passing the terminal dimensions using environment variables. Fixes GH-151, "Broken commit rendering on Ubuntu 10.04" since incompatibilitis with older versions of Git is no longer an issue. Tested using `tig 1f384f3`.
- Loading branch information
Showing
3 changed files
with
15 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ static void warn(const char *msg, ...) PRINTF_LIKE(1, 2); | |
static void report(const char *msg, ...) PRINTF_LIKE(1, 2); | ||
#define report_clear() report("%s", "") | ||
|
||
static bool set_environment_variable(const char *name, const char *value); | ||
static bool set_int_environment_variable(const char *name, int value); | ||
|
||
|
||
enum input_status { | ||
INPUT_OK, | ||
|
@@ -2496,6 +2499,8 @@ resize_display(void) | |
/* Setup window dimensions */ | ||
|
||
getmaxyx(stdscr, base->height, base->width); | ||
set_int_environment_variable("COLUMNS", base->width); | ||
set_int_environment_variable("LINES", base->height); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jonas
Author
Owner
|
||
|
||
/* Make room for the status window. */ | ||
base->height -= 1; | ||
|
@@ -3077,9 +3082,6 @@ format_expand_arg(struct format_context *format, const char *name) | |
return string_format_from(format->buf, &format->bufpos, "%s", value); | ||
} | ||
|
||
if (!prefixcmp(name, "%(width)")) | ||
return string_format_from(format->buf, &format->bufpos, "%d", format->view->width); | ||
|
||
for (i = 0; i < ARRAY_SIZE(vars); i++) { | ||
const char *value; | ||
|
||
|
@@ -4443,7 +4445,7 @@ diff_open(struct view *view, enum open_flags flags) | |
{ | ||
static const char *diff_argv[] = { | ||
"git", "show", opt_encoding_arg, "--pretty=fuller", "--no-color", "--root", | ||
"--patch", "--stat=%(width)", | ||
"--patch-with-stat", | ||
opt_notes_arg, opt_diff_context_arg, opt_ignore_space_arg, | ||
"%(diffargs)", "%(commit)", "--", "%(fileargs)", NULL | ||
}; | ||
|
@@ -8184,6 +8186,15 @@ set_environment_variable(const char *name, const char *value) | |
return FALSE; | ||
} | ||
|
||
static bool | ||
set_int_environment_variable(const char *name, int value) | ||
{ | ||
char buf[SIZEOF_STR]; | ||
|
||
return string_format(buf, "%d", value) | ||
&& set_environment_variable(name, buf); | ||
} | ||
|
||
static void | ||
set_work_tree(const char *value) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Setting the LINES/COLUMNS environment variables to a constant number breaks ncurses' getmaxyx() logic, so dynamic resizing doesn't work. But git doesn't need them anyways as it does its own magic..