packfile: add repository argument to find_pack_entry

While at it move the documentation to the header and mention which pack files are searched. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Mar 23, 2018 at 18:45 UTC 613b42f283140308435939377994c4d57d0dda23
3 files changed +11 -10
packfile.c
+2 -6
@@ -1845,11 +1845,7 @@ static int fill_pack_entry(const unsigned char *sha1,
1845 return 1;
1846 }
1847
1848 -/*
1849 - * Iff a pack file contains the object named by sha1, return true and
1850 - * store its location to e.
1851 - */
1852 -int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
1848 +int find_pack_entry_the_repository(const unsigned char *sha1, struct pack_entry *e)
1849 {
1850 struct list_head *pos;
1851
@@ -1871,7 +1867,7 @@ int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
1867 int has_sha1_pack(const unsigned char *sha1)
1868 {
1869 struct pack_entry e;
1874 - return find_pack_entry(sha1, &e);
1870 + return find_pack_entry(the_repository, sha1, &e);
1871 }
1872
1873 int has_pack_index(const unsigned char *sha1)
packfile.h
+6 -1
@@ -123,7 +123,12 @@ extern int packed_object_info(struct packed_git *pack, off_t offset, struct obje
123 extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);
124 extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);
125
126 -extern int find_pack_entry(const unsigned char *sha1, struct pack_entry *e);
126 +/*
127 + * Iff a pack file in the given repository contains the object named by sha1,
128 + * return true and store its location to e.
129 + */
130 +#define find_pack_entry(r, s, e) find_pack_entry_##r(s, e)
131 +extern int find_pack_entry_the_repository(const unsigned char *sha1, struct pack_entry *e);
132
133 extern int has_sha1_pack(const unsigned char *sha1);
134
sha1_file.c
+3 -3
@@ -1266,7 +1266,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
1266 }
1267
1268 while (1) {
1269 - if (find_pack_entry(real, &e))
1269 + if (find_pack_entry(the_repository, real, &e))
1270 break;
1271
1272 /* Most likely it's a loose object. */
@@ -1275,7 +1275,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
1275
1276 /* Not a loose object; someone else may have just packed it. */
1277 reprepare_packed_git(the_repository);
1278 - if (find_pack_entry(real, &e))
1278 + if (find_pack_entry(the_repository, real, &e))
1279 break;
1280
1281 /* Check if it is a missing object */
@@ -1655,7 +1655,7 @@ static int freshen_loose_object(const unsigned char *sha1)
1655 static int freshen_packed_object(const unsigned char *sha1)
1656 {
1657 struct pack_entry e;
1658 - if (!find_pack_entry(sha1, &e))
1658 + if (!find_pack_entry(the_repository, sha1, &e))
1659 return 0;
1660 if (e.p->freshened)
1661 return 1;