packfile: convert find_pack_entry to object_id
Convert find_pack_entry and the static function fill_pack_entry to take pointers to struct object_id. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
May 2, 2018 at 00:25 UTC
544443cb3cca4d5e48dfd8bd3c704a7e52b89ee6
3 files changed
+10
-10
packfile.c
+6
-6
@@ -1805,7 +1805,7 @@ struct packed_git *find_sha1_pack(const unsigned char *sha1,
1805
1806
}
1807
1808
-static int fill_pack_entry(const unsigned char *sha1,
1808
+static int fill_pack_entry(const struct object_id *oid,
1809
struct pack_entry *e,
1810
struct packed_git *p)
1811
{
@@ -1814,11 +1814,11 @@ static int fill_pack_entry(const unsigned char *sha1,
1814
if (p->num_bad_objects) {
1815
unsigned i;
1816
for (i = 0; i < p->num_bad_objects; i++)
1817
- if (!hashcmp(sha1, p->bad_object_sha1 + 20 * i))
1817
+ if (!hashcmp(oid->hash, p->bad_object_sha1 + 20 * i))
1818
return 0;
1819
}
1820
1821
- offset = find_pack_entry_one(sha1, p);
1821
+ offset = find_pack_entry_one(oid->hash, p);
1822
if (!offset)
1823
return 0;
1824
@@ -1836,7 +1836,7 @@ static int fill_pack_entry(const unsigned char *sha1,
1836
return 1;
1837
}
1838
1839
-int find_pack_entry(struct repository *r, const unsigned char *sha1, struct pack_entry *e)
1839
+int find_pack_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e)
1840
{
1841
struct list_head *pos;
1842
@@ -1846,7 +1846,7 @@ int find_pack_entry(struct repository *r, const unsigned char *sha1, struct pack
1846
1847
list_for_each(pos, &r->objects->packed_git_mru) {
1848
struct packed_git *p = list_entry(pos, struct packed_git, mru);
1849
- if (fill_pack_entry(sha1, e, p)) {
1849
+ if (fill_pack_entry(oid, e, p)) {
1850
list_move(&p->mru, &r->objects->packed_git_mru);
1851
return 1;
1852
}
@@ -1857,7 +1857,7 @@ int find_pack_entry(struct repository *r, const unsigned char *sha1, struct pack
1857
int has_object_pack(const struct object_id *oid)
1858
{
1859
struct pack_entry e;
1860
- return find_pack_entry(the_repository, oid->hash, &e);
1860
+ return find_pack_entry(the_repository, oid, &e);
1861
}
1862
1863
int has_pack_index(const unsigned char *sha1)
packfile.h
+1
-1
@@ -134,7 +134,7 @@ extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);
134
* Iff a pack file in the given repository contains the object named by sha1,
135
* return true and store its location to e.
136
*/
137
-extern int find_pack_entry(struct repository *r, const unsigned char *sha1, struct pack_entry *e);
137
+extern int find_pack_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e);
138
139
extern int has_object_pack(const struct object_id *oid);
140
sha1_file.c
+3
-3
@@ -1268,7 +1268,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
1268
}
1269
1270
while (1) {
1271
- if (find_pack_entry(the_repository, real->hash, &e))
1271
+ if (find_pack_entry(the_repository, real, &e))
1272
break;
1273
1274
if (flags & OBJECT_INFO_IGNORE_LOOSE)
@@ -1281,7 +1281,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
1281
/* Not a loose object; someone else may have just packed it. */
1282
if (!(flags & OBJECT_INFO_QUICK)) {
1283
reprepare_packed_git(the_repository);
1284
- if (find_pack_entry(the_repository, real->hash, &e))
1284
+ if (find_pack_entry(the_repository, real, &e))
1285
break;
1286
}
1287
@@ -1669,7 +1669,7 @@ static int freshen_loose_object(const struct object_id *oid)
1669
static int freshen_packed_object(const struct object_id *oid)
1670
{
1671
struct pack_entry e;
1672
- if (!find_pack_entry(the_repository, oid->hash, &e))
1672
+ if (!find_pack_entry(the_repository, oid, &e))
1673
return 0;
1674
if (e.p->freshened)
1675
return 1;