Skip to content

Commit b8431b0

Browse files
committed
has_sha1_kept_pack(): take "struct rev_info"
Its "ignore_packed" parameter always comes from struct rev_info. This patch makes the function take a pointer to the surrounding structure, so that the refactoring in the next patch becomes easier to review. There is an unfortunate header file dependency and the easiest workaround is to temporarily move the function declaration from cache.h to revision.h; this will be moved back to cache.h once the function loses this "ignore_packed" parameter altogether in the later part of the series. Signed-off-by: Junio C Hamano <[email protected]>
1 parent cd673c1 commit b8431b0

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned l
566566
extern int move_temp_to_file(const char *tmpfile, const char *filename);
567567

568568
extern int has_sha1_pack(const unsigned char *sha1);
569-
extern int has_sha1_kept_pack(const unsigned char *sha1, const char **ignore);
570569
extern int has_sha1_file(const unsigned char *sha1);
571570
extern int has_loose_object_nonlocal(const unsigned char *sha1);
572571

revision.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
14861486
if (commit->object.flags & SHOWN)
14871487
return commit_ignore;
14881488
if (revs->unpacked &&
1489-
has_sha1_kept_pack(commit->object.sha1, revs->ignore_packed))
1489+
has_sha1_kept_pack(commit->object.sha1, revs))
14901490
return commit_ignore;
14911491
if (revs->show_all)
14921492
return commit_show;

revision.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,6 @@ enum commit_action {
158158

159159
extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
160160

161+
extern int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *);
162+
161163
#endif

sha1_file.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "refs.h"
1717
#include "pack-revindex.h"
1818
#include "sha1-lookup.h"
19+
#include "diff.h"
20+
#include "revision.h"
1921

2022
#ifndef O_NOATIME
2123
#if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
@@ -1875,7 +1877,7 @@ int matches_pack_name(struct packed_git *p, const char *name)
18751877
}
18761878

18771879
static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
1878-
const char **ignore_packed)
1880+
const struct rev_info *revs)
18791881
{
18801882
static struct packed_git *last_found = (void *)1;
18811883
struct packed_git *p;
@@ -1887,9 +1889,9 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
18871889
p = (last_found == (void *)1) ? packed_git : last_found;
18881890

18891891
do {
1890-
if (ignore_packed) {
1892+
if (revs->ignore_packed) {
18911893
const char **ig;
1892-
for (ig = ignore_packed; *ig; ig++)
1894+
for (ig = revs->ignore_packed; *ig; ig++)
18931895
if (matches_pack_name(p, *ig))
18941896
break;
18951897
if (*ig)
@@ -1941,9 +1943,9 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
19411943
}
19421944

19431945
static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e,
1944-
const char **ignore_packed)
1946+
const struct rev_info *revs)
19451947
{
1946-
return find_pack_ent(sha1, e, ignore_packed);
1948+
return find_pack_ent(sha1, e, revs);
19471949
}
19481950

19491951
struct packed_git *find_sha1_pack(const unsigned char *sha1,
@@ -2413,10 +2415,10 @@ int has_sha1_pack(const unsigned char *sha1)
24132415
return find_pack_entry(sha1, &e);
24142416
}
24152417

2416-
int has_sha1_kept_pack(const unsigned char *sha1, const char **ignore_packed)
2418+
int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *revs)
24172419
{
24182420
struct pack_entry e;
2419-
return find_kept_pack_entry(sha1, &e, ignore_packed);
2421+
return find_kept_pack_entry(sha1, &e, revs);
24202422
}
24212423

24222424
int has_sha1_file(const unsigned char *sha1)

0 commit comments

Comments
 (0)