summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a00fff3)
raw | patch | inline | side by side (parent: a00fff3)
author | Jonas Fonseca <fonseca@diku.dk> | |
Fri, 21 Mar 2008 16:27:28 +0000 (17:27 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sat, 22 Mar 2008 20:20:51 +0000 (21:20 +0100) |
tig.c | patch | blob | history |
index 8fb2d4c17526ffaa1bbea0261a75e805701326cf..f8132fd0f8aeaaf096aea74a0e2cd041edbfe2f7 100644 (file)
--- a/tig.c
+++ b/tig.c
{
char *altargv[1024];
int altargc = 0;
- char *subcommand = NULL;
+ char *subcommand;
int i;
- for (i = 1; i < argc; i++) {
- char *opt = argv[i];
+ if (argc <= 1)
+ return TRUE;
- if (!strcmp(opt, "log") ||
- !strcmp(opt, "diff")) {
- subcommand = opt;
- opt_request = opt[0] == 'l'
- ? REQ_VIEW_LOG : REQ_VIEW_DIFF;
- warn("`tig %s' has been deprecated", opt);
- break;
- }
+ subcommand = argv[1];
+ if (!strcmp(subcommand, "status")) {
+ opt_request = REQ_VIEW_STATUS;
+ if (argc > 2)
+ warn("ignoring arguments after `%s'", subcommand);
+ return TRUE;
- if (!strcmp(opt, "show")) {
- subcommand = opt;
- opt_request = REQ_VIEW_DIFF;
- break;
- }
+ } else if (!strcmp(subcommand, "show")) {
+ opt_request = REQ_VIEW_DIFF;
- if (!strcmp(opt, "status")) {
- subcommand = opt;
- opt_request = REQ_VIEW_STATUS;
- break;
- }
+ } else if (!strcmp(subcommand, "log") || !strcmp(subcommand, "diff")) {
+ opt_request = subcommand[0] == 'l'
+ ? REQ_VIEW_LOG : REQ_VIEW_DIFF;
+ warn("`tig %s' has been deprecated", subcommand);
+
+ } else {
+ subcommand = NULL;
+ }
+
+ for (i = 1 + !!subcommand; i < argc; i++) {
+ char *opt = argv[i];
if (opt[0] && opt[0] != '-')
break;
warn("`%s' has been deprecated", opt);
}
- /* Check that no 'alt' arguments occured before a subcommand. */
- if (subcommand && i < argc && altargc > 0)
- die("unknown arguments before `%s'", argv[i]);
-
if (!isatty(STDIN_FILENO)) {
opt_request = REQ_VIEW_PAGER;
opt_pipe = stdin;
- } else if (opt_request == REQ_VIEW_STATUS) {
- if (argc - i > 1)
- warn("ignoring arguments after `%s'", argv[i]);
-
} else if (i < argc || altargc > 0) {
int alti = 0;
size_t buf_size;
* options required for the main view parser. */
string_copy(opt_cmd, "git log --no-color --pretty=raw --boundary --parents");
else
- string_copy(opt_cmd, "git");
+ string_format(opt_cmd, "git %s", subcommand);
buf_size = strlen(opt_cmd);
while (buf_size < sizeof(opt_cmd) && alti < altargc) {