Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make word-diff a toggleable option #1125

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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