Simplify is_kept_pack()

This removes --unpacked=<packfile> parameter from the revision parser, and
rewrites its use in git-repack to pass a single --kept-pack-only option
instead.

The new --kept-pack-only option means just that.  When this option is
given, is_kept_pack() that used to say "not on the --unpacked=<packfile>
list" now says "the packfile has corresponding .keep file".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2009-02-28 00:00:21 -08:00
parent 386cb77210
commit 03a9683d22
5 changed files with 18 additions and 51 deletions

View File

@ -1858,33 +1858,9 @@ off_t find_pack_entry_one(const unsigned char *sha1,
return 0;
}
static int matches_pack_name(const struct packed_git *p, const char *name)
int is_kept_pack(const struct packed_git *p)
{
const char *last_c, *c;
if (!strcmp(p->pack_name, name))
return 1;
for (c = p->pack_name, last_c = c; *c;)
if (*c == '/')
last_c = ++c;
else
++c;
if (!strcmp(last_c, name))
return 1;
return 0;
}
int is_kept_pack(const struct packed_git *p, const struct rev_info *revs)
{
int i;
for (i = 0; i < revs->num_ignore_packed; i++) {
if (matches_pack_name(p, revs->ignore_packed[i]))
return 0;
}
return 1;
return p->pack_keep;
}
static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
@ -1900,7 +1876,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->ignore_packed && !is_kept_pack(p, revs))
if (revs->kept_pack_only && !is_kept_pack(p))
goto next;
if (p->num_bad_objects) {
unsigned i;