-
Notifications
You must be signed in to change notification settings - Fork 415
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
Make diffing work on Windows #904
Conversation
@diml is this WIP? |
nope, I forgot to change the title |
Thanks, I've tested it and it seems to work fine ! |
src/action.ml
Outdated
; "diff?", | ||
(path >>= fun file1 -> | ||
path >>= fun file2 -> | ||
Syntax.get_exn Stanza.syntax >>| fun ver -> | ||
let mode = if ver < (1, 0) then Diff_mode.Text_jbuild else Text in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This idiom should be extracted IMO. Something like Syntax.choose syntax ~jbuild:... ~dune:...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreeed. I added Stanza.file_kind
, the advantage compared to choose
is that it cost less when the two values require computation.
Bytes.blit_string src src_pos dst dst_pos len; | ||
let dst_pos = dst_pos + len in | ||
Bytes.set dst dst_pos '\n'; | ||
loop (i + 2) (dst_pos + 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you give writing this a code try with mutual recursion style? I find that much easier to read usually. I'm pretty certain that you did, since I basically learned this technique from you, but the current code is a bit hard to follow. Anyway, I've convinced myself that this is correct so approving
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I did but there were a lot of variables to maintain so I thought it was better this way
- make (diff ...) trailing cr on Win32 - add a (cmp ...) action for comparing binary files - add a test and run it in AppVeyor Fix #844 Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This PR changes the behavior of
(diff a b)
on Windows. Currently, it is common to compare a generated file against a source one. However, it is often the case that on Windows the generated file contains lines ending with\r\n
, which causes the comparison to fail if the source file has unix end of lines.After this PR,
(diff a b)
normalizes the end of lines on Windows before comparing the files. Additionally, it passes--skip-trailing-cr
todiff
on Windows so thatdiff
does the same comparison as Dune.In some cases,
diff
might be used to compare binary files. For this purpose acmp
action was added.(cmp a b)
always compare the raw contents ofa
andb
and never callsdiff
. Instead it simply prints:Promoted files are still promoted as it. It's not clear what Dune should do but I expect that people working on Windows configure their git so that files are checkouted with Windows end of lines.