summary | shortlog | log | commit | commitdiff | tree
raw | combined (merge: ec7ff5b 2eeeef2 ad6c373)
raw | combined (merge: ec7ff5b 2eeeef2 ad6c373)
author | Junio C Hamano <gitster@pobox.com> | |
Sat, 25 Feb 2012 00:07:04 +0000 (16:07 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 25 Feb 2012 00:07:04 +0000 (16:07 -0800) |
1 | 2 | 3 | |||
---|---|---|---|---|---|
cache.h | patch | | diff1 | | diff2 | | diff3 | | blob | history |
diff.c | patch | | diff1 | | diff2 | | diff3 | | blob | history |
pager.c | patch | | diff1 | | diff2 | | diff3 | | blob | history |
diff --cc cache.h
index 24732e6caf8ba30b44a5aa5f40eb5756d164daf4,79c612fc2f51a5adf059a7a9ec2b8e7882388faa,c7e3b4d49e64ef05b4f094f46fec06ded5704907..deaa35a70011123c6a8061cedabf6d368b925a5b
+++ b/cache.h
extern const char *pager_program;
extern int pager_in_use(void);
extern int pager_use_color;
++ extern int term_columns(void);
++extern int decimal_width(int);
extern const char *editor_program;
extern const char *askpass_program;
diff --cc diff.c
Simple merge
diff --cc pager.c
index 96c07babbd7756a59fb5e891bf78f9c4396fed13,975955ba82a0dbb128d6733090cd74c2b509ea81,b7909678f459d90d1c8907c78bb5fcb512fe558d..05584dead6728ceff818630fbccaa91bb6c6b686
+++ b/pager.c
env = getenv("GIT_PAGER_IN_USE");
return env ? git_config_bool("GIT_PAGER_IN_USE", env) : 0;
}
+
++ /*
++ * Return cached value (if set) or $COLUMNS environment variable (if
++ * set and positive) or ioctl(1, TIOCGWINSZ).ws_col (if positive),
++ * and default to 80 if all else fails.
++ */
++ int term_columns(void)
++ {
++ static int term_columns_at_startup;
++
++ char *col_string;
++ int n_cols;
++
++ if (term_columns_at_startup)
++ return term_columns_at_startup;
++
++ term_columns_at_startup = 80;
++
++ col_string = getenv("COLUMNS");
++ if (col_string && (n_cols = atoi(col_string)) > 0)
++ term_columns_at_startup = n_cols;
++ #ifdef TIOCGWINSZ
++ else {
++ struct winsize ws;
++ if (!ioctl(1, TIOCGWINSZ, &ws) && ws.ws_col)
++ term_columns_at_startup = ws.ws_col;
++ }
++ #endif
++
++ return term_columns_at_startup;
++ }
+++
++/*
++ * How many columns do we need to show this number in decimal?
++ */
++int decimal_width(int number)
++{
++ int i, width;
++
++ for (width = 1, i = 10; i <= number; width++)
++ i *= 10;
++ return width;
++}