tig-0.8
[tig] / tig.c
diff --git a/tig.c b/tig.c
index 4150696..fa2a708 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1153,7 +1153,7 @@ read_option(char *opt, size_t optlen, char *value, size_t valuelen)
 
        if (status == ERR) {
                fprintf(stderr, "Error on line %d, near '%.*s': %s\n",
-                       config_lineno, optlen, opt, config_msg);
+                       config_lineno, (int) optlen, opt, config_msg);
                config_errors = TRUE;
        }
 
@@ -1289,8 +1289,8 @@ static struct view views[] = {
        VIEW_(LOG,    "log",    &pager_ops,  ref_head),
        VIEW_(TREE,   "tree",   &tree_ops,   ref_commit),
        VIEW_(BLOB,   "blob",   &blob_ops,   ref_blob),
-       VIEW_(HELP,   "help",   &help_ops,  ""),
-       VIEW_(PAGER,  "pager",  &pager_ops,  ""),
+       VIEW_(HELP,   "help",   &help_ops,   ""),
+       VIEW_(PAGER,  "pager",  &pager_ops,  "stdin"),
        VIEW_(STATUS, "status", &status_ops, ""),
 };
 
@@ -1394,7 +1394,7 @@ update_view_title(struct view *view)
 
                if (minsize < view->width)
                        refsize = view->width - minsize + 7;
-               string_format_from(buf, &bufpos, " %.*s", refsize, view->ref);
+               string_format_from(buf, &bufpos, " %.*s", (int) refsize, view->ref);
        }
 
        if (statelen && bufpos < view->width) {
@@ -2152,7 +2152,7 @@ view_driver(struct view *view, enum request request)
                break;
 
        case REQ_VIEW_PAGER:
-               if (!VIEW(REQ_VIEW_PAGER)->lines) {
+               if (!opt_pipe && !VIEW(REQ_VIEW_PAGER)->lines) {
                        report("No pager content, press %s to run command from prompt",
                               get_key(REQ_PROMPT));
                        break;
@@ -4089,7 +4089,7 @@ read_repo_info(char *name, size_t namelen, char *value, size_t valuelen)
 static int
 load_repo_info(void)
 {
-       return read_properties(popen("git rev-parse --git-dir --show-cdup", "r"),
+       return read_properties(popen("git rev-parse --git-dir --show-cdup 2>/dev/null", "r"),
                               "=", read_repo_info);
 }
 
@@ -4178,6 +4178,13 @@ main(int argc, char *argv[])
                string_ncopy(opt_codeset, codeset, strlen(codeset));
        }
 
+       if (load_repo_info() == ERR)
+               die("Failed to load repo info.");
+
+       /* Require a git repository unless when running in pager mode. */
+       if (!opt_git_dir[0])
+               die("Not a git repository");
+
        if (load_options() == ERR)
                die("Failed to load user config.");
 
@@ -4186,9 +4193,6 @@ main(int argc, char *argv[])
        if (load_repo_config() == ERR)
                die("Failed to load repo config.");
 
-       if (load_repo_info() == ERR)
-               die("Failed to load repo info.");
-
        if (!parse_options(argc, argv))
                return 0;
 
@@ -4201,10 +4205,6 @@ main(int argc, char *argv[])
        if (load_refs() == ERR)
                die("Failed to load refs.");
 
-       /* Require a git repository unless when running in pager mode. */
-       if (refs_size == 0 && opt_request != REQ_VIEW_PAGER)
-               die("Not a git repository");
-
        for (i = 0; i < ARRAY_SIZE(views) && (view = &views[i]); i++)
                view->cmd_env = getenv(view->cmd_env);