Code

Fix missing ID reference
[tig.git] / tig.c
diff --git a/tig.c b/tig.c
index e5612c197c7320b51ea0303284ab52718ca6d9eb..a82a4686e4696316a00eeb9473d8deb934df6e4b 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;
 }
 
@@ -3188,17 +3200,17 @@ format_argv(const char ***dst_argv, const char *src_argv[], bool replace)
                const char *arg = src_argv[argc];
                size_t bufpos = 0;
 
-               if (!strcmp(arg, "%(file-args)")) {
+               if (!strcmp(arg, "%(fileargs)")) {
                        if (!argv_append_array(dst_argv, opt_file_args))
                                break;
                        continue;
 
-               } else if (!strcmp(arg, "%(diff-args)")) {
+               } else if (!strcmp(arg, "%(diffargs)")) {
                        if (!argv_append_array(dst_argv, opt_diff_args))
                                break;
                        continue;
 
-               } else if (!strcmp(arg, "%(rev-args)")) {
+               } else if (!strcmp(arg, "%(revargs)")) {
                        if (!argv_append_array(dst_argv, opt_rev_args))
                                break;
                        continue;
@@ -4171,7 +4183,7 @@ static struct view_ops log_ops = {
 static const char *diff_argv[SIZEOF_ARG] = {
        "git", "show", "--pretty=fuller", "--no-color", "--root",
                "--patch-with-stat", "--find-copies-harder", "-C",
-               "%(diff-args)", "%(commit)", "--", "%(file-args)", NULL
+               "%(diffargs)", "%(commit)", "--", "%(fileargs)", NULL
 };
 
 static struct view_ops diff_ops = {
@@ -6695,8 +6707,8 @@ update_rev_graph(struct view *view, struct rev_graph *graph)
 
 static const char *main_argv[SIZEOF_ARG] = {
        "git", "log", "--no-color", "--pretty=raw", "--parents",
-               "--topo-order", "%(diff-args)", "%(rev-args)",
-               "--", "%(file-args)", NULL
+               "--topo-order", "%(diffargs)", "%(revargs)",
+               "--", "%(fileargs)", NULL
 };
 
 static bool