File tree Expand file tree Collapse file tree 3 files changed +18
-22
lines changed
Expand file tree Collapse file tree 3 files changed +18
-22
lines changed Original file line number Diff line number Diff line change @@ -426,7 +426,7 @@ int odb_source_loose_read_object_info(struct odb_source *source,
426426 unsigned long size_scratch ;
427427 enum object_type type_scratch ;
428428
429- if (oi -> delta_base_oid )
429+ if (oi && oi -> delta_base_oid )
430430 oidclr (oi -> delta_base_oid , source -> odb -> repo -> hash_algo );
431431
432432 /*
@@ -437,13 +437,13 @@ int odb_source_loose_read_object_info(struct odb_source *source,
437437 * return value implicitly indicates whether the
438438 * object even exists.
439439 */
440- if (!oi -> typep && !oi -> sizep && !oi -> contentp ) {
440+ if (!oi || (! oi -> typep && !oi -> sizep && !oi -> contentp ) ) {
441441 struct stat st ;
442- if (!oi -> disk_sizep && (flags & OBJECT_INFO_QUICK ))
442+ if (( !oi || ! oi -> disk_sizep ) && (flags & OBJECT_INFO_QUICK ))
443443 return quick_has_loose (source -> loose , oid ) ? 0 : -1 ;
444444 if (stat_loose_object (source -> loose , oid , & st , & path ) < 0 )
445445 return -1 ;
446- if (oi -> disk_sizep )
446+ if (oi && oi -> disk_sizep )
447447 * oi -> disk_sizep = st .st_size ;
448448 return 0 ;
449449 }
Original file line number Diff line number Diff line change @@ -677,34 +677,31 @@ static int do_oid_object_info_extended(struct object_database *odb,
677677 const struct object_id * oid ,
678678 struct object_info * oi , unsigned flags )
679679{
680- static struct object_info blank_oi = OBJECT_INFO_INIT ;
681680 const struct cached_object * co ;
682681 const struct object_id * real = oid ;
683682 int already_retried = 0 ;
684683
685-
686684 if (flags & OBJECT_INFO_LOOKUP_REPLACE )
687685 real = lookup_replace_object (odb -> repo , oid );
688686
689687 if (is_null_oid (real ))
690688 return -1 ;
691689
692- if (!oi )
693- oi = & blank_oi ;
694-
695690 co = find_cached_object (odb , real );
696691 if (co ) {
697- if (oi -> typep )
698- * (oi -> typep ) = co -> type ;
699- if (oi -> sizep )
700- * (oi -> sizep ) = co -> size ;
701- if (oi -> disk_sizep )
702- * (oi -> disk_sizep ) = 0 ;
703- if (oi -> delta_base_oid )
704- oidclr (oi -> delta_base_oid , odb -> repo -> hash_algo );
705- if (oi -> contentp )
706- * oi -> contentp = xmemdupz (co -> buf , co -> size );
707- oi -> whence = OI_CACHED ;
692+ if (oi ) {
693+ if (oi -> typep )
694+ * (oi -> typep ) = co -> type ;
695+ if (oi -> sizep )
696+ * (oi -> sizep ) = co -> size ;
697+ if (oi -> disk_sizep )
698+ * (oi -> disk_sizep ) = 0 ;
699+ if (oi -> delta_base_oid )
700+ oidclr (oi -> delta_base_oid , odb -> repo -> hash_algo );
701+ if (oi -> contentp )
702+ * oi -> contentp = xmemdupz (co -> buf , co -> size );
703+ oi -> whence = OI_CACHED ;
704+ }
708705 return 0 ;
709706 }
710707
Original file line number Diff line number Diff line change @@ -2138,7 +2138,6 @@ int packfile_store_read_object_info(struct packfile_store *store,
21382138 struct object_info * oi ,
21392139 unsigned flags UNUSED )
21402140{
2141- static struct object_info blank_oi = OBJECT_INFO_INIT ;
21422141 struct pack_entry e ;
21432142 int rtype ;
21442143
@@ -2149,7 +2148,7 @@ int packfile_store_read_object_info(struct packfile_store *store,
21492148 * We know that the caller doesn't actually need the
21502149 * information below, so return early.
21512150 */
2152- if (oi == & blank_oi )
2151+ if (! oi )
21532152 return 0 ;
21542153
21552154 rtype = packed_object_info (store -> odb -> repo , e .p , e .offset , oi );
You can’t perform that action at this time.
0 commit comments