File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,12 @@ pub mod main_worktree {
6565 ///
6666 /// Note that this is a no-op if the remote was empty, leaving this repository empty as well. This can be validated by checking
6767 /// if the `head()` of the returned repository is *not* unborn.
68+ ///
69+ /// # Panics
70+ ///
71+ /// If called after it was successful. The reason here is that it auto-deletes the contained repository,
72+ /// and keeps track of this by means of keeping just one repository instance, which is passed to the user
73+ /// after success.
6874 pub fn main_worktree < P > (
6975 & mut self ,
7076 mut progress : P ,
@@ -86,7 +92,7 @@ pub mod main_worktree {
8692 let repo = self
8793 . repo
8894 . as_ref ( )
89- . expect ( "still present as we never succeeded the worktree checkout yet " ) ;
95+ . expect ( "BUG: this method may only be called until it is successful " ) ;
9096 let workdir = repo. work_dir ( ) . ok_or_else ( || Error :: BareRepository {
9197 git_dir : repo. git_dir ( ) . to_owned ( ) ,
9298 } ) ?;
@@ -138,7 +144,7 @@ pub mod main_worktree {
138144 bytes. show_throughput ( start) ;
139145
140146 index. write ( Default :: default ( ) ) ?;
141- Ok ( ( self . repo . take ( ) . expect ( "still present" ) , outcome) )
147+ Ok ( ( self . repo . take ( ) . expect ( "still present" ) . clone ( ) , outcome) )
142148 }
143149 }
144150}
Original file line number Diff line number Diff line change @@ -140,13 +140,13 @@ impl PrepareFetch {
140140 }
141141}
142142
143- /// A utility to collect configuration on how to perform a checkout into a working tree, and when dropped without checking out successfully
144- /// the fetched repository will be dropped .
143+ /// A utility to collect configuration on how to perform a checkout into a working tree,
144+ /// and when dropped without checking out successfully the fetched repository will be deleted from disk .
145145#[ must_use]
146146#[ cfg( feature = "worktree-mutation" ) ]
147147#[ derive( Debug ) ]
148148pub struct PrepareCheckout {
149- /// A freshly initialized repository which is owned by us, or `None` if it was handed to the user
149+ /// A freshly initialized repository which is owned by us, or `None` if it was successfully checked out.
150150 pub ( self ) repo : Option < crate :: Repository > ,
151151 /// The name of the reference to check out. If `None`, the reference pointed to by `HEAD` will be checked out.
152152 pub ( self ) ref_name : Option < gix_ref:: PartialName > ,
You can’t perform that action at this time.
0 commit comments