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

diff parsing, regardless of diff-prefix choices #1337

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions include/tig/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ typedef struct view_column *view_settings;
_(commit_order, enum commit_order, VIEW_LOG_LIKE) \
_(diff_context, int, VIEW_DIFF_LIKE) \
_(diff_noprefix, bool, VIEW_NO_FLAGS) \
// TODO: _(diff_dstprefix,
// TODO: _(diff_srcprefix,
_(diff_options, const char **, VIEW_DIFF_LIKE) \
_(diff_highlight, const char *, VIEW_DIFF_LIKE) \
_(word_diff, bool, VIEW_DIFF_LIKE) \
Expand Down
6 changes: 4 additions & 2 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,9 @@ diff_trace_origin(struct view *view, struct line *line)
for (; diff < line && !file; diff++) {
const char *data = box_text(diff);

if (!prefixcmp(data, "--- a/")) {
file = data + STRING_SIZE("--- a/");
// TODO: make a diff file name parser generic
if (!prefixcmp(data, "--- ")) {
file = data + (opt_diff_noprefix ? STRING_SIZE("--- ") : STRING_SIZE("--- a/"));
break;
}
}
Expand Down Expand Up @@ -735,6 +736,7 @@ diff_get_pathname(struct view *view, struct line *line, bool old)
if (!header)
return NULL;

// TODO: make a diff file name parser generic
name = box_text(header);
if (old ? !prefixcmp(name, "--- ") : !prefixcmp(name, "+++ "))
name += STRING_SIZE("+++ ");
Expand Down
4 changes: 4 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,10 @@ read_repo_config_option(char *name, size_t namelen, char *value, size_t valuelen
else if (!strcmp(name, "diff.noprefix"))
parse_bool(&opt_diff_noprefix, value);

// TODO: else if (!strcmp(name, "diff.dstprefix")) and store it somewhere

// TODO: else if (!strcmp(name, "diff.srcprefix")) and store it somewhere

else if (!strcmp(name, "status.showuntrackedfiles"))
opt_status_show_untracked_files = !!strcmp(value, "no"),
opt_status_show_untracked_dirs = !strcmp(value, "all");
Expand Down