Code

Improve parsing of the set command and variable arguments options
authorJonas Fonseca <fonseca@diku.dk>
Thu, 10 Mar 2011 02:11:44 +0000 (21:11 -0500)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 10 Mar 2011 02:12:30 +0000 (21:12 -0500)
tig.c

diff --git a/tig.c b/tig.c
index f022f17a974b2424f32e6c729a191f6672ac2792..f56547455c50dcf170dbdb0f8424915a9db2c40e 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1115,7 +1115,7 @@ parse_string(char *opt, const char *arg, size_t optsize)
 static enum option_code
 parse_args(const char ***args, const char *argv[])
 {
-       if (!argv_copy(args, argv))
+       if (*args == NULL && !argv_copy(args, argv))
                return OPT_ERR_OUT_OF_MEMORY;
        return OPT_OK;
 }
@@ -1127,15 +1127,15 @@ option_set_command(int argc, const char *argv[])
        if (argc < 3)
                return OPT_ERR_WRONG_NUMBER_OF_ARGUMENTS;
 
-       if (!opt_blame_argv && !strcmp(argv[0], "blame-options"))
+       if (strcmp(argv[1], "="))
+               return OPT_ERR_NO_VALUE_ASSIGNED;
+
+       if (!strcmp(argv[0], "blame-options"))
                return parse_args(&opt_blame_argv, argv + 2);
 
        if (argc != 3)
                return OPT_ERR_WRONG_NUMBER_OF_ARGUMENTS;
 
-       if (strcmp(argv[1], "="))
-               return OPT_ERR_NO_VALUE_ASSIGNED;
-
        if (!strcmp(argv[0], "show-author"))
                return parse_enum(&opt_author, argv[2], author_map);