Code

Fix pager mode by always doing the isatty()
authorJonas Fonseca <fonseca@diku.dk>
Mon, 31 Mar 2008 17:51:02 +0000 (19:51 +0200)
committerJonas Fonseca <fonseca@diku.dk>
Mon, 31 Mar 2008 17:51:02 +0000 (19:51 +0200)
Also relax the opt_git_dir check.

tig.c

diff --git a/tig.c b/tig.c
index 466fc2dc2dbb1d1a8ab592cafa65be6dadbc474c..ece56281d8bd07d0cf4ab0ab42f6122966f79620 100644 (file)
--- 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"))