Skip to content

unified diff parser in unified-diff-parser branch parsing issues #46

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

Closed
uwesimm opened this issue Aug 9, 2019 · 5 comments
Closed

unified diff parser in unified-diff-parser branch parsing issues #46

uwesimm opened this issue Aug 9, 2019 · 5 comments

Comments

@uwesimm
Copy link

uwesimm commented Aug 9, 2019

hi

a unified diff such as the one below is not parsed properly. i do see that the parse complete however the fromFile gets updated with the content of the line '---' out of the line fragments. essentially the fromFile is "some comment" after the parse.

--- a.vhd	2019-04-18 13:49:39.516149751 +0200
+++ b.vhd	2019-04-18 11:33:08.372563078 +0200
@@ -2819,3 +2819,3 @@
--- some comment
-bla
-bla
+
+

read the above unified patch into using

  val diff = UnifiedDiffReader.parseUnifiedDiff(diff_file)
@uwesimm
Copy link
Author

uwesimm commented Aug 12, 2019

from the code i would guess that the same problem happens with lines starting with '--' or '++' since they are parsed as fromfile to tofile. the '---' and '+++' need to be distinguished with their context ...

@wumpz
Copy link
Collaborator

wumpz commented Aug 12, 2019

My problem is, that there seems to be no complete specification of how such a file should look like. That's why I guessed a lot and now have to adapt to such cases. Help is appreciated.

@uwesimm
Copy link
Author

uwesimm commented Aug 13, 2019

hi

the closest thing i saw is (https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html#Detailed-Unified). This doesnt explain whats happening between diffs though. I looked at the code but i didnt see something for a quick fix. I think parsing has to distinguish between non-diff-sections (diff, index etc) ,diff-header (---,+++) and hunks (@@,fragments). I'll revisit this as time permits

@uwesimm
Copy link
Author

uwesimm commented Aug 13, 2019

btw an almost good short implementation i found is here https://stackoverflow.com/questions/3560073/how-to-write-parser-for-unified-diff-syntax

@wumpz
Copy link
Collaborator

wumpz commented Sep 21, 2019

The actual version has a complete rewrite of the parser logic. It is able to parse your problem file.

wumpz added a commit that referenced this issue Sep 21, 2019
@wumpz wumpz closed this as completed in 73263b4 Sep 21, 2019
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

No branches or pull requests

2 participants