Code

Load diff arguments from TIG_DIFF_OPTS if defined and no diff args was passed
authorJonas Fonseca <fonseca@diku.dk>
Fri, 11 Jun 2010 00:02:39 +0000 (20:02 -0400)
committerJonas Fonseca <fonseca@diku.dk>
Fri, 11 Jun 2010 00:02:39 +0000 (20:02 -0400)
This is the missing part of 53c089443cd9885fa677becee4bf7ffd56c3c357.

tig.c

diff --git a/tig.c b/tig.c
index e5612c197c7320b51ea0303284ab52718ca6d9eb..d7752a2f9131b75d4f7b9a58edad7e1bffdfff12 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2135,6 +2135,7 @@ load_options(void)
        const char *home = getenv("HOME");
        const char *tigrc_user = getenv("TIGRC_USER");
        const char *tigrc_system = getenv("TIGRC_SYSTEM");
+       const char *tig_diff_opts = getenv("TIG_DIFF_OPTS");
        char buf[SIZEOF_STR];
 
        if (!tigrc_system)
@@ -2152,6 +2153,17 @@ load_options(void)
         * that conflict with keybindings. */
        add_builtin_run_requests();
 
+       if (!opt_diff_args && tig_diff_opts && *tig_diff_opts) {
+               static const char *diff_opts[SIZEOF_ARG] = { NULL };
+               int argc = 0;
+
+               if (!string_format(buf, "%s", tig_diff_opts) ||
+                   !argv_from_string(diff_opts, &argc, buf))
+                       die("TIG_DIFF_OPTS contains too many arguments");
+               else if (!argv_copy(&opt_diff_args, diff_opts))
+                       die("Failed to format TIG_DIFF_OPTS arguments");
+       }
+
        return OK;
 }