From e7977a8210addabb191308ea89b0eac610fc475d Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Thu, 10 Jun 2010 20:02:39 -0400 Subject: [PATCH] Load diff arguments from TIG_DIFF_OPTS if defined and no diff args was passed This is the missing part of 53c089443cd9885fa677becee4bf7ffd56c3c357. --- tig.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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; } -- 2.30.2