Browse Source

Merge branch 'jc/cache-tree' into next

* jc/cache-tree:
  fsck-objects: mark objects reachable from cache-tree
  cache-tree: replace a sscanf() by two strtol() calls
maint
Junio C Hamano 19 years ago
parent
commit
f5196dbb25
  1. 11
      cache-tree.c
  2. 2
      fsck-objects.c

11
cache-tree.c

@ -440,6 +440,8 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p) @@ -440,6 +440,8 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
{
const char *buf = *buffer;
unsigned long size = *size_p;
const char *cp;
char *ep;
struct cache_tree *it;
int i, subtree_nr;

@ -453,7 +455,14 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p) @@ -453,7 +455,14 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
goto free_return;
buf++; size--;
it = cache_tree();
if (sscanf(buf, "%d %d\n", &it->entry_count, &subtree_nr) != 2)

cp = buf;
it->entry_count = strtol(cp, &ep, 10);
if (cp == ep)
goto free_return;
cp = ep;
subtree_nr = strtol(cp, &ep, 10);
if (cp == ep)
goto free_return;
while (size && *buf && *buf != '\n') {
size--;

2
fsck-objects.c

@ -446,6 +446,8 @@ static int fsck_cache_tree(struct cache_tree *it) @@ -446,6 +446,8 @@ static int fsck_cache_tree(struct cache_tree *it)

if (0 <= it->entry_count) {
struct object *obj = parse_object(it->sha1);
mark_reachable(obj, REACHABLE);
obj->used = 1;
if (obj->type != tree_type)
err |= objerror(obj, "non-tree in cache-tree");
}

Loading…
Cancel
Save