Skip to content

Commit 613b42f

Browse files
stefanbellergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c2a13b commit 613b42f

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

packfile.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,11 +1845,7 @@ static int fill_pack_entry(const unsigned char *sha1,
18451845
return 1;
18461846
}
18471847

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)
18531849
{
18541850
struct list_head *pos;
18551851

@@ -1871,7 +1867,7 @@ int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
18711867
int has_sha1_pack(const unsigned char *sha1)
18721868
{
18731869
struct pack_entry e;
1874-
return find_pack_entry(sha1, &e);
1870+
return find_pack_entry(the_repository, sha1, &e);
18751871
}
18761872

18771873
int has_pack_index(const unsigned char *sha1)

packfile.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ extern int packed_object_info(struct packed_git *pack, off_t offset, struct obje
123123
extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);
124124
extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);
125125

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);
127132

128133
extern int has_sha1_pack(const unsigned char *sha1);
129134

sha1_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
12661266
}
12671267

12681268
while (1) {
1269-
if (find_pack_entry(real, &e))
1269+
if (find_pack_entry(the_repository, real, &e))
12701270
break;
12711271

12721272
/* Most likely it's a loose object. */
@@ -1275,7 +1275,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
12751275

12761276
/* Not a loose object; someone else may have just packed it. */
12771277
reprepare_packed_git(the_repository);
1278-
if (find_pack_entry(real, &e))
1278+
if (find_pack_entry(the_repository, real, &e))
12791279
break;
12801280

12811281
/* Check if it is a missing object */
@@ -1655,7 +1655,7 @@ static int freshen_loose_object(const unsigned char *sha1)
16551655
static int freshen_packed_object(const unsigned char *sha1)
16561656
{
16571657
struct pack_entry e;
1658-
if (!find_pack_entry(sha1, &e))
1658+
if (!find_pack_entry(the_repository, sha1, &e))
16591659
return 0;
16601660
if (e.p->freshened)
16611661
return 1;

0 commit comments

Comments
 (0)