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
Changes from 2 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
11 changes: 7 additions & 4 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,13 @@ 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/");
break;
if (!prefixcmp(data, "--- ")) {
const char *data_n1 = box_text(diff+1);
const char *data_n2 = box_text(diff+2);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably needs a bounds check here

if(!prefixcmp(data_n1, "+++ ") && !prefixcmp(data_n2, "@@ ")){
file = data + STRING_SIZE("--- ");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these hardcoded strings can probably be from https://github.com/jonas/tig/blob/master/include/tig/line.h#L29

break;
}
}
}

Expand Down