summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 723516a)
raw | patch | inline | side by side (parent: 723516a)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 18 Jan 2009 13:47:06 +0000 (14:47 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 3 Feb 2009 14:27:25 +0000 (15:27 +0100) |
tig.c | patch | blob | history |
index d6b9366e6323ebd73d3279e726b2c6cb6f3135c2..c8ae05395c875397fef7be41c9ebf4ac5473af62 100644 (file)
--- a/tig.c
+++ b/tig.c
}
static enum request
-parse_options(int argc, const char *argv[], const char ***run_argv)
+parse_options(int argc, const char *argv[])
{
enum request request = REQ_VIEW_MAIN;
const char *subcommand;
bool seen_dashdash = FALSE;
/* XXX: This is vulnerable to the user overriding options
* required for the main view parser. */
- static const char *custom_argv[SIZEOF_ARG] = {
+ const char *custom_argv[SIZEOF_ARG] = {
"git", "log", "--no-color", "--pretty=raw", "--parents",
"--topo-order", NULL
};
int i, j = 6;
- if (!isatty(STDIN_FILENO))
+ if (!isatty(STDIN_FILENO)) {
+ io_open(&VIEW(REQ_VIEW_PAGER)->io, "");
return REQ_VIEW_PAGER;
+ }
if (argc <= 1)
- return REQ_VIEW_MAIN;
+ return REQ_NONE;
subcommand = argv[1];
if (!strcmp(subcommand, "status")) {
} else if (!strcmp(opt, "-v") || !strcmp(opt, "--version")) {
printf("tig version %s\n", TIG_VERSION);
- return REQ_NONE;
+ quit(0);
} else if (!strcmp(opt, "-h") || !strcmp(opt, "--help")) {
printf("%s\n", usage);
- return REQ_NONE;
+ quit(0);
}
custom_argv[j++] = opt;
die("command too long");
}
- custom_argv[j] = NULL;
- *run_argv = custom_argv;
+ if (!prepare_update(VIEW(request), custom_argv, NULL, FORMAT_NONE))
+ die("Failed to format arguments");
return request;
}
int
main(int argc, const char *argv[])
{
- const char **run_argv = NULL;
+ enum request request = parse_options(argc, argv);
struct view *view;
- enum request request;
size_t i;
signal(SIGINT, quit);
if (load_git_config() == ERR)
die("Failed to load repo config.");
- request = parse_options(argc, argv, &run_argv);
- if (request == REQ_NONE)
- return 0;
-
/* Require a git repository unless when running in pager mode. */
if (!opt_git_dir[0] && request != REQ_VIEW_PAGER)
die("Not a git repository");
init_display();
- if (request == REQ_VIEW_PAGER || run_argv) {
- if (request == REQ_VIEW_PAGER)
- io_open(&VIEW(request)->io, "");
- else if (!prepare_update(VIEW(request), run_argv, NULL, FORMAT_NONE))
- die("Failed to format arguments");
+ if (request != REQ_NONE)
open_view(NULL, request, OPEN_PREPARED);
- request = REQ_NONE;
- }
+ request = request == REQ_NONE ? REQ_VIEW_MAIN : REQ_NONE;
while (view_driver(display[current_view], request)) {
int key = get_input(0);