Browse files

Add a diff-options config, similar to blame-options

This is useful for persistent arguments to the diff view instead of
setting TIG_DIFF_OPTS or always passing them on the command line
invocation.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
  • Loading branch information...
1 parent f996cef commit 3567c4e158f50e8ca6813d97195fbbc6697cd09b @tsibley tsibley committed with Feb 9, 2013
Showing with 15 additions and 2 deletions.
  1. +2 −1 tig.1.txt
  2. +5 −1 tig.c
  3. +8 −0 tigrc.5.txt
View
3 tig.1.txt
@@ -120,7 +120,8 @@ TIG_LS_REMOTE::
TIG_DIFF_OPTS::
The diff options to use in the diff view. The diff view uses
- git-show(1) for formatting and always passes --patch-with-stat.
+ git-show(1) for formatting and always passes --patch-with-stat. You
+ may also set the diff-options setting in your manpage:tigrc[5].
TIG_TRACE::
Path for trace file where information about git commands are logged.
View
6 tig.c
@@ -1426,6 +1426,9 @@ option_set_command(int argc, const char *argv[])
if (!strcmp(argv[0], "blame-options"))
return parse_args(&opt_blame_argv, argv + 2);
+ if (!strcmp(argv[0], "diff-options"))
+ return parse_args(&opt_diff_argv, argv + 2);
+
if (argc != 3)
return OPT_ERR_WRONG_NUMBER_OF_ARGUMENTS;
@@ -1705,6 +1708,7 @@ load_options(void)
const char *tigrc_user = getenv("TIGRC_USER");
const char *tigrc_system = getenv("TIGRC_SYSTEM");
const char *tig_diff_opts = getenv("TIG_DIFF_OPTS");
+ const bool diff_opts_from_args = !!opt_diff_argv;
char buf[SIZEOF_STR];
if (!tigrc_system)
@@ -1722,7 +1726,7 @@ load_options(void)
* that conflict with keybindings. */
add_builtin_run_requests();
- if (!opt_diff_argv && tig_diff_opts && *tig_diff_opts) {
+ if (!diff_opts_from_args && tig_diff_opts && *tig_diff_opts) {
static const char *diff_opts[SIZEOF_ARG] = { NULL };
int argc = 0;
View
8 tigrc.5.txt
@@ -143,6 +143,14 @@ The following variables can be set:
'core.abbrev' if found or default to 7. See git-config(1) on how to
set 'core.abbrev'.
+'diff-options' (string)::
+
+ A space separate string of diff options to use in the diff view.
+ git-show(1) is used for formatting and always passes --patch-with-stat.
+ This option overrides any options specified in the TIG_DIFF_OPTS
+ environment variable (described in manpage:tig[1]), but is itself
+ overridden by diff flags given on the command line invocation.
+
'blame-options' (string)::
A space separated string of extra blame options. Can be used for

0 comments on commit 3567c4e

Please sign in to comment.