From ac7fa2776c4a839a5a96c13886714774b52844de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Wed, 9 Apr 2008 23:14:43 +0200 Subject: git-archive: ignore prefix when checking file attribute Ulrik Sverdrup noticed that git-archive doesn't correctly apply the attribute export-subst when the option --prefix is given, too. When it checked if a file has the attribute turned on, git-archive would try to look up the full path -- including the prefix -- in .gitattributes. That's wrong, as the prefix doesn't need to have any relation to any existing directories, tracked or not. This patch makes git-archive ignore the prefix when looking up if value of the attribute export-subst for a file. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- archive-zip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'archive-zip.c') diff --git a/archive-zip.c b/archive-zip.c index 74e30f620..18c0f8710 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -13,6 +13,7 @@ static int verbose; static int zip_date; static int zip_time; static const struct commit *commit; +static size_t base_len; static unsigned char *zip_dir; static unsigned int zip_dir_size; @@ -197,8 +198,8 @@ static int write_zip_entry(const unsigned char *sha1, if (S_ISREG(mode) && zlib_compression_level != 0) method = 8; result = 0; - buffer = sha1_file_to_archive(path, sha1, mode, &type, &size, - commit); + buffer = sha1_file_to_archive(path + base_len, sha1, mode, + &type, &size, commit); if (!buffer) die("cannot read %s", sha1_to_hex(sha1)); crc = crc32(crc, buffer, size); @@ -321,6 +322,7 @@ int write_zip_archive(struct archiver_args *args) zip_dir_size = ZIP_DIRECTORY_MIN_SIZE; verbose = args->verbose; commit = args->commit; + base_len = args->base ? strlen(args->base) : 0; if (args->base && plen > 0 && args->base[plen - 1] == '/') { char *base = xstrdup(args->base); -- cgit v1.2.1