From 094e6ab0e900bf8546bc95e3e034e7630574b644 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 31 Mar 2008 19:51:02 +0200 Subject: [PATCH] Fix pager mode by always doing the isatty() Also relax the opt_git_dir check. --- tig.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tig.c b/tig.c index 466fc2d..ece5628 100644 --- a/tig.c +++ b/tig.c @@ -466,6 +466,12 @@ parse_options(int argc, char *argv[]) bool seen_dashdash = FALSE; int i; + if (!isatty(STDIN_FILENO)) { + opt_request = REQ_VIEW_PAGER; + opt_pipe = stdin; + return TRUE; + } + if (argc <= 1) return TRUE; @@ -534,12 +540,6 @@ parse_options(int argc, char *argv[]) die("command too long"); } - if (!isatty(STDIN_FILENO)) { - opt_request = REQ_VIEW_PAGER; - opt_pipe = stdin; - buf_size = 0; - } - opt_cmd[buf_size] = 0; return TRUE; @@ -5741,7 +5741,7 @@ main(int argc, char *argv[]) return 0; /* Require a git repository unless when running in pager mode. */ - if (!opt_git_dir[0]) + if (!opt_git_dir[0] && opt_request != REQ_VIEW_PAGER) die("Not a git repository"); if (*opt_encoding && strcasecmp(opt_encoding, "UTF-8")) -- 2.30.2