@@ -2,6 +2,7 @@ use anyhow::bail;
22use std:: path:: { Path , PathBuf } ;
33
44use git_repository as git;
5+ use git_repository:: worktree:: index:: checkout;
56use git_repository:: { odb:: FindExt , Progress } ;
67
78pub struct Options {
@@ -106,6 +107,7 @@ pub mod checkout_exclusive {
106107 pub index : super :: Options ,
107108 /// If true, all files will be written with zero bytes despite having made an ODB lookup.
108109 pub empty_files : bool ,
110+ pub keep_going : bool ,
109111 }
110112}
111113
@@ -117,6 +119,7 @@ pub fn checkout_exclusive(
117119 checkout_exclusive:: Options {
118120 index : Options { object_hash, .. } ,
119121 empty_files,
122+ keep_going,
120123 } : checkout_exclusive:: Options ,
121124) -> anyhow:: Result < ( ) > {
122125 let repo = repo
@@ -157,6 +160,7 @@ pub fn checkout_exclusive(
157160 // TODO: turn the two following flags into an enum
158161 destination_is_initially_empty : true ,
159162 overwrite_existing : false ,
163+ keep_going,
160164 ..Default :: default ( )
161165 } ;
162166
@@ -168,7 +172,7 @@ pub fn checkout_exclusive(
168172 bytes. init ( None , git:: progress:: bytes ( ) ) ;
169173
170174 let start = std:: time:: Instant :: now ( ) ;
171- match & repo {
175+ let checkout :: Outcome { errors , collisions } = match & repo {
172176 Some ( repo) => git:: worktree:: index:: checkout (
173177 & mut index,
174178 dest_directory,
@@ -209,5 +213,19 @@ pub fn checkout_exclusive(
209213 entries_for_checkout,
210214 repo. is_none( ) . then( || "empty" ) . unwrap_or_default( )
211215 ) ) ;
216+
217+ if !( collisions. is_empty ( ) && errors. is_empty ( ) ) {
218+ let mut messages = Vec :: new ( ) ;
219+ if !errors. is_empty ( ) {
220+ messages. push ( format ! ( "kept going through {} errors(s)" , errors. len( ) ) ) ;
221+ }
222+ if !collisions. is_empty ( ) {
223+ messages. push ( format ! ( "encountered {} collision(s)" , collisions. len( ) ) ) ;
224+ }
225+ bail ! (
226+ "One or more errors occurred - checkout is incomplete: {}" ,
227+ messages. join( ", " )
228+ ) ;
229+ }
212230 Ok ( ( ) )
213231}
0 commit comments