Skip to content

Commit 69e020a

Browse files
committed
is_kept_pack(): final clean-up
Now is_kept_pack() is just a member lookup into a structure, we can write it as such. Also rewrite the sole caller of has_sha1_kept_pack() to switch on the criteria the callee uses (namely, revs->kept_pack_only) between calling has_sha1_kept_pack() and has_sha1_pack(), so that these two callees do not have to take a pointer to struct rev_info as an argument. This removes the header file dependency issue temporarily introduced by the earlier commit, so we revert changes associated to that as well. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 03a9683 commit 69e020a

File tree

5 files changed

+13
-21
lines changed

5 files changed

+13
-21
lines changed

builtin-pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,7 +1915,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
19151915
const unsigned char *sha1;
19161916
struct object *o;
19171917

1918-
if (is_kept_pack(p))
1918+
if (p->pack_keep)
19191919
continue;
19201920
if (open_pack_index(p))
19211921
die("cannot open pack index");
@@ -1951,7 +1951,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
19511951
const unsigned char *sha1;
19521952

19531953
for (p = packed_git; p; p = p->next) {
1954-
if (is_kept_pack(p))
1954+
if (p->pack_keep)
19551955
continue;
19561956

19571957
if (open_pack_index(p))

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ 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);
569570
extern int has_sha1_file(const unsigned char *sha1);
570571
extern int has_loose_object_nonlocal(const unsigned char *sha1);
571572

revision.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,9 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
14761476
if (commit->object.flags & SHOWN)
14771477
return commit_ignore;
14781478
if (revs->unpacked &&
1479-
has_sha1_kept_pack(commit->object.sha1, revs))
1479+
(revs->kept_pack_only
1480+
? has_sha1_kept_pack(commit->object.sha1)
1481+
: has_sha1_pack(commit->object.sha1)))
14801482
return commit_ignore;
14811483
if (revs->show_all)
14821484
return commit_show;

revision.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,4 @@ enum commit_action {
156156

157157
extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
158158

159-
extern int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *);
160-
extern int is_kept_pack(const struct packed_git *);
161-
162159
#endif

sha1_file.c

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

2220
#ifndef O_NOATIME
2321
#if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
@@ -1858,13 +1856,8 @@ off_t find_pack_entry_one(const unsigned char *sha1,
18581856
return 0;
18591857
}
18601858

1861-
int is_kept_pack(const struct packed_git *p)
1862-
{
1863-
return p->pack_keep;
1864-
}
1865-
18661859
static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
1867-
const struct rev_info *revs)
1860+
int kept_pack_only)
18681861
{
18691862
static struct packed_git *last_found = (void *)1;
18701863
struct packed_git *p;
@@ -1876,7 +1869,7 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
18761869
p = (last_found == (void *)1) ? packed_git : last_found;
18771870

18781871
do {
1879-
if (revs->kept_pack_only && !is_kept_pack(p))
1872+
if (kept_pack_only && !p->pack_keep)
18801873
goto next;
18811874
if (p->num_bad_objects) {
18821875
unsigned i;
@@ -1919,13 +1912,12 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
19191912

19201913
static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
19211914
{
1922-
return find_pack_ent(sha1, e, NULL);
1915+
return find_pack_ent(sha1, e, 0);
19231916
}
19241917

1925-
static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e,
1926-
const struct rev_info *revs)
1918+
static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e)
19271919
{
1928-
return find_pack_ent(sha1, e, revs);
1920+
return find_pack_ent(sha1, e, 1);
19291921
}
19301922

19311923
struct packed_git *find_sha1_pack(const unsigned char *sha1,
@@ -2395,10 +2387,10 @@ int has_sha1_pack(const unsigned char *sha1)
23952387
return find_pack_entry(sha1, &e);
23962388
}
23972389

2398-
int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *revs)
2390+
int has_sha1_kept_pack(const unsigned char *sha1)
23992391
{
24002392
struct pack_entry e;
2401-
return find_kept_pack_entry(sha1, &e, revs);
2393+
return find_kept_pack_entry(sha1, &e);
24022394
}
24032395

24042396
int has_sha1_file(const unsigned char *sha1)

0 commit comments

Comments
 (0)