diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-02-27 23:43:37 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-02-28 01:06:06 -0800 |
commit | 386cb77210cdb09cd808698d21d0e796cd77f26f (patch) | |
tree | 0a8460ca2365d52c864cec23cb17a2ffb31ba577 /sha1_file.c | |
parent | b8431b033f9e60f87a75b864612873307a3e5966 (diff) | |
download | git-386cb77210cdb09cd808698d21d0e796cd77f26f.tar.gz |
Consolidate ignore_packed logic more
This refactors three loops that check if a given packfile is on the
ignore_packed list into a function is_kept_pack(). The function returns
false for a pack on the list, and true for a pack not on the list, because
this list is solely used by "git repack" to pass list of packfiles that do
not have corresponding .keep files, i.e. a packfile not on the list is
"kept".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/sha1_file.c b/sha1_file.c index f963c3cadb..6e0a462f10 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1858,7 +1858,7 @@ off_t find_pack_entry_one(const unsigned char *sha1, return 0; } -int matches_pack_name(struct packed_git *p, const char *name) +static int matches_pack_name(const struct packed_git *p, const char *name) { const char *last_c, *c; @@ -1876,6 +1876,17 @@ int matches_pack_name(struct packed_git *p, const char *name) 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; +} + static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e, const struct rev_info *revs) { @@ -1889,15 +1900,8 @@ 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) { - const char **ig; - for (ig = revs->ignore_packed; *ig; ig++) - if (matches_pack_name(p, *ig)) - break; - if (*ig) - goto next; - } - + if (revs->ignore_packed && !is_kept_pack(p, revs)) + goto next; if (p->num_bad_objects) { unsigned i; for (i = 0; i < p->num_bad_objects; i++) |