@@ -486,9 +486,7 @@ let run_with_exit_code { dir; _ } ~allow_codes ~display args =
486486 minimum supported version is Git 2.29."
487487 ]
488488 ~hints: [ User_message. command " Please update your git version." ]
489- | _ ->
490- Console. print [ Pp. verbatim stderr ];
491- Error { Git_error. dir; args; exit_code; output = [] })
489+ | _ -> Error { Git_error. dir; args; exit_code; output = [ stderr ] })
492490;;
493491
494492let run t ~display args =
@@ -725,15 +723,16 @@ let fetch_allow_failure repo ~url obj =
725723 | true -> Fiber. return `Fetched
726724 | false ->
727725 run_with_exit_code
728- ~allow_codes: (fun x -> x = 0 || x = 128 )
726+ ~allow_codes: (Int. equal 0 )
729727 repo
730728 ~display: ! Dune_engine.Clflags. display
731729 [ " fetch" ; " --no-write-fetch-head" ; url; Object. to_hex obj ]
732730 >> | (function
733- | Ok 128 -> `Not_found
734731 | Ok 0 ->
735732 Table. set repo.present_objects obj () ;
736733 `Fetched
734+ | Error { Git_error. exit_code; output; _ } when exit_code = 128 ->
735+ `Not_found output
737736 | Error git_error -> Git_error. raise_code_error git_error
738737 | _ -> assert false ))
739738;;
@@ -742,8 +741,14 @@ let fetch repo ~url obj =
742741 fetch_allow_failure repo ~url obj
743742 >> | function
744743 | `Fetched -> ()
745- | `Not_found ->
746- User_error. raise [ Pp. textf " unable to fetch %S from %S" (Object. to_hex obj) url ]
744+ | `Not_found output ->
745+ User_error. raise
746+ ([ Pp. textf
747+ " Dune was unable to fetch %S from %S due to the following git fetch error:"
748+ (Object. to_hex obj)
749+ url
750+ ]
751+ @ List. map ~f: Pp. verbatim output)
747752;;
748753
749754module Debug = struct
@@ -1156,8 +1161,8 @@ let resolve_revision t (remote : Remote.t) ~revision =
11561161let fetch_object t (remote : Remote.t ) revision =
11571162 fetch_allow_failure t ~url: remote.url revision
11581163 >> = function
1159- | `Not_found -> Fiber. return None
1160- | `Fetched -> At_rev. of_rev t ~revision >> | Option. some
1164+ | `Not_found git_output -> Fiber. return ( Error git_output)
1165+ | `Fetched -> At_rev. of_rev t ~revision >> | Result. ok
11611166;;
11621167
11631168let content_of_files t files =
0 commit comments