mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
Make "git help" react to window size correctly
Currently the git "show commands" function will react to the environment variable COLUMNS, or just default to a width of 80 characters. That's just soo eighties. Nobody sane sets COLUMNS any more, unless they need to support some stone-age software from before the age of steam engines, SIGWINCH and TIOCGWINSZ. So get with the new century, and use TIOCGWINSZ to get the terminal size. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
d808111ebd
commit
ea77e675e5
11
git.c
11
git.c
|
@ -8,6 +8,7 @@
|
|||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "git-compat-util.h"
|
||||
|
||||
#ifndef PATH_MAX
|
||||
|
@ -26,6 +27,16 @@ static int term_columns(void)
|
|||
if (col_string && (n_cols = atoi(col_string)) > 0)
|
||||
return n_cols;
|
||||
|
||||
#ifdef TIOCGWINSZ
|
||||
{
|
||||
struct winsize ws;
|
||||
if (!ioctl(1, TIOCGWINSZ, &ws)) {
|
||||
if (ws.ws_col)
|
||||
return ws.ws_col;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 80;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue