@@ -659,9 +659,28 @@ extern char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)
659659extern char * git_path_submodule (const char * path , const char * fmt , ...)
660660 __attribute__((format (printf , 2 , 3 )));
661661
662+ /*
663+ * Return the name of the file in the local object database that would
664+ * be used to store a loose object with the specified sha1. The
665+ * return value is a pointer to a statically allocated buffer that is
666+ * overwritten each time the function is called.
667+ */
662668extern const char * sha1_file_name (const unsigned char * sha1 );
669+
670+ /*
671+ * Return the name of the (local) packfile with the specified sha1 in
672+ * its name. The return value is a pointer to memory that is
673+ * overwritten each time this function is called.
674+ */
663675extern char * sha1_pack_name (const unsigned char * sha1 );
676+
677+ /*
678+ * Return the name of the (local) pack index file with the specified
679+ * sha1 in its name. The return value is a pointer to memory that is
680+ * overwritten each time this function is called.
681+ */
664682extern char * sha1_pack_index_name (const unsigned char * sha1 );
683+
665684extern const char * find_unique_abbrev (const unsigned char * sha1 , int );
666685extern const unsigned char null_sha1 [20 ];
667686
@@ -820,7 +839,19 @@ extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned l
820839extern int move_temp_to_file (const char * tmpfile , const char * filename );
821840
822841extern int has_sha1_pack (const unsigned char * sha1 );
842+
843+ /*
844+ * Return true iff we have an object named sha1, whether local or in
845+ * an alternate object database, and whether packed or loose. This
846+ * function does not respect replace references.
847+ */
823848extern int has_sha1_file (const unsigned char * sha1 );
849+
850+ /*
851+ * Return true iff an alternate object database has a loose object
852+ * with the specified name. This function does not respect replace
853+ * references.
854+ */
824855extern int has_loose_object_nonlocal (const unsigned char * sha1 );
825856
826857extern int has_pack_index (const unsigned char * sha1 );
@@ -1083,17 +1114,46 @@ extern struct packed_git *find_sha1_pack(const unsigned char *sha1,
10831114 struct packed_git * packs );
10841115
10851116extern void pack_report (void );
1117+
1118+ /*
1119+ * mmap the index file for the specified packfile (if it is not
1120+ * already mmapped). Return 0 on success.
1121+ */
10861122extern int open_pack_index (struct packed_git * );
1123+
1124+ /*
1125+ * munmap the index file for the specified packfile (if it is
1126+ * currently mmapped).
1127+ */
10871128extern void close_pack_index (struct packed_git * );
1129+
10881130extern unsigned char * use_pack (struct packed_git * , struct pack_window * * , off_t , unsigned long * );
10891131extern void close_pack_windows (struct packed_git * );
10901132extern void unuse_pack (struct pack_window * * );
10911133extern void free_pack_by_name (const char * );
10921134extern void clear_delta_base_cache (void );
10931135extern struct packed_git * add_packed_git (const char * , int , int );
1094- extern const unsigned char * nth_packed_object_sha1 (struct packed_git * , uint32_t );
1095- extern off_t nth_packed_object_offset (const struct packed_git * , uint32_t );
1096- extern off_t find_pack_entry_one (const unsigned char * , struct packed_git * );
1136+
1137+ /*
1138+ * Return the SHA-1 of the nth object within the specified packfile.
1139+ * Open the index if it is not already open. The return value points
1140+ * at the SHA-1 within the mmapped index. Return NULL if there is an
1141+ * error.
1142+ */
1143+ extern const unsigned char * nth_packed_object_sha1 (struct packed_git * , uint32_t n );
1144+
1145+ /*
1146+ * Return the offset of the nth object within the specified packfile.
1147+ * The index must already be opened.
1148+ */
1149+ extern off_t nth_packed_object_offset (const struct packed_git * , uint32_t n );
1150+
1151+ /*
1152+ * If the object named sha1 is present in the specified packfile,
1153+ * return its offset within the packfile; otherwise, return 0.
1154+ */
1155+ extern off_t find_pack_entry_one (const unsigned char * sha1 , struct packed_git * );
1156+
10971157extern int is_pack_valid (struct packed_git * );
10981158extern void * unpack_entry (struct packed_git * , off_t , enum object_type * , unsigned long * );
10991159extern unsigned long unpack_object_header_buffer (const unsigned char * buf , unsigned long len , enum object_type * type , unsigned long * sizep );
0 commit comments