summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-10-09 16:27:16 -0700
committerJunio C Hamano <gitster@pobox.com>2009-10-09 16:27:16 -0700
commita17a9606e49dd3ad08558706f85475a694deb68b (patch)
treed7eb85719d36f9b6d09808d535d0d886ccc1a720
parente12bfd86c1939be056fcf65e13359bea2e820d01 (diff)
parentebfbdb340ad9a1b6fbaf91464f0fd86643fdcb46 (diff)
downloadgit-a17a9606e49dd3ad08558706f85475a694deb68b.tar.gz
Merge branch 'rs/maint-archive-prefix'
* rs/maint-archive-prefix: Git archive and trailing "/" in prefix
-rw-r--r--archive.c7
-rwxr-xr-xt/t5000-tar-tree.sh12
2 files changed, 16 insertions, 3 deletions
diff --git a/archive.c b/archive.c
index 73b8e8a56d..0cc79d2a24 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,
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 5f84b18fa5..0037f63d91 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -230,4 +230,16 @@ test_expect_success \
'git archive --list outside of a git repo' \
'GIT_DIR=some/non-existing/directory git archive --list'
+test_expect_success 'git-archive --prefix=olde-' '
+ git archive --prefix=olde- >h.tar HEAD &&
+ (
+ mkdir h &&
+ cd h &&
+ "$TAR" xf - <../h.tar
+ ) &&
+ test -d h/olde-a &&
+ test -d h/olde-a/bin &&
+ test -f h/olde-a/bin/sh
+'
+
test_done