Skip to content

Commit

Permalink
sha1_file.c: split has_loose_object() into local and non-local counte…
Browse files Browse the repository at this point in the history
…rparts

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Brandon Casey authored and Junio C Hamano committed Nov 12, 2008
1 parent 3c3df42 commit 0f4dc14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ extern int move_temp_to_file(const char *tmpfile, const char *filename);

extern int has_sha1_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);

extern int has_pack_file(const unsigned char *sha1);
extern int has_pack_index(const unsigned char *sha1);
Expand Down
19 changes: 13 additions & 6 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,23 +410,30 @@ void prepare_alt_odb(void)
read_info_alternates(get_object_directory(), 0);
}

static int has_loose_object(const unsigned char *sha1)
static int has_loose_object_local(const unsigned char *sha1)
{
char *name = sha1_file_name(sha1);
struct alternate_object_database *alt;
return !access(name, F_OK);
}

if (!access(name, F_OK))
return 1;
int has_loose_object_nonlocal(const unsigned char *sha1)
{
struct alternate_object_database *alt;
prepare_alt_odb();
for (alt = alt_odb_list; alt; alt = alt->next) {
name = alt->name;
fill_sha1_path(name, sha1);
fill_sha1_path(alt->name, sha1);
if (!access(alt->base, F_OK))
return 1;
}
return 0;
}

static int has_loose_object(const unsigned char *sha1)
{
return has_loose_object_local(sha1) ||
has_loose_object_nonlocal(sha1);
}

static unsigned int pack_used_ctr;
static unsigned int pack_mmap_calls;
static unsigned int peak_pack_open_windows;
Expand Down

0 comments on commit 0f4dc14

Please sign in to comment.