From: Junio C Hamano Date: Mon, 29 May 2006 05:47:53 +0000 (-0700) Subject: Merge branch 'lt/tree' into jc/lt-tree-n-cache-tree X-Git-Tag: v1.4.0-rc1~10^2~2^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0a2586c807fadc4b13a741e693471765870f6bb4;p=thirdparty%2Fgit.git Merge branch 'lt/tree' into jc/lt-tree-n-cache-tree * lt/tree: (98 commits) Remove "tree->entries" tree-entry list from tree parser Switch "read_tree_recursive()" over to tree-walk functionality Make "tree_entry" have a SHA1 instead of a union of object pointers Add raw tree buffer info to "struct tree" Don't use "sscanf()" for tree mode scanning git-fetch: avoid using "case ... in (arm)" mailinfo: skip bogus UNIX From line inside body mailinfo: More carefully parse header lines in read_one_header_line() Allow in body headers beyond the in body header prefix. More accurately detect header lines in read_one_header_line In handle_body only read a line if we don't already have one. Refactor commit messge handling. Move B and Q decoding into check header. Make read_one_header_line return a flag not a length. Fix memory leak in "git rev-list --objects" gitview: Move the console error messages to message dialog gitview: Add key binding for F5. Let git-clone to pass --template=dir option to git-init-db. Make cvsexportcommit create parent directories as needed. Document current cvsexportcommit limitations. ... Conflicts: Makefile, builtin.h, git.c are trivially resolved. builtin-read-tree.c needed adjustment for the tree parser change. --- 0a2586c807fadc4b13a741e693471765870f6bb4 diff --cc builtin-read-tree.c index 99e7c75044,da0731ca0e..b93178a4ba --- a/builtin-read-tree.c +++ b/builtin-read-tree.c @@@ -9,9 -9,9 +9,11 @@@ #include "object.h" #include "tree.h" +#include "cache-tree.h" ++#include "tree-walk.h" #include #include + #include "builtin.h" static int reset = 0; static int merge = 0; @@@ -771,39 -761,6 +774,51 @@@ static int read_cache_unmerged(void return deleted; } +static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree) +{ - struct tree_entry_list *ent; - int cnt; ++ struct tree_desc desc; ++ int cnt = 0; + + memcpy(it->sha1, tree->object.sha1, 20); - for (cnt = 0, ent = tree->entries; ent; ent = ent->next) { - if (!ent->directory) ++ desc.buf = tree->buffer; ++ desc.size = tree->size; ++ ++ while (desc.size) { ++ unsigned mode; ++ const char *name; ++ const unsigned char *sha1; ++ ++ sha1 = tree_entry_extract(&desc, &name, &mode); ++ update_tree_entry(&desc); ++ ++ if (!S_ISDIR(mode)) + cnt++; + else { + struct cache_tree_sub *sub; - struct tree *subtree = (struct tree *)ent->item.tree; ++ struct tree *subtree; ++ ++ subtree = lookup_tree(sha1); + if (!subtree->object.parsed) + parse_tree(subtree); - sub = cache_tree_sub(it, ent->name); ++ sub = cache_tree_sub(it, name); + sub->cache_tree = cache_tree(); + prime_cache_tree_rec(sub->cache_tree, subtree); + cnt += sub->cache_tree->entry_count; + } + } + it->entry_count = cnt; +} + +static void prime_cache_tree(void) +{ + struct tree *tree = (struct tree *)trees->item; + if (!tree) + return; + active_cache_tree = cache_tree(); + prime_cache_tree_rec(active_cache_tree, tree); + +} + static const char read_tree_usage[] = "git-read-tree ( | -m [--aggressive] [-u | -i] [ []])"; static struct cache_file cache_file; diff --cc fsck-objects.c index 1922b6d84c,ec99a7a6cb..42778e87d0 --- a/fsck-objects.c +++ b/fsck-objects.c @@@ -8,9 -8,9 +8,10 @@@ #include "tag.h" #include "refs.h" #include "pack.h" +#include "cache-tree.h" #define REACHABLE 0x0001 + #define SEEN 0x0002 static int show_root = 0; static int show_tags = 0;