Skip to content

Conversation

@wolfv
Copy link
Contributor

@wolfv wolfv commented Apr 16, 2025

One of the test files (0001-cross.patch) had an issue because empty whitespace lines are removed.

However, the old parser was looking for +, - and to add a line to the hunk.

With this modification, we try parsing until we find a next header and also take into account empty whitespace lines as context.

It will still fail on the example mentioned:

--- main.c
+++ main.c
@@ -1,4 +1,7 @@
+#include<stdio.h>
+
 int main() {
 double a;
--- a;
+++ a;
+printf("%d\n", a);
 }

Where the --- a; is interpreted as a "header".

I tried a little bit to add range counting to the parser so that this case would also be fixed but I didn't finish that yet. I think it should be doable though :)

@vrmiguel
Copy link
Collaborator

Awesome stuff, @wolfv!

Really sorry for the delay

@vrmiguel vrmiguel merged commit cbad97c into gitpatch-rs:main Apr 30, 2025
1 of 2 checks passed
@wolfv wolfv deleted the hunks branch May 6, 2025 08:47
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