File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,8 +117,9 @@ pub struct Options {
117117 /// If set, use these filesystem capabilities to populate the respective git-config fields.
118118 /// If `None`, the directory will be probed.
119119 pub fs_capabilities : Option < gix_fs:: Capabilities > ,
120- /// If set to `Some(Sha256)`, initialize the repository with SHA-256.
121- /// Otherwise, no object hash will be explicitly set for the repository.
120+ /// If set to `Some(Sha256)`, write `extensions.objectFormat=sha256`.
121+ /// Otherwise, create a repository without an explicit object-format extension,
122+ /// which is interpreted as legacy SHA-1.
122123 pub object_hash : Option < gix_hash:: Kind > ,
123124}
124125
@@ -231,7 +232,6 @@ pub fn into(
231232 core. push ( key ( "repositoryformatversion" ) , Some ( "1" . into ( ) ) ) ;
232233
233234 let mut extensions = config. new_section ( "extensions" , None ) . expect ( "valid section name" ) ;
234-
235235 extensions. push (
236236 key ( "objectformat" ) ,
237237 Some ( gix_hash:: Kind :: Sha256 . to_string ( ) . as_bytes ( ) . into ( ) ) ,
Original file line number Diff line number Diff line change @@ -40,16 +40,16 @@ fn decode_uses_the_tree_id_hash_kind() -> crate::Result {
4040 let mut data = b"100644 file\0 " . to_vec ( ) ;
4141 data. extend_from_slice ( bogus_other_hash_entry_id. as_bytes ( ) ) ;
4242
43- let bogux_other_hash_tree_id = other_hash. empty_tree ( ) ;
44- let tree = gix:: Tree :: from_data ( bogux_other_hash_tree_id , data, & repo) ;
43+ let bogus_other_hash_tree_id = other_hash. empty_tree ( ) ;
44+ let tree = gix:: Tree :: from_data ( bogus_other_hash_tree_id , data, & repo) ;
4545 let decoded = tree. decode ( ) ?;
4646
4747 assert_eq ! ( decoded. entries. len( ) , 1 ) ;
4848 assert_eq ! ( decoded. entries[ 0 ] . filename, b"file" . as_bstr( ) ) ;
4949 assert_eq ! ( decoded. entries[ 0 ] . oid, bogus_other_hash_entry_id. as_ref( ) ) ;
5050 assert_eq ! (
5151 bogus_other_hash_entry_id. kind( ) ,
52- bogux_other_hash_tree_id . kind( ) ,
52+ bogus_other_hash_tree_id . kind( ) ,
5353 "both kinds are expected to match, the `repo.object_hash()` doesn't matter here"
5454 ) ;
5555 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -136,33 +136,36 @@ mod traverse {
136136 . collect:: <Vec <_>>( )
137137 ) ;
138138
139- // Generated through `git log --graph --oneline`.
140- //
141- // SHA-1:
142- //
143- // f99771f A
144- // |\
145- // | * 2d9d136 C
146- // | |
147- // | \
148- // *-. | dfd0954 (tag: b-tag) B
149- // |\ \|
150- // | | * 27e7157 (grafted) F
151- // | * b515286 (grafted) E
152- // * 82024b2 (grafted) D
153- //
154- // SHA-256:
155- //
156- // e36613f A
157- // |\
158- // | * 1e485b4 C
159- // | |
160- // | \
161- // *-. | 94c0c58 (tag: b-tag) B
162- // |\ \|
163- // | | * c2eec0d (grafted) F
164- // | * a5d87b4 (grafted) E
165- // * 125ce6c (grafted) D
139+ if !toggle && name == "shallow" {
140+ let graph = gix_testtools:: git ( repo. git_dir ( ) , "log --graph --oneline" ) ?;
141+ match gix_testtools:: object_hash ( ) {
142+ gix_hash:: Kind :: Sha1 => insta:: assert_snapshot!( graph, @r"
143+ * f99771f A
144+ |\
145+ | * 2d9d136 C
146+ | |
147+ | \
148+ *-. | dfd0954 B
149+ |\ \|
150+ | | * 27e7157 F
151+ | * b515286 E
152+ * 82024b2 D
153+ " ) ,
154+ gix_hash:: Kind :: Sha256 => insta:: assert_snapshot!( graph, @r"
155+ * e36613f A
156+ |\
157+ | * 1e485b4 C
158+ | |
159+ | \
160+ *-. | 94c0c58 B
161+ |\ \|
162+ | | * c2eec0d F
163+ | * a5d87b4 E
164+ * 125ce6c D
165+ " ) ,
166+ _ => unimplemented ! ( ) ,
167+ }
168+ }
166169 }
167170 }
168171 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments