summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d2eafb7)
raw | patch | inline | side by side (parent: d2eafb7)
author | Linus Torvalds <torvalds@osdl.org> | |
Sun, 28 May 2006 22:10:04 +0000 (15:10 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 29 May 2006 02:40:18 +0000 (19:40 -0700) |
This is preparatory work for further cleanups, where we try to make
tree_entry look more like the more efficient tree-walk descriptor.
Instead of having a union of pointers to blob/tree/objects, this just
makes "struct tree_entry" have the raw SHA1, and makes all the users use
that instead (often that implies adding a "lookup_tree(..)" on the sha1,
but sometimes the user just wanted the SHA1 in the first place, and it
just avoids an unnecessary indirection).
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
tree_entry look more like the more efficient tree-walk descriptor.
Instead of having a union of pointers to blob/tree/objects, this just
makes "struct tree_entry" have the raw SHA1, and makes all the users use
that instead (often that implies adding a "lookup_tree(..)" on the sha1,
but sometimes the user just wanted the SHA1 in the first place, and it
just avoids an unnecessary indirection).
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
blame.c | patch | blob | history | |
builtin-read-tree.c | patch | blob | history | |
builtin-rev-list.c | patch | blob | history | |
fsck-objects.c | patch | blob | history | |
http-push.c | patch | blob | history | |
object.c | patch | blob | history | |
revision.c | patch | blob | history | |
tree.c | patch | blob | history | |
tree.h | patch | blob | history |
index 99ceea81df7b7c69bc263cf170cbb23d88420613..88bfec262f741a80ee4aac6ef19d7cf359559464 100644 (file)
--- a/blame.c
+++ b/blame.c
free(p);
}
-static int get_blob_sha1_internal(unsigned char *sha1, const char *base,
+static int get_blob_sha1_internal(const unsigned char *sha1, const char *base,
int baselen, const char *pathname,
unsigned mode, int stage);
return 0;
}
-static int get_blob_sha1_internal(unsigned char *sha1, const char *base,
+static int get_blob_sha1_internal(const unsigned char *sha1, const char *base,
int baselen, const char *pathname,
unsigned mode, int stage)
{
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 740a8c7e66bc3f893a680f8e8f9ebfad42141508..f0b8dad6eb5c469b78f08c12aa0f62befbb54e80 100644 (file)
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
}
if (posns[i]->directory) {
+ struct tree *tree = lookup_tree(posns[i]->sha1);
any_dirs = 1;
- parse_tree(posns[i]->item.tree);
- subposns[i] = posns[i]->item.tree->entries;
+ parse_tree(tree);
+ subposns[i] = tree->entries;
posns[i] = posns[i]->next;
src[i + merge] = &df_conflict_entry;
continue;
any_files = 1;
- memcpy(ce->sha1, posns[i]->item.any->sha1, 20);
+ memcpy(ce->sha1, posns[i]->sha1, 20);
src[i + merge] = ce;
subposns[i] = &df_conflict_list;
posns[i] = posns[i]->next;
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 72c1549c701f24dc46eaf920fdcb73f822cf5cda..94f520b908402ffd6468cc15f894d7a9d56ebbf7 100644 (file)
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
while (entry) {
struct tree_entry_list *next = entry->next;
if (entry->directory)
- p = process_tree(entry->item.tree, p, &me, entry->name);
+ p = process_tree(lookup_tree(entry->sha1), p, &me, entry->name);
else
- p = process_blob(entry->item.blob, p, &me, entry->name);
+ p = process_blob(lookup_blob(entry->sha1), p, &me, entry->name);
free(entry);
entry = next;
}
diff --git a/fsck-objects.c b/fsck-objects.c
index a0290b09c9365434ae84d78ced8024dda6a40e3d..44b646540a84f1d4afe319376d81c495eb232503 100644 (file)
--- a/fsck-objects.c
+++ b/fsck-objects.c
{
int i, heads;
+ track_object_refs = 1;
setup_git_directory();
for (i = 1; i < argc; i++) {
diff --git a/http-push.c b/http-push.c
index b4327d92438d9596b7286ead06152ad3156b6e2c..f492a5d36678a996ff2c665cacc8cfc69eb10f6f 100644 (file)
--- a/http-push.c
+++ b/http-push.c
while (entry) {
struct tree_entry_list *next = entry->next;
if (entry->directory)
- p = process_tree(entry->item.tree, p, &me, entry->name);
+ p = process_tree(lookup_tree(entry->sha1), p, &me, entry->name);
else
- p = process_blob(entry->item.blob, p, &me, entry->name);
+ p = process_blob(lookup_blob(entry->sha1), p, &me, entry->name);
free(entry);
entry = next;
}
diff --git a/object.c b/object.c
index 1a7823c234406a418d360bf5ea322fe2321aec06..9adc87479bde2a0b2a0a0335aed12a9f485facff 100644 (file)
--- a/object.c
+++ b/object.c
static int nr_objs;
int obj_allocs;
-int track_object_refs = 1;
+int track_object_refs = 0;
static int hashtable_index(const unsigned char *sha1)
{
diff --git a/revision.c b/revision.c
index 42c077a4cbc74b99dac516a0d55110892c1a132f..8d70a6f77a56d4a413e77015258db136f6cb7410 100644 (file)
--- a/revision.c
+++ b/revision.c
while (entry) {
struct tree_entry_list *next = entry->next;
if (entry->directory)
- mark_tree_uninteresting(entry->item.tree);
+ mark_tree_uninteresting(lookup_tree(entry->sha1));
else
- mark_blob_uninteresting(entry->item.blob);
+ mark_blob_uninteresting(lookup_blob(entry->sha1));
free(entry);
entry = next;
}
index 1e76d9cc11dcbda655e40f19fbd82d34212383b2..88c22190307b2f86ef365af66ddcc71ba4cb2fb4 100644 (file)
--- a/tree.c
+++ b/tree.c
const char *tree_type = "tree";
-static int read_one_entry(unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage)
+static int read_one_entry(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage)
{
int len;
unsigned int size;
current->mode, match))
continue;
- switch (fn(current->item.any->sha1, base, baselen,
+ switch (fn(current->sha1, base, baselen,
current->name, current->mode, stage)) {
case 0:
continue;
memcpy(newbase, base, baselen);
memcpy(newbase + baselen, current->name, pathlen);
newbase[baselen + pathlen] = '/';
- retval = read_tree_recursive(current->item.tree,
+ retval = read_tree_recursive(lookup_tree(current->sha1),
newbase,
baselen + pathlen + 1,
stage, match, fn);
entry = xmalloc(sizeof(struct tree_entry_list));
entry->name = path;
+ entry->sha1 = sha1;
entry->mode = mode;
entry->directory = S_ISDIR(mode) != 0;
entry->executable = (mode & S_IXUSR) != 0;
entry->next = NULL;
update_tree_entry(&desc);
-
- if (entry->directory) {
- entry->item.tree = lookup_tree(sha1);
- } else {
- entry->item.blob = lookup_blob(sha1);
- }
n_refs++;
*list_p = entry;
list_p = &entry->next;
struct tree_entry_list *entry;
unsigned i = 0;
struct object_refs *refs = alloc_object_refs(n_refs);
- for (entry = item->entries; entry; entry = entry->next)
- refs->ref[i++] = entry->item.any;
+ for (entry = item->entries; entry; entry = entry->next) {
+ struct object *obj;
+
+ if (entry->directory)
+ obj = &lookup_tree(entry->sha1)->object;
+ else
+ obj = &lookup_blob(entry->sha1)->object;
+ refs->ref[i++] = obj;
+ }
+
set_object_refs(&item->object, refs);
}
index 066ac5d5bfa38ec8b61e4a8c9b1d75c1959eaa03..a27bae41ba48c7f04f7abda0bfce25587eb46ebe 100644 (file)
--- a/tree.h
+++ b/tree.h
unsigned zeropad : 1;
unsigned int mode;
const char *name;
- union {
- struct object *any;
- struct tree *tree;
- struct blob *blob;
- } item;
+ const unsigned char *sha1;
};
struct tree {
struct tree *parse_tree_indirect(const unsigned char *sha1);
#define READ_TREE_RECURSIVE 1
-typedef int (*read_tree_fn_t)(unsigned char *, const char *, int, const char *, unsigned int, int);
+typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int);
extern int read_tree_recursive(struct tree *tree,
const char *base, int baselen,