@@ -581,7 +581,17 @@ extern size_t packed_git_limit;
581581extern size_t delta_base_cache_limit ;
582582extern unsigned long big_file_threshold ;
583583extern unsigned long pack_size_limit_cfg ;
584- extern int read_replace_refs ;
584+
585+ /*
586+ * Do replace refs need to be checked this run? This variable is
587+ * initialized to true unless --no-replace-object is used or
588+ * $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some
589+ * commands that do not want replace references to be active. As an
590+ * optimization it is also set to false if replace references have
591+ * been sought but there were none.
592+ */
593+ extern int check_replace_refs ;
594+
585595extern int fsync_object_files ;
586596extern int core_preload_index ;
587597extern int core_apply_sparse_checkout ;
@@ -808,13 +818,26 @@ static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *
808818{
809819 return read_sha1_file_extended (sha1 , type , size , LOOKUP_REPLACE_OBJECT );
810820}
821+
822+ /*
823+ * This internal function is only declared here for the benefit of
824+ * lookup_replace_object(). Please do not call it directly.
825+ */
811826extern const unsigned char * do_lookup_replace_object (const unsigned char * sha1 );
827+
828+ /*
829+ * If object sha1 should be replaced, return the replacement object's
830+ * name (replaced recursively, if necessary). The return value is
831+ * either sha1 or a pointer to a permanently-allocated value. When
832+ * object replacement is suppressed, always return sha1.
833+ */
812834static inline const unsigned char * lookup_replace_object (const unsigned char * sha1 )
813835{
814- if (!read_replace_refs )
836+ if (!check_replace_refs )
815837 return sha1 ;
816838 return do_lookup_replace_object (sha1 );
817839}
840+
818841static inline const unsigned char * lookup_replace_object_extended (const unsigned char * sha1 , unsigned flag )
819842{
820843 if (!(flag & LOOKUP_REPLACE_OBJECT ))
0 commit comments