Staging
v0.5.1
https://github.com/git/git
Revision d5e86da89155b462c30a59bc724037fb111d3894 authored by Junio C Hamano on 26 December 2006, 02:14:12 UTC, committed by Junio C Hamano on 26 December 2006, 02:39:54 UTC
This is not yet -rc1 where all new topics closes, but I think it
is getting pretty closer.  I'd still want to merge updates to
fsck/prune to honor reflog entries before -rc1.

Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent d2bafe5
Raw File
Tip revision: d5e86da89155b462c30a59bc724037fb111d3894 authored by Junio C Hamano on 26 December 2006, 02:14:12 UTC
GIT v1.5.0 preview
Tip revision: d5e86da
pager.c
#include "cache.h"

/*
 * This is split up from the rest of git so that we might do
 * something different on Windows, for example.
 */

static void run_pager(const char *pager)
{
	execlp(pager, pager, NULL);
	execl("/bin/sh", "sh", "-c", pager, NULL);
}

void setup_pager(void)
{
	pid_t pid;
	int fd[2];
	const char *pager = getenv("GIT_PAGER");

	if (!isatty(1))
		return;
	if (!pager)
		pager = getenv("PAGER");
	if (!pager)
		pager = "less";
	else if (!*pager || !strcmp(pager, "cat"))
		return;

	pager_in_use = 1; /* means we are emitting to terminal */

	if (pipe(fd) < 0)
		return;
	pid = fork();
	if (pid < 0) {
		close(fd[0]);
		close(fd[1]);
		return;
	}

	/* return in the child */
	if (!pid) {
		dup2(fd[1], 1);
		close(fd[0]);
		close(fd[1]);
		return;
	}

	/* The original process turns into the PAGER */
	dup2(fd[0], 0);
	close(fd[0]);
	close(fd[1]);

	setenv("LESS", "FRSX", 0);
	run_pager(pager);
	die("unable to execute pager '%s'", pager);
	exit(255);
}
back to top