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

Conversation

gcb
Copy link

@gcb gcb commented May 22, 2024

handle all diff view options (noprefix, mnemonicPrefix, srcPrefix, dstPrefix, line-prefix)

(moved quick fix of #1336 to #1338)

gcb added 2 commits May 22, 2024 14:19
src/diff.c Outdated
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

@gcb
Copy link
Author

gcb commented May 23, 2024

Confess I only went for a patch because it would get the 1337 id...

Looking the code just around the error message, I already had all the context to send in a fix in a language i haven't touched in over 15years. The text area here was enough "IDE support". I'm aware this is not "done" code, but was enough to downloaded my branch, build, and get the feature i needed without considering edge cases. Haven't looked at the failing test yet 🙄

Well, just meant this as an appreciation note. Thank you. Had used tig for years, but never had a reason to look at the nice source, which is another compliment I guess. cheers.

@koutcher
Copy link
Collaborator

7h4nk5 for reporting and trying to fix the issue. Test case is failing because your fix breaks the original prefixed use case.

@gcb
Copy link
Author

gcb commented May 26, 2024

Thanks for pointing out the test issue! will try to polish this when i get some down time next month, if nobody beat me to it.

src/diff.c Outdated
const char *data_n1 = box_text(diff+1);
const char *data_n2 = box_text(diff+2);
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

@gcb gcb changed the title change diff parsing diff parsing, regardless of diff-prefix choices May 30, 2024
@gcb
Copy link
Author

gcb commented May 30, 2024

also needs to account for mnemonicPrefix, srcPrefix, dstPrefix, line-prefix, which can change prefix letters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants