summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 44d1c19)
raw | patch | inline | side by side (parent: 44d1c19)
author | Linus Torvalds <torvalds@linux-foundation.org> | |
Sat, 14 Jun 2008 18:43:01 +0000 (11:43 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 14 Jun 2008 21:39:22 +0000 (14:39 -0700) |
Now that we've made the loose SHA1 file reading more careful and
streamlined, we only use the old find_sha1_file() function for checking
whether a loose object file exists at all.
As such, the whole 'return stat information' part of it was just
pointless (nobody cares any more), and the naming of the function is not
really all that relevant either.
So simplify it to not do a 'stat()', but just an existence check (which
is what the callers want), and rename it to 'has_loose_object()' which
matches the use.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
streamlined, we only use the old find_sha1_file() function for checking
whether a loose object file exists at all.
As such, the whole 'return stat information' part of it was just
pointless (nobody cares any more), and the naming of the function is not
really all that relevant either.
So simplify it to not do a 'stat()', but just an existence check (which
is what the callers want), and rename it to 'has_loose_object()' which
matches the use.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c | patch | blob | history |
diff --git a/sha1_file.c b/sha1_file.c
index 71a25e78c2afd4adedd1f4f768e5b47e4894cdda..37bcc5474efac82ab2c822947bae8a738d342bca 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
read_info_alternates(get_object_directory(), 0);
}
-static char *find_sha1_file(const unsigned char *sha1, struct stat *st)
+static int has_loose_object(const unsigned char *sha1)
{
char *name = sha1_file_name(sha1);
struct alternate_object_database *alt;
- if (!stat(name, st))
- return name;
+ if (!access(name, F_OK))
+ return 1;
prepare_alt_odb();
for (alt = alt_odb_list; alt; alt = alt->next) {
name = alt->name;
fill_sha1_path(name, sha1);
- if (!stat(alt->base, st))
- return alt->base;
+ if (!access(alt->base, F_OK))
+ return 1;
}
- return NULL;
+ return 0;
}
static unsigned int pack_used_ctr;
@@ -2232,14 +2232,13 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha
int force_object_loose(const unsigned char *sha1, time_t mtime)
{
- struct stat st;
void *buf;
unsigned long len;
enum object_type type;
char hdr[32];
int hdrlen;
- if (find_sha1_file(sha1, &st))
+ if (has_loose_object(sha1))
return 0;
buf = read_packed_sha1(sha1, &type, &len);
if (!buf)
int has_sha1_file(const unsigned char *sha1)
{
- struct stat st;
struct pack_entry e;
if (find_pack_entry(sha1, &e, NULL))
return 1;
- return find_sha1_file(sha1, &st) ? 1 : 0;
+ return has_loose_object(sha1);
}
int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)