summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-04-29 10:21:03 -0700
committerVicent Martí <vicent@github.com>2013-04-29 10:21:03 -0700
commitbb503dbd0326abd6fe714b99cd7e64c482130867 (patch)
treeca8196f1a3d1d644b51d0e7046ce5d4f11c38eb9
parent51a91ce8c6d8129788841975e4ff213bc2953bb4 (diff)
parentc8a4e8a5f6acc94c46c8a7ea2cf3f9d67b50e07a (diff)
downloadlibgit2-bb503dbd0326abd6fe714b99cd7e64c482130867.tar.gz
Merge pull request #1516 from ethomson/win32_alternate_nostat
don't use uninitialized struct stat in win32
-rw-r--r--src/odb.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/odb.c b/src/odb.c
index 53630dddc..64e1232f5 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -445,31 +445,39 @@ static int add_default_backends(
{
size_t i;
struct stat st;
+ ino_t inode;
git_odb_backend *loose, *packed;
/* TODO: inodes are not really relevant on Win32, so we need to find
* a cross-platform workaround for this */
-#ifndef GIT_WIN32
+#ifdef GIT_WIN32
+ GIT_UNUSED(i);
+ GIT_UNUSED(st);
+
+ inode = 0;
+#else
if (p_stat(objects_dir, &st) < 0) {
giterr_set(GITERR_ODB, "Failed to load object database in '%s'", objects_dir);
return -1;
}
+ inode = st.st_ino;
+
for (i = 0; i < db->backends.length; ++i) {
backend_internal *backend = git_vector_get(&db->backends, i);
- if (backend->disk_inode == st.st_ino)
+ if (backend->disk_inode == inode)
return 0;
}
#endif
/* add the loose object backend */
if (git_odb_backend_loose(&loose, objects_dir, -1, 0) < 0 ||
- add_backend_internal(db, loose, GIT_LOOSE_PRIORITY, as_alternates, st.st_ino) < 0)
+ add_backend_internal(db, loose, GIT_LOOSE_PRIORITY, as_alternates, inode) < 0)
return -1;
/* add the packed file backend */
if (git_odb_backend_pack(&packed, objects_dir) < 0 ||
- add_backend_internal(db, packed, GIT_PACKED_PRIORITY, as_alternates, st.st_ino) < 0)
+ add_backend_internal(db, packed, GIT_PACKED_PRIORITY, as_alternates, inode) < 0)
return -1;
return load_alternates(db, objects_dir, alternate_depth);