diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-09-27 00:52:47 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-09-27 00:52:47 -0700 |
commit | a17ba31b0b75365e1245e494d46abae4afc57480 (patch) | |
tree | 41c1d800c92e60d97a8b984dce086bcb3473dcc2 /cache-tree.c | |
parent | 0f729f21348c43a1c80f48faed2e753b1c923e85 (diff) | |
parent | 6d69b6f6ac27ab6f71a10da34b813ca25fd2a358 (diff) | |
download | git-a17ba31b0b75365e1245e494d46abae4afc57480.tar.gz git-a17ba31b0b75365e1245e494d46abae4afc57480.tar.xz |
Merge branch 'ph/strbuf' into kh/commit
* ph/strbuf:
Clean up stripspace a bit, use strbuf even more.
Add strbuf_read_file().
rerere: Fix use of an empty strbuf.buf
Small cache_tree_write refactor.
Make builtin-rerere use of strbuf nicer and more efficient.
Add strbuf_cmp.
strbuf_setlen(): do not barf on setting length of an empty buffer to 0
sq_quote_argv and add_to_string rework with strbuf's.
Full rework of quote_c_style and write_name_quoted.
Rework unquote_c_style to work on a strbuf.
strbuf API additions and enhancements.
nfv?asprintf are broken without va_copy, workaround them.
Fix the expansion pattern of the pseudo-static path buffer.
Diffstat (limited to 'cache-tree.c')
-rw-r--r-- | cache-tree.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/cache-tree.c b/cache-tree.c index 5471844af..50b35264f 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) |