File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -61,12 +61,22 @@ struct InMemoryBuilder {
6161
6262impl InMemoryBuilder {
6363 fn new ( ) -> Self {
64- Self {
65- pending_writes : HashMap :: new ( ) ,
66- }
64+ // Add an empty blob because we use a shortcut for them below
65+ // in write_blob
66+ let mut pending_writes = HashMap :: new ( ) ;
67+ pending_writes. insert (
68+ gix_hash:: ObjectId :: empty_blob ( gix_hash:: Kind :: Sha1 ) ,
69+ ( gix_object:: Kind :: Blob , Vec :: new ( ) ) ,
70+ ) ;
71+
72+ Self { pending_writes }
6773 }
6874
6975 fn write_blob ( & mut self , data : & [ u8 ] ) -> gix_hash:: ObjectId {
76+ if data. is_empty ( ) {
77+ return gix_hash:: ObjectId :: empty_blob ( gix_hash:: Kind :: Sha1 ) ;
78+ }
79+
7080 let hash = gix_object:: compute_hash ( gix_hash:: Kind :: Sha1 , gix_object:: Kind :: Blob , data)
7181 . expect ( "failed to compute hash" ) ;
7282 self . pending_writes
You can’t perform that action at this time.
0 commit comments