[PATCH/RFC] "git --less cmd" to page anywhere

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This allows you to say:

	git --less diff v2.6.16-rc5..

to pipe the output of any git command to your pager.

Signed-off-by: Junio C Hamano <junkio@xxxxxxx>
---

  Linus Torvalds <torvalds@xxxxxxxx> writes:

  > On Sun, 4 Jun 2006, Petr Baudis wrote:
  >> 
  >> And I forgot to mention that it also adds the interactivity test
  >> requested by Janek - aliases are now interpreted only when stdout is a
  >> tty.
  >
  > I don't think that's a good test.
  >
  > The fact is, I do
  >
  > 	git diff | less -S
  >
  > all the time,...

  This is not a serious patch, since I suspect it would obviously
  not make much sense to say "git --less commit" or somesuch,
  but it was fun to do.

 git.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/git.c b/git.c
index bc463c9..c52da8c 100644
--- a/git.c
+++ b/git.c
@@ -10,6 +10,7 @@ #include <limits.h>
 #include <stdarg.h>
 #include "git-compat-util.h"
 #include "exec_cmd.h"
+#include "cache.h"
 
 #include "builtin.h"
 
@@ -162,6 +163,10 @@ int main(int argc, const char **argv, ch
 			puts(git_exec_path());
 			exit(0);
 		}
+		if (!strcmp(cmd, "less")) {
+			setup_pager();
+			continue;
+		}
 		cmd_usage(0, NULL, NULL);
 	}
 	argv[0] = cmd;

-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]