Skip to content

Commit

Permalink
is_kept_pack(): final clean-up
Browse files Browse the repository at this point in the history
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 <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Feb 28, 2009
1 parent 03a9683 commit 69e020a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
4 changes: 2 additions & 2 deletions builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -1915,7 +1915,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
const unsigned char *sha1;
struct object *o;

if (is_kept_pack(p))
if (p->pack_keep)
continue;
if (open_pack_index(p))
die("cannot open pack index");
Expand Down Expand Up @@ -1951,7 +1951,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
const unsigned char *sha1;

for (p = packed_git; p; p = p->next) {
if (is_kept_pack(p))
if (p->pack_keep)
continue;

if (open_pack_index(p))
Expand Down
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned l
extern int move_temp_to_file(const char *tmpfile, const char *filename);

extern int has_sha1_pack(const unsigned char *sha1);
extern int has_sha1_kept_pack(const unsigned char *sha1);
extern int has_sha1_file(const unsigned char *sha1);
extern int has_loose_object_nonlocal(const unsigned char *sha1);

Expand Down
4 changes: 3 additions & 1 deletion revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,9 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
if (commit->object.flags & SHOWN)
return commit_ignore;
if (revs->unpacked &&
has_sha1_kept_pack(commit->object.sha1, revs))
(revs->kept_pack_only
? has_sha1_kept_pack(commit->object.sha1)
: has_sha1_pack(commit->object.sha1)))
return commit_ignore;
if (revs->show_all)
return commit_show;
Expand Down
3 changes: 0 additions & 3 deletions revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,4 @@ enum commit_action {

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

extern int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *);
extern int is_kept_pack(const struct packed_git *);

#endif
22 changes: 7 additions & 15 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include "refs.h"
#include "pack-revindex.h"
#include "sha1-lookup.h"
#include "diff.h"
#include "revision.h"

#ifndef O_NOATIME
#if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
Expand Down Expand Up @@ -1858,13 +1856,8 @@ off_t find_pack_entry_one(const unsigned char *sha1,
return 0;
}

int is_kept_pack(const struct packed_git *p)
{
return p->pack_keep;
}

static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
const struct rev_info *revs)
int kept_pack_only)
{
static struct packed_git *last_found = (void *)1;
struct packed_git *p;
Expand All @@ -1876,7 +1869,7 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
p = (last_found == (void *)1) ? packed_git : last_found;

do {
if (revs->kept_pack_only && !is_kept_pack(p))
if (kept_pack_only && !p->pack_keep)
goto next;
if (p->num_bad_objects) {
unsigned i;
Expand Down Expand Up @@ -1919,13 +1912,12 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,

static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
{
return find_pack_ent(sha1, e, NULL);
return find_pack_ent(sha1, e, 0);
}

static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e,
const struct rev_info *revs)
static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e)
{
return find_pack_ent(sha1, e, revs);
return find_pack_ent(sha1, e, 1);
}

struct packed_git *find_sha1_pack(const unsigned char *sha1,
Expand Down Expand Up @@ -2395,10 +2387,10 @@ int has_sha1_pack(const unsigned char *sha1)
return find_pack_entry(sha1, &e);
}

int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *revs)
int has_sha1_kept_pack(const unsigned char *sha1)
{
struct pack_entry e;
return find_kept_pack_entry(sha1, &e, revs);
return find_kept_pack_entry(sha1, &e);
}

int has_sha1_file(const unsigned char *sha1)
Expand Down

0 comments on commit 69e020a

Please sign in to comment.