summaryrefslogtreecommitdiff
path: root/builtin/merge-tree.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-07-31 04:38:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-08-01 20:06:52 (GMT)
commitc43ab062598d0299ea6e0d115a6018189a7793bf (patch)
tree03abcb873feb9ab6d23d51f9e7f45d1c2b14af26 /builtin/merge-tree.c
parentb3b3cbcbf246b1051ad453bc02e24a89573e2911 (diff)
downloadgit-c43ab062598d0299ea6e0d115a6018189a7793bf.zip
git-c43ab062598d0299ea6e0d115a6018189a7793bf.tar.gz
git-c43ab062598d0299ea6e0d115a6018189a7793bf.tar.bz2
tree-walk: add a strbuf wrapper for make_traverse_path()
All but one of the callers of make_traverse_path() allocate a new heap buffer to store the path. Let's give them an easy way to write to a strbuf, which saves them from computing the length themselves (which is especially tricky when they want to add to the path). It will also make it easier for us to change the make_traverse_path() interface in a future patch to improve its bounds-checking. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge-tree.c')
-rw-r--r--builtin/merge-tree.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 0629c87..87d949c 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -180,8 +180,9 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru
static char *traverse_path(const struct traverse_info *info, const struct name_entry *n)
{
- char *path = xmallocz(traverse_path_len(info, tree_entry_len(n)));
- return make_traverse_path(path, info, n->path, n->pathlen);
+ struct strbuf buf = STRBUF_INIT;
+ strbuf_make_traverse_path(&buf, info, n->path, n->pathlen);
+ return strbuf_detach(&buf, NULL);
}
static void resolve(const struct traverse_info *info, struct name_entry *ours, struct name_entry *result)