Skip to content

Commit

Permalink
Make word-diff a toggleable option (#1125)
Browse files Browse the repository at this point in the history
Closes #1119
  • Loading branch information
koutcher authored Oct 4, 2021
1 parent b396a5d commit 02e2643
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/tig/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef struct view_column *view_settings;
_(diff_noprefix, bool, VIEW_NO_FLAGS) \
_(diff_options, const char **, VIEW_DIFF_LIKE) \
_(diff_highlight, const char *, VIEW_DIFF_LIKE) \
_(word_diff, bool, VIEW_DIFF_LIKE) \
_(diff_view, view_settings, VIEW_NO_FLAGS) \
_(editor_line_number, bool, VIEW_NO_FLAGS) \
_(file_args, const char **, VIEW_NO_FLAGS) \
Expand Down Expand Up @@ -183,7 +184,6 @@ extern iconv_t opt_iconv_out;
extern char opt_editor[SIZEOF_STR];
extern const char **opt_cmdline_args;
extern bool opt_log_follow;
extern bool opt_word_diff;

/*
* Mapping between options and command argument mapping.
Expand All @@ -197,6 +197,7 @@ const char *commit_order_arg_with_graph(enum graph_display graph_display);
const char *log_custom_pretty_arg();
const char *use_mailmap_arg();
const char *diff_context_arg();
const char *word_diff_arg();
const char *show_notes_arg();

/*
Expand Down
4 changes: 2 additions & 2 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ diff_open(struct view *view, enum open_flags flags)
"git", "show", encoding_arg, "--pretty=fuller", "--root",
"--patch-with-stat", use_mailmap_arg(),
show_notes_arg(), diff_context_arg(), ignore_space_arg(),
DIFF_ARGS, "%(cmdlineargs)", "--no-color", "%(commit)",
"--", "%(fileargs)", NULL
DIFF_ARGS, "%(cmdlineargs)", "--no-color", word_diff_arg(),
"%(commit)", "--", "%(fileargs)", NULL
};
enum status_code code;

Expand Down
8 changes: 8 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ diff_context_arg()
return opt_diff_context_arg;
}

const char *
word_diff_arg()
{
return opt_word_diff ? "--word-diff=plain" : "--word-diff=none";
}

const char *
use_mailmap_arg()
{
Expand Down Expand Up @@ -257,6 +263,8 @@ update_options_from_argv(const char *argv[])
if (!strcmp(flag, "--word-diff") ||
!strcmp(flag, "--word-diff=plain")) {
opt_word_diff = true;
mark_option_seen(&opt_word_diff);
continue;
}

argv[flags_pos++] = flag;
Expand Down

0 comments on commit 02e2643

Please sign in to comment.