3 type patch
= patchitem list
4 and patchitem
= File
of filename
* string (* header line *) * string list
6 let parse_patch filename
=
7 let xs = Common.cat filename
in
8 let xxs = Common.split_list_regexp
"^diff" xs in
9 xxs +> List.map
(fun (s
, body
) ->
10 if s
=~
"^diff --git a/\\([^ ]*\\) b/\\([^ ]*\\)"
12 let (a
,b
) = matched2 s
in
16 else failwith
("wrong line in git diff:" ^ s
)
20 let unparse_patch xs outfile
=
21 Common.with_open_outfile outfile
(fun (pr_no_nl
, _chan
) ->
22 let pr s
= pr_no_nl
(s ^
"\n") in
24 xs +> List.iter
(function (File
(file
, header
, body
)) ->