"git -p cmd" to page anywhere
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>
This commit is contained in:
parent
cfc01c0387
commit
85fb65ed6e
1
cache.h
1
cache.h
@ -382,6 +382,7 @@ extern int receive_keep_pack(int fd[2], const char *me, int quiet, int);
|
|||||||
|
|
||||||
/* pager.c */
|
/* pager.c */
|
||||||
extern void setup_pager(void);
|
extern void setup_pager(void);
|
||||||
|
extern int pager_in_use;
|
||||||
|
|
||||||
/* base85 */
|
/* base85 */
|
||||||
int decode_85(char *dst, char *line, int linelen);
|
int decode_85(char *dst, char *line, int linelen);
|
||||||
|
2
diff.c
2
diff.c
@ -112,7 +112,7 @@ int git_diff_config(const char *var, const char *value)
|
|||||||
diff_use_color_default = 1; /* bool */
|
diff_use_color_default = 1; /* bool */
|
||||||
else if (!strcasecmp(value, "auto")) {
|
else if (!strcasecmp(value, "auto")) {
|
||||||
diff_use_color_default = 0;
|
diff_use_color_default = 0;
|
||||||
if (isatty(1)) {
|
if (isatty(1) || pager_in_use) {
|
||||||
char *term = getenv("TERM");
|
char *term = getenv("TERM");
|
||||||
if (term && strcmp(term, "dumb"))
|
if (term && strcmp(term, "dumb"))
|
||||||
diff_use_color_default = 1;
|
diff_use_color_default = 1;
|
||||||
|
5
git.c
5
git.c
@ -251,6 +251,11 @@ int main(int argc, const char **argv, char **envp)
|
|||||||
cmd = *++argv;
|
cmd = *++argv;
|
||||||
argc--;
|
argc--;
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
|
||||||
|
setup_pager();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (strncmp(cmd, "--", 2))
|
if (strncmp(cmd, "--", 2))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
4
pager.c
4
pager.c
@ -5,6 +5,8 @@
|
|||||||
* something different on Windows, for example.
|
* something different on Windows, for example.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int pager_in_use;
|
||||||
|
|
||||||
static void run_pager(const char *pager)
|
static void run_pager(const char *pager)
|
||||||
{
|
{
|
||||||
execlp(pager, pager, NULL);
|
execlp(pager, pager, NULL);
|
||||||
@ -24,6 +26,8 @@ void setup_pager(void)
|
|||||||
else if (!*pager || !strcmp(pager, "cat"))
|
else if (!*pager || !strcmp(pager, "cat"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
pager_in_use = 1; /* means we are emitting to terminal */
|
||||||
|
|
||||||
if (pipe(fd) < 0)
|
if (pipe(fd) < 0)
|
||||||
return;
|
return;
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
Loading…
Reference in New Issue
Block a user