From ebfbdb340ad9a1b6fbaf91464f0fd86643fdcb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Thu, 8 Oct 2009 18:46:54 +0200 Subject: Git archive and trailing "/" in prefix With --prefix=string that does not end with a slash, the top-level entries are written out with the specified prefix as expected, but no paths in the directories are added. Fix this by adding the prefix in write_archive_entry() instead of letting get_pathspec() and read_tree_recursive() pair; they are designed to only handle prefixes that are path components. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- archive.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'archive.c') diff --git a/archive.c b/archive.c index 0bca9ca40..57ac65e5c 100644 --- a/archive.c +++ b/archive.c @@ -115,6 +115,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base, strbuf_reset(&path); strbuf_grow(&path, PATH_MAX); + strbuf_add(&path, args->base, args->baselen); strbuf_add(&path, base, baselen); strbuf_addstr(&path, filename); path_without_prefix = path.buf + args->baselen; @@ -187,8 +188,8 @@ int write_archive_entries(struct archiver_args *args, git_attr_set_direction(GIT_ATTR_INDEX, &the_index); } - err = read_tree_recursive(args->tree, args->base, args->baselen, 0, - args->pathspec, write_archive_entry, &context); + err = read_tree_recursive(args->tree, "", 0, 0, args->pathspec, + write_archive_entry, &context); if (err == READ_TREE_RECURSIVE) err = 0; return err; @@ -211,7 +212,7 @@ static const struct archiver *lookup_archiver(const char *name) static void parse_pathspec_arg(const char **pathspec, struct archiver_args *ar_args) { - ar_args->pathspec = get_pathspec(ar_args->base, pathspec); + ar_args->pathspec = get_pathspec("", pathspec); } static void parse_treeish_arg(const char **argv, -- cgit v1.2.1