Skip to content

Commit

Permalink
has_sha1_kept_pack(): take "struct rev_info"
Browse files Browse the repository at this point in the history
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 <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Feb 28, 2009
1 parent cd673c1 commit b8431b0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ 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, const char **ignore);
extern int has_sha1_file(const unsigned char *sha1);
extern int has_loose_object_nonlocal(const unsigned char *sha1);

Expand Down
2 changes: 1 addition & 1 deletion revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ 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->ignore_packed))
has_sha1_kept_pack(commit->object.sha1, revs))
return commit_ignore;
if (revs->show_all)
return commit_show;
Expand Down
2 changes: 2 additions & 0 deletions revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,6 @@ 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 *);

#endif
16 changes: 9 additions & 7 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#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 @@ -1875,7 +1877,7 @@ int matches_pack_name(struct packed_git *p, const char *name)
}

static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
const char **ignore_packed)
const struct rev_info *revs)
{
static struct packed_git *last_found = (void *)1;
struct packed_git *p;
Expand All @@ -1887,9 +1889,9 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
p = (last_found == (void *)1) ? packed_git : last_found;

do {
if (ignore_packed) {
if (revs->ignore_packed) {
const char **ig;
for (ig = ignore_packed; *ig; ig++)
for (ig = revs->ignore_packed; *ig; ig++)
if (matches_pack_name(p, *ig))
break;
if (*ig)
Expand Down Expand Up @@ -1941,9 +1943,9 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
}

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

struct packed_git *find_sha1_pack(const unsigned char *sha1,
Expand Down Expand Up @@ -2413,10 +2415,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 char **ignore_packed)
int has_sha1_kept_pack(const unsigned char *sha1, const struct rev_info *revs)
{
struct pack_entry e;
return find_kept_pack_entry(sha1, &e, ignore_packed);
return find_kept_pack_entry(sha1, &e, revs);
}

int has_sha1_file(const unsigned char *sha1)
Expand Down

0 comments on commit b8431b0

Please sign in to comment.