summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d808111)
raw | patch | inline | side by side (parent: d808111)
author | Linus Torvalds <torvalds@osdl.org> | |
Sun, 18 Dec 2005 20:15:58 +0000 (12:15 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 18 Dec 2005 21:53:33 +0000 (13:53 -0800) |
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>
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>
git.c | patch | blob | history |
index c26cac6555e940e1ae5573a99350388f09118b87..157c54914422b197209e24223916f2ba501385ac 100644 (file)
--- a/git.c
+++ b/git.c
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
+#include <sys/ioctl.h>
#include "git-compat-util.h"
#ifndef PATH_MAX
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;
}