From: drafnel@gmail.com
To: git@vger.kernel.org
Cc: gitster@pobox.com, nico@cam.org, spearce@spearce.org,
Brandon Casey <drafnel@gmail.com>
Subject: [PATCH 1/3] packed_git: convert pack_local flag into generic bit mask
Date: Sun, 2 Nov 2008 10:31:15 -0600 [thread overview]
Message-ID: <6141358.1225643400587.JavaMail.teamon@b303.teamon.com> (raw)
In-Reply-To: <14536526.1225596838300.JavaMail.teamon@b301.teamon.com>
From: Brandon Casey <drafnel@gmail.com>
This converts the pack_local flag of the packed_git structure into a generic
bit mask and introduces a PACK_LOCAL mask and an ispacklocal() access macro.
So instead of this:
if (p->pack_local)
do_something
you would do this:
if (ispacklocal(p))
do_something
This is in preparation for adding a flag indicating whether a .keep file is
present.
Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
builtin-count-objects.c | 2 +-
builtin-gc.c | 2 +-
builtin-pack-objects.c | 2 +-
cache.h | 5 ++++-
pack-redundant.c | 4 ++--
server-info.c | 4 ++--
sha1_file.c | 5 +++--
7 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/builtin-count-objects.c b/builtin-count-objects.c
index ab35b65..3f981d6 100644
--- a/builtin-count-objects.c
+++ b/builtin-count-objects.c
@@ -108,7 +108,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
if (!packed_git)
prepare_packed_git();
for (p = packed_git; p; p = p->next) {
- if (!p->pack_local)
+ if (!ispacklocal(p))
continue;
if (open_pack_index(p))
continue;
diff --git a/builtin-gc.c b/builtin-gc.c
index 7af65bb..0473158 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -135,7 +135,7 @@ static int too_many_packs(void)
size_t len;
int keep;
- if (!p->pack_local)
+ if (!ispacklocal(p))
continue;
len = strlen(p->pack_name);
if (PATH_MAX <= len + 1)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 59c30d1..6a8b9bf 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -701,7 +701,7 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,
break;
if (incremental)
return 0;
- if (local && !p->pack_local)
+ if (local && !ispacklocal(p))
return 0;
}
}
diff --git a/cache.h b/cache.h
index b0edbf9..0cb9350 100644
--- a/cache.h
+++ b/cache.h
@@ -679,12 +679,15 @@ extern struct packed_git {
int index_version;
time_t mtime;
int pack_fd;
- int pack_local;
+ unsigned int flags;
unsigned char sha1[20];
/* something like ".git/objects/pack/xxxxx.pack" */
char pack_name[FLEX_ARRAY]; /* more */
} *packed_git;
+#define PACK_LOCAL 1
+#define ispacklocal(p) ((p)->flags & PACK_LOCAL)
+
struct pack_entry {
off_t offset;
unsigned char sha1[20];
diff --git a/pack-redundant.c b/pack-redundant.c
index 25b81a4..964f18f 100644
--- a/pack-redundant.c
+++ b/pack-redundant.c
@@ -544,7 +544,7 @@ static struct pack_list * add_pack(struct packed_git *p)
unsigned long off = 0, step;
const unsigned char *base;
- if (!p->pack_local && !(alt_odb || verbose))
+ if (!ispacklocal(p) && !(alt_odb || verbose))
return NULL;
l.pack = p;
@@ -562,7 +562,7 @@ static struct pack_list * add_pack(struct packed_git *p)
}
/* this list will be pruned in cmp_two_packs later */
l.unique_objects = llist_copy(l.all_objects);
- if (p->pack_local)
+ if (ispacklocal(p))
return pack_list_insert(&local_packs, &l);
else
return pack_list_insert(&altodb_packs, &l);
diff --git a/server-info.c b/server-info.c
index c1c073b..2eb20f5 100644
--- a/server-info.c
+++ b/server-info.c
@@ -168,14 +168,14 @@ static void init_pack_info(const char *infofile, int force)
/* we ignore things on alternate path since they are
* not available to the pullers in general.
*/
- if (!p->pack_local)
+ if (!ispacklocal(p))
continue;
i++;
}
num_pack = i;
info = xcalloc(num_pack, sizeof(struct pack_info *));
for (i = 0, p = packed_git; p; p = p->next) {
- if (!p->pack_local)
+ if (!ispacklocal(p))
continue;
info[i] = xcalloc(1, sizeof(struct pack_info));
info[i]->p = p;
diff --git a/sha1_file.c b/sha1_file.c
index ab2b520..e4141c9 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -851,7 +851,8 @@ struct packed_git *add_packed_git(const char *path, int path_len, int local)
* actually mapping the pack file.
*/
p->pack_size = st.st_size;
- p->pack_local = local;
+ if (local)
+ p->flags |= PACK_LOCAL;
p->mtime = st.st_mtime;
if (path_len < 40 || get_sha1_hex(path + path_len - 40, p->sha1))
hashclr(p->sha1);
@@ -941,7 +942,7 @@ static int sort_pack(const void *a_, const void *b_)
* remote ones could be on a network mounted filesystem.
* Favor local ones for these reasons.
*/
- st = a->pack_local - b->pack_local;
+ st = ispacklocal(a) - ispacklocal(b);
if (st)
return -st;
--
1.6.0.2.588.g3102
next prev parent reply other threads:[~2008-11-02 16:31 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-31 19:32 getting list of objects for packing Brandon Casey
2008-10-31 20:40 ` Nicolas Pitre
2008-10-31 20:48 ` Brandon Casey
2008-10-31 21:30 ` Junio C Hamano
2008-10-31 21:40 ` Brandon Casey
2008-10-31 22:23 ` Jakub Narebski
2008-11-01 0:00 ` Brandon Casey
2008-11-02 3:35 ` [PATCH] t7700: demonstrate mishandling of objects in packs with a .keep file drafnel
2008-11-02 16:31 ` drafnel [this message]
2008-11-03 16:12 ` [PATCH 1/3] packed_git: convert pack_local flag into generic bit mask Shawn O. Pearce
2008-11-03 18:24 ` Brandon Casey
2008-11-03 20:37 ` [PATCH v2 1/3] t7700: demonstrate mishandling of objects in packs with a .keep file Brandon Casey
2008-11-03 20:41 ` [PATCH v2 2/3] packed_git: convert pack_local flag into a bitfield and add pack_keep Brandon Casey
2008-11-03 20:43 ` [PATCH v2 3/3] pack-objects: honor '.keep' files Brandon Casey
2008-11-03 20:49 ` Shawn O. Pearce
2008-11-05 22:37 ` Brandon Casey
2008-11-06 23:22 ` Brandon Casey
2008-11-07 0:30 ` Junio C Hamano
2008-11-07 1:17 ` Brandon Casey
2008-11-07 8:12 ` Andreas Ericsson
2008-11-07 19:25 ` Shawn O. Pearce
2008-11-10 5:59 ` recognize loose local objects during repack drafnel
2008-11-10 21:03 ` Junio C Hamano
[not found] ` <1226296798-31522-1-git-send-email-foo@foo.com>
2008-11-10 5:59 ` [PATCH 1/3] t7700: demonstrate mishandling of loose objects in an alternate ODB drafnel
[not found] ` <1226296798-31522-2-git-send-email-foo@foo.com>
2008-11-10 5:59 ` [PATCH 2/3] sha1_file.c: split has_loose_object() into local and non-local counterparts drafnel
[not found] ` <1226296798-31522-3-git-send-email-foo@foo.com>
2008-11-10 5:59 ` [PATCH 3/3] pack-objects: extend --local to mean ignore non-local loose objects too drafnel
2008-11-07 1:52 ` [PATCH 1/4] pack-objects: new option --honor-pack-keep Brandon Casey
2008-11-07 1:54 ` [PATCH 2/4] repack: don't repack local objects in packs with .keep file Brandon Casey
2008-11-07 1:55 ` [PATCH 3/4] repack: do not fall back to incremental repacking with [-a|-A] Brandon Casey
2008-11-07 1:56 ` [PATCH 4/4] builtin-gc.c: use new pack_keep bitfield to detect .keep file existence Brandon Casey
2008-11-07 8:14 ` [PATCH 2/4] repack: don't repack local objects in packs with .keep file Andreas Ericsson
2008-11-07 8:13 ` [PATCH 1/4] pack-objects: new option --honor-pack-keep Andreas Ericsson
2008-11-03 22:14 ` [PATCH v3] t7700: demonstrate mishandling of objects in packs with a .keep file Brandon Casey
2008-11-04 19:17 ` [PATCH v2 1/3] " Andreas Ericsson
2008-11-04 19:49 ` Brandon Casey
2008-11-04 19:55 ` Junio C Hamano
2008-11-04 20:01 ` Brandon Casey
2008-11-04 20:21 ` Andreas Ericsson
2008-11-04 23:55 ` Junio C Hamano
2008-11-12 8:09 ` Jeff King
2008-11-12 17:10 ` Junio C Hamano
2008-11-12 19:17 ` Jeff King
2008-11-12 17:30 ` Brandon Casey
2008-11-12 17:59 ` repack and .keep series Brandon Casey
2008-11-12 17:59 ` [PATCH 1/6] t7700: demonstrate mishandling of objects in packs with a .keep file Brandon Casey
2008-11-12 17:59 ` [PATCH 2/6] packed_git: convert pack_local flag into a bitfield and add pack_keep Brandon Casey
2008-11-12 17:59 ` [PATCH 3/6] pack-objects: new option --honor-pack-keep Brandon Casey
2008-11-12 17:59 ` [PATCH 4/6] repack: don't repack local objects in packs with .keep file Brandon Casey
2008-11-12 17:59 ` [PATCH 5/6] repack: do not fall back to incremental repacking with [-a|-A] Brandon Casey
2008-11-12 17:59 ` [PATCH 6/6] builtin-gc.c: use new pack_keep bitfield to detect .keep file existence Brandon Casey
2008-11-13 0:50 ` [PATCH] t7700: test that 'repack -a' packs alternate packed objects Brandon Casey
2008-11-12 18:10 ` [PATCH v2 1/3] t7700: demonstrate mishandling of objects in packs with a .keep file Junio C Hamano
2008-11-12 18:19 ` Junio C Hamano
[not found] ` <1225643477-32319-1-git-send-email-foo@foo.com>
2008-11-02 16:31 ` [PATCH 2/3] packed_git: add new PACK_KEEP flag and haspackkeep() access macro drafnel
[not found] ` <1225643477-32319-2-git-send-email-foo@foo.com>
2008-11-02 16:31 ` [PATCH 3/3] pack-objects: honor '.keep' files drafnel
2008-11-03 16:17 ` Shawn O. Pearce
2008-11-03 10:35 ` [PATCH] t7700: demonstrate mishandling of objects in packs with a .keep file Andreas Ericsson
2008-11-03 18:20 ` Brandon Casey
2008-11-03 20:25 ` Andreas Ericsson
2008-11-03 22:02 ` Brandon Casey
2008-11-04 19:25 ` Andreas Ericsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6141358.1225643400587.JavaMail.teamon@b303.teamon.com \
--to=drafnel@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=nico@cam.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).