Skip to content

Commit 0a0dd63

Browse files
stefanbellergitster
authored andcommitted
packfile: allow find_pack_entry to handle arbitrary repositories
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 613b42f commit 0a0dd63

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packfile.c

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

1848-
int find_pack_entry_the_repository(const unsigned char *sha1, struct pack_entry *e)
1848+
int find_pack_entry(struct repository *r, const unsigned char *sha1, struct pack_entry *e)
18491849
{
18501850
struct list_head *pos;
18511851

1852-
prepare_packed_git(the_repository);
1853-
if (!the_repository->objects->packed_git)
1852+
prepare_packed_git(r);
1853+
if (!r->objects->packed_git)
18541854
return 0;
18551855

1856-
list_for_each(pos, &the_repository->objects->packed_git_mru) {
1856+
list_for_each(pos, &r->objects->packed_git_mru) {
18571857
struct packed_git *p = list_entry(pos, struct packed_git, mru);
18581858
if (fill_pack_entry(sha1, e, p)) {
1859-
list_move(&p->mru,
1860-
&the_repository->objects->packed_git_mru);
1859+
list_move(&p->mru, &r->objects->packed_git_mru);
18611860
return 1;
18621861
}
18631862
}

packfile.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);
127127
* Iff a pack file in the given repository contains the object named by sha1,
128128
* return true and store its location to e.
129129
*/
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);
130+
extern int find_pack_entry(struct repository *r, const unsigned char *sha1, struct pack_entry *e);
132131

133132
extern int has_sha1_pack(const unsigned char *sha1);
134133

0 commit comments

Comments
 (0)