summaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2007-09-25 08:22:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-09-26 09:27:06 (GMT)
commit1dffb8fa8056860e769f3a0c6e232d436f5a5c17 (patch)
tree51ac48c04be22c1af391fc1ec3bbdecc751bd0ff /cache-tree.c
parent8289b6209552a57c255561a2585d0edbe96d62d3 (diff)
downloadgit-1dffb8fa8056860e769f3a0c6e232d436f5a5c17.zip
git-1dffb8fa8056860e769f3a0c6e232d436f5a5c17.tar.gz
git-1dffb8fa8056860e769f3a0c6e232d436f5a5c17.tar.bz2
Small cache_tree_write refactor.
This function cannot fail, make it void. Also make write_one act on a const char* instead of a char*. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache-tree.c')
-rw-r--r--cache-tree.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/cache-tree.c b/cache-tree.c
index 5471844..50b3526 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -369,10 +369,8 @@ int cache_tree_update(struct cache_tree *it,
return 0;
}
-static void write_one(struct cache_tree *it,
- char *path,
- int pathlen,
- struct strbuf *buffer)
+static void write_one(struct strbuf *buffer, struct cache_tree *it,
+ const char *path, int pathlen)
{
int i;
@@ -407,20 +405,13 @@ static void write_one(struct cache_tree *it,
prev->name, prev->namelen) <= 0)
die("fatal - unsorted cache subtree");
}
- write_one(down->cache_tree, down->name, down->namelen, buffer);
+ write_one(buffer, down->cache_tree, down->name, down->namelen);
}
}
-void *cache_tree_write(struct cache_tree *root, unsigned long *size_p)
+void cache_tree_write(struct strbuf *sb, struct cache_tree *root)
{
- char path[PATH_MAX];
- struct strbuf buffer;
-
- path[0] = 0;
- strbuf_init(&buffer, 0);
- write_one(root, path, 0, &buffer);
- *size_p = buffer.len;
- return strbuf_detach(&buffer);
+ write_one(sb, root, "", 0);
}
static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)