aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-12-02 23:00:04 -0800
committerJunio C Hamano <gitster@pobox.com>2008-12-02 23:00:04 -0800
commit0fd9d7e66deb7071da2a568b96c94f94ee890908 (patch)
treee8af2cdc7eee0aaa92087e7e798aa8d1c0d6acf1 /sha1_file.c
parente23f6822df5ee0acfe244c819a419c3e7c8c9e7e (diff)
parent83d0289df6fb4deae100ee3fc37b90683c2e8c9f (diff)
downloadgit-0fd9d7e66deb7071da2a568b96c94f94ee890908.tar.gz
git-0fd9d7e66deb7071da2a568b96c94f94ee890908.tar.xz
Merge branch 'bc/maint-keep-pack' into maint
* bc/maint-keep-pack: repack: only unpack-unreachable if we are deleting redundant packs t7700: test that 'repack -a' packs alternate packed objects pack-objects: extend --local to mean ignore non-local loose objects too sha1_file.c: split has_loose_object() into local and non-local counterparts t7700: demonstrate mishandling of loose objects in an alternate ODB builtin-gc.c: use new pack_keep bitfield to detect .keep file existence repack: do not fall back to incremental repacking with [-a|-A] repack: don't repack local objects in packs with .keep file pack-objects: new option --honor-pack-keep packed_git: convert pack_local flag into a bitfield and add pack_keep t7700: demonstrate mishandling of objects in packs with a .keep file
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 4e05429ab..c35469d48 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;
@@ -828,6 +835,11 @@ struct packed_git *add_packed_git(const char *path, int path_len, int local)
return NULL;
}
memcpy(p->pack_name, path, path_len);
+
+ strcpy(p->pack_name + path_len, ".keep");
+ if (!access(p->pack_name, F_OK))
+ p->pack_keep = 1;
+
strcpy(p->pack_name + path_len, ".pack");
if (stat(p->pack_name, &st) || !S_ISREG(st.st_mode)) {
free(p);