summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cfc01c0)
raw | patch | inline | side by side (parent: cfc01c0)
author | Junio C Hamano <junkio@cox.net> | |
Tue, 6 Jun 2006 23:58:40 +0000 (16:58 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 9 Jul 2006 10:27:03 +0000 (03:27 -0700) |
This allows you to say:
git -p diff v2.6.16-rc5..
and the command pipes the output of any git command to your pager.
[jc: this resurrects a month old RFC patch with improvement
suggested by Linus to call it --paginate instead of --less.]
Signed-off-by: Junio C Hamano <junkio@cox.net>
git -p diff v2.6.16-rc5..
and the command pipes the output of any git command to your pager.
[jc: this resurrects a month old RFC patch with improvement
suggested by Linus to call it --paginate instead of --less.]
Signed-off-by: Junio C Hamano <junkio@cox.net>
cache.h | patch | blob | history | |
diff.c | patch | blob | history | |
git.c | patch | blob | history | |
pager.c | patch | blob | history |
index 7b5c91c996fc58d7e5f743bdf07739ac1c1487bb..b5e3f8fa21e49e2e209f0edc2e42878368d7d817 100644 (file)
--- a/cache.h
+++ b/cache.h
/* pager.c */
extern void setup_pager(void);
+extern int pager_in_use;
/* base85 */
int decode_85(char *dst, char *line, int linelen);
index 3e26180f08204df2e7519e4613aa6e3e844e21b2..a00f9d1e5244c8a7d2edfcef55cb92d3d3df252a 100644 (file)
--- a/diff.c
+++ b/diff.c
diff_use_color_default = 1; /* bool */
else if (!strcasecmp(value, "auto")) {
diff_use_color_default = 0;
- if (isatty(1)) {
+ if (isatty(1) || pager_in_use) {
char *term = getenv("TERM");
if (term && strcmp(term, "dumb"))
diff_use_color_default = 1;
index 256730112e56e19e5df70f2bef4e3efdb1a5e362..49062ca66e4f37d53f16d4bff10dc71b1c97e6db 100644 (file)
--- a/git.c
+++ b/git.c
cmd = *++argv;
argc--;
+ if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
+ setup_pager();
+ continue;
+ }
+
if (strncmp(cmd, "--", 2))
break;
index 2d186e8bde1067a62c9615e8d7f0368f98442ca4..bb14e99735dd08c31c66325eacdcde4f3f2c685c 100644 (file)
--- a/pager.c
+++ b/pager.c
* something different on Windows, for example.
*/
+int pager_in_use;
+
static void run_pager(const char *pager)
{
execlp(pager, pager, NULL);
else if (!*pager || !strcmp(pager, "cat"))
return;
+ pager_in_use = 1; /* means we are emitting to terminal */
+
if (pipe(fd) < 0)
return;
pid = fork();