From ec1fcbb0a9432e0baccc43484caa57c7c2042118 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Thu, 18 Jan 2007 09:37:38 +0100 Subject: [PATCH] Make the pager work. --- pager.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pager.c b/pager.c index 4587fbbdb5..b2a37e2658 100644 --- a/pager.c +++ b/pager.c @@ -1,19 +1,26 @@ #include "cache.h" +#include "spawn-pipe.h" /* * This is split up from the rest of git so that we might do * something different on Windows, for example. */ +#ifndef __MINGW32__ static void run_pager(const char *pager) { execlp(pager, pager, NULL); execl("/bin/sh", "sh", "-c", pager, NULL); } +#endif void setup_pager(void) { +#ifndef __MINGW32__ pid_t pid; +#else + const char *pager_argv[] = { "sh", "-c", NULL, NULL }; +#endif int fd[2]; const char *pager = getenv("GIT_PAGER"); @@ -30,6 +37,7 @@ void setup_pager(void) if (pipe(fd) < 0) return; +#ifndef __MINGW32__ pid = fork(); if (pid < 0) { close(fd[0]); @@ -54,4 +62,14 @@ void setup_pager(void) run_pager(pager); die("unable to execute pager '%s'", pager); exit(255); +#else + /* spawn the pager */ + pager_argv[2] = pager; + if (spawnvpe_pipe(pager_argv[0], pager_argv, environ, fd, NULL) < 0) + return; + + /* original process continues, but writes to the pipe */ + dup2(fd[1], 1); + close(fd[1]); +#endif }