projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make "git help" react to window size correctly
[git.git]
/
git.c
diff --git
a/git.c
b/git.c
index
c26cac6
..
157c549
100644
(file)
--- a/
git.c
+++ b/
git.c
@@
-8,6
+8,7
@@
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
+#include <sys/ioctl.h>
#include "git-compat-util.h"
#ifndef PATH_MAX
#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;
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;
}
return 80;
}