From: Jonas Fonseca Date: Fri, 11 Jun 2010 00:02:39 +0000 (-0400) Subject: Load diff arguments from TIG_DIFF_OPTS if defined and no diff args was passed X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e7977a8210addabb191308ea89b0eac610fc475d;p=tig.git Load diff arguments from TIG_DIFF_OPTS if defined and no diff args was passed This is the missing part of 53c089443cd9885fa677becee4bf7ffd56c3c357. --- diff --git a/tig.c b/tig.c index e5612c1..d7752a2 100644 --- 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; }