Skip to content

Commit

Permalink
Fix ocaml#3627: use git -c diff.noprefix=false diff (ocaml#3788)
Browse files Browse the repository at this point in the history
Fix ocaml#3627 by ensuring git produces a `-p1` diff. This is a very limited
fix but appears to work in my usecase. I have reviewed the other uses of
`git diff` in the same file, but it appears their output is not passed
to `patch` hence this change is unnecessary.
  • Loading branch information
rjbou committed Mar 28, 2019
1 parent 04e8535 commit c093d94
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/repository/opamGit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ module VCS : OpamVCS.VCS = struct
git repo_root [ "init" ];
(* Enforce this option, it can break our use of git if set *)
git repo_root [ "config" ; "--local" ; "fetch.prune"; "false"];
(* We reset diff.noprefix to ensure we get a `-p1` patch and avoid <https://github.com/ocaml/opam/issues/3627>. *)
git repo_root [ "config" ; "--local" ; "diff.noprefix"; "false"];
(* Document the remote for user-friendliness (we don't use it) *)
git repo_root [ "remote"; "add"; "origin"; OpamUrl.base_url repo_url ];
] @@+ function
Expand Down Expand Up @@ -156,7 +158,8 @@ module VCS : OpamVCS.VCS = struct
(* Git diff is to the working dir, but doesn't work properly for
unregistered directories. *)
OpamSystem.raise_on_process_error r;
git repo_root ~stdout:patch_file [ "diff" ; "--no-ext-diff" ; "-R" ; "-p" ; rref; "--" ]
(* We also reset diff.noprefix here to handle already existing repo. *)
git repo_root ~stdout:patch_file [ "-c" ; "diff.noprefix=false" ; "diff" ; "--no-ext-diff" ; "-R" ; "-p" ; rref; "--" ]
@@> fun r ->
if not (OpamProcess.check_success_and_cleanup r) then
(finalise ();
Expand Down

0 comments on commit c093d94

Please sign in to comment.