aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorBrandon Casey <drafnel@gmail.com>2008-11-09 23:59:57 -0600
committerJunio C Hamano <gitster@pobox.com>2008-11-12 10:29:22 -0800
commit0f4dc14ac4945448f7309964afeb879d20408e07 (patch)
tree386464b1ec3421a6ee934d373a405b4daae7326d /sha1_file.c
parent3c3df429106770966397086b6d2bced452ec7383 (diff)
downloadgit-0f4dc14ac4945448f7309964afeb879d20408e07.tar.gz
git-0f4dc14ac4945448f7309964afeb879d20408e07.tar.xz
sha1_file.c: split has_loose_object() into local and non-local counterparts
Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/sha1_file.c b/sha1_file.c
index adb116350..0203de585 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -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;