[PATCH 2/3] packed_git: add new PACK_KEEP flag and haspackkeep() access macro
- From
drafnel@gmail.com <drafnel@gmail.com>
- Date
- Nov 2, 2008, 16:31 UTC
- Message-ID
- <14846251.1225643403413.JavaMail.teamon@b303.teamon.com>
- In-Reply-To
- <1225643477-32319-1-git-send-email-foo@foo.com>
From: Brandon Casey <drafnel@gmail.com>
If you want to tell whether a pack has an associated ".keep" file you would do:
if (haspackkeep(p))
do_somethingSigned-off-by: Brandon Casey <drafnel@gmail.com> --- cache.h | 2 ++ sha1_file.c | 5 +++++ 2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/cache.h b/cache.h index 0cb9350..48cd366 100644 --- a/cache.h +++ b/cache.h @@ -686,7 +686,9 @@ extern struct packed_git { } *packed_git; #define PACK_LOCAL 1 +#define PACK_KEEP 2 #define ispacklocal(p) ((p)->flags & PACK_LOCAL) +#define haspackkeep(p) ((p)->flags & PACK_KEEP) struct pack_entry { off_t offset; diff --git a/sha1_file.c b/sha1_file.c index e4141c9..8a027e9 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -841,6 +841,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->flags |= PACK_KEEP; + strcpy(p->pack_name + path_len, ".pack"); if (stat(p->pack_name, &st) || !S_ISREG(st.st_mode)) { free(p);
-- 1.6.0.2.588.g3102