From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 3/3] object: reclaim one bit in the flags field
Date: Mon, 27 Jun 2011 10:50:59 -0700 [thread overview]
Message-ID: <1309197059-7177-3-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1309197059-7177-1-git-send-email-gitster@pobox.com>
The object layer has "used" bit in the structure that is only used while
running fsck. Remove it, and instead use one bit from the flags to record
the fact that an object is referenced from some other object (only during
fsck).
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/fsck.c | 7 ++++---
object.c | 1 -
object.h | 3 +--
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 90f5c2c..dde0907 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -14,6 +14,7 @@
#define REACHABLE 0x0001
#define SEEN 0x0002
+#define USED 0x0004
static int show_root;
static int show_tags;
@@ -114,7 +115,7 @@ static int mark_object(struct object *obj, int type, void *data)
static void mark_object_reachable(struct object *obj)
{
if (obj) {
- obj->used = 1;
+ obj->flags |= USED;
mark_object(obj, OBJ_ANY, NULL);
}
}
@@ -156,7 +157,7 @@ static int mark_used(struct object *obj, int type, void *data)
{
if (!obj)
return 1;
- obj->used = 1;
+ obj->flags |= USED;
return 0;
}
@@ -214,7 +215,7 @@ static void check_unreachable_object(struct object *obj)
* deleted a branch by mistake, this is a prime candidate to
* start looking at, for example.
*/
- if (!obj->used) {
+ if (!(obj->flags & USED)) {
printf("dangling %s %s\n", typename(obj->type),
sha1_to_hex(obj->sha1));
if (write_lost_and_found) {
diff --git a/object.c b/object.c
index 31976b5..4a9d77f 100644
--- a/object.c
+++ b/object.c
@@ -111,7 +111,6 @@ void *create_object(const unsigned char *sha1, int type, void *o)
struct object *obj = o;
obj->parsed = 0;
- obj->used = 0;
obj->type = type;
obj->flags = 0;
hashcpy(obj->sha1, sha1);
diff --git a/object.h b/object.h
index b6618d9..dbfc88f 100644
--- a/object.h
+++ b/object.h
@@ -19,14 +19,13 @@ struct object_array {
#define OBJECT_ARRAY_INIT { 0, 0, NULL }
#define TYPE_BITS 3
-#define FLAG_BITS 27
+#define FLAG_BITS (31-TYPE_BITS)
/*
* The object type is stored in 3 bits.
*/
struct object {
unsigned parsed : 1;
- unsigned used : 1;
unsigned type : TYPE_BITS;
unsigned flags : FLAG_BITS;
unsigned char sha1[20];
--
1.7.6
prev parent reply other threads:[~2011-06-27 17:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-27 17:50 [PATCH 1/3] fsck: minor typofix Junio C Hamano
2011-06-27 17:50 ` [PATCH 2/3] fsck: clarify semantics of mark_object_reachable() Junio C Hamano
2011-06-27 17:50 ` Junio C Hamano [this message]
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=1309197059-7177-3-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.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).