File tree Expand file tree Collapse file tree 3 files changed +25
-8
lines changed
Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ fn create_dir(p: &Path) -> Result<(), Error> {
108108}
109109
110110/// Options for use in [`into()`];
111- #[ derive( Copy , Clone , Default ) ]
111+ #[ derive( Copy , Clone ) ]
112112pub struct Options {
113113 /// If true, and the kind of repository to create has a worktree, then the destination directory must be empty.
114114 ///
@@ -119,6 +119,15 @@ pub struct Options {
119119 pub fs_capabilities : Option < gix_fs:: Capabilities > ,
120120}
121121
122+ impl Default for Options {
123+ fn default ( ) -> Self {
124+ Options {
125+ destination_must_be_empty : true ,
126+ fs_capabilities : None ,
127+ }
128+ }
129+ }
130+
122131/// Create a new `.git` repository of `kind` within the possibly non-existing `directory`
123132/// and return its path.
124133/// Note that this is a simple template-based initialization routine which should be accompanied with additional corrections
Original file line number Diff line number Diff line change @@ -293,7 +293,15 @@ pub fn open_with_environment_overrides(directory: impl Into<std::path::PathBuf>)
293293/// ```
294294#[ allow( clippy:: result_large_err) ]
295295pub fn init ( directory : impl AsRef < std:: path:: Path > ) -> Result < Repository , init:: Error > {
296- ThreadSafeRepository :: init ( directory, create:: Kind :: WithWorktree , create:: Options :: default ( ) ) . map ( Into :: into)
296+ ThreadSafeRepository :: init (
297+ directory,
298+ create:: Kind :: WithWorktree ,
299+ create:: Options {
300+ destination_must_be_empty : false ,
301+ ..Default :: default ( )
302+ } ,
303+ )
304+ . map ( Into :: into)
297305}
298306
299307/// See [`ThreadSafeRepository::init()`], but returns a [`Repository`] instead.
Original file line number Diff line number Diff line change @@ -552,7 +552,7 @@ mod blocking_io {
552552 }
553553
554554 #[ test]
555- fn fetch_and_checkout_into_non_empty_directory_is_allowed_by_default ( ) -> crate :: Result {
555+ fn fetch_and_checkout_into_non_empty_directory ( ) -> crate :: Result {
556556 let tmp = gix_testtools:: tempfile:: TempDir :: new ( ) ?;
557557 let existing_path = tmp. path ( ) . join ( "existing.txt" ) ;
558558 let existing_content = b"I was here before you" ;
@@ -562,7 +562,10 @@ mod blocking_io {
562562 remote:: repo ( "base" ) . path ( ) ,
563563 tmp. path ( ) ,
564564 gix:: create:: Kind :: WithWorktree ,
565- Default :: default ( ) ,
565+ gix:: create:: Options {
566+ destination_must_be_empty : false ,
567+ ..Default :: default ( )
568+ } ,
566569 restricted ( ) ,
567570 ) ?;
568571 let ( mut checkout, _out) =
@@ -835,10 +838,7 @@ fn clone_with_worktree_and_destination_must_be_empty() -> crate::Result {
835838 remote:: repo ( "base" ) . path ( ) ,
836839 tmp. path ( ) ,
837840 gix:: create:: Kind :: WithWorktree ,
838- gix:: create:: Options {
839- destination_must_be_empty : true ,
840- ..Default :: default ( )
841- } ,
841+ Default :: default ( ) ,
842842 restricted ( ) ,
843843 ) {
844844 Ok ( _) => unreachable ! ( "this should fail as the directory isn't empty" ) ,
You can’t perform that action at this time.
0 commit comments