Code

packed_git: convert pack_local flag into a bitfield and add pack_keep
authorBrandon Casey <drafnel@gmail.com>
Wed, 12 Nov 2008 17:59:03 +0000 (11:59 -0600)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Nov 2008 18:28:08 +0000 (10:28 -0800)
pack_keep will be set when a pack file has an associated .keep file.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
sha1_file.c

diff --git a/cache.h b/cache.h
index a1e4982cd424ec5c3695c2221583bca1bd861614..1a5740f5899628b2d2b3ed063b81f89a21308d67 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -671,7 +671,8 @@ extern struct packed_git {
        int index_version;
        time_t mtime;
        int pack_fd;
-       int pack_local;
+       unsigned pack_local:1,
+                pack_keep:1;
        unsigned char sha1[20];
        /* something like ".git/objects/pack/xxxxx.pack" */
        char pack_name[FLEX_ARRAY]; /* more */
index 12fc767ee57103739e568a959981ca559417ecf4..adb116350bd38db0390f4f731e509f3fe703a1c1 100644 (file)
@@ -828,6 +828,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);