summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cef661f)
raw | patch | inline | side by side (parent: cef661f)
author | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Fri, 22 Apr 2005 23:35:06 +0000 (16:35 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Fri, 22 Apr 2005 23:35:06 +0000 (16:35 -0700) |
This is preparation for moving parts of it into "tree.c" to be used
as a library function.
as a library function.
read-tree.c | patch | blob | history |
diff --git a/read-tree.c b/read-tree.c
index 8121e30671718737328f0ea3189ed7f69b31ce8b..345d576dcbb16874ebae0cb868c0b416d20f5a3d 100644 (file)
--- a/read-tree.c
+++ b/read-tree.c
return add_cache_entry(ce, 1);
}
-static int read_tree_recursive(void *buffer, const char *type,
- unsigned long size,
+static int read_tree_recursive(void *buffer, unsigned long size,
const char *base, int baselen)
{
- if (!buffer || strcmp(type, "tree"))
- return -1;
while (size) {
int len = strlen(buffer)+1;
unsigned char *sha1 = buffer + len;
unsigned long eltsize;
eltbuf = read_sha1_file(sha1, elttype, &eltsize);
- if (!eltbuf)
+ if (!eltbuf || strcmp(elttype, "tree"))
return -1;
memcpy(newbase, base, baselen);
memcpy(newbase + baselen, path, pathlen);
newbase[baselen + pathlen] = '/';
- retval = read_tree_recursive(eltbuf, elttype, eltsize,
+ retval = read_tree_recursive(eltbuf, eltsize,
newbase,
baselen + pathlen + 1);
free(eltbuf);
unsigned long size;
buffer = read_tree_with_tree_or_commit_sha1(sha1, &size, 0);
- return read_tree_recursive(buffer, "tree", size, base, baselen);
+ if (!buffer)
+ return -1;
+ return read_tree_recursive(buffer, size, base, baselen);
}
static char *lockfile_name;