git-archive: don't die when repository uses subprojects
authorLars Hjemli <hjemli@gmail.com>
Fri, 11 May 2007 16:55:21 +0000 (18:55 +0200)
committerJunio C Hamano <junkio@cox.net>
Sat, 12 May 2007 16:35:07 +0000 (09:35 -0700)
Both archive-tar and archive-zip needed to be taught about subprojects.
The tar function died when trying to read the subproject commit object,
while the zip function reported "unsupported file mode".

This fixes both by representing the subproject as an empty directory.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
archive-tar.c
archive-zip.c

index d9c30d33dc286fa2926c80f647304687ba13295b..56ff356966c002a0d0a86b1b0d88a3ae60718172 100644 (file)
@@ -166,7 +166,7 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
        } else {
                if (verbose)
                        fprintf(stderr, "%.*s\n", path->len, path->buf);
-               if (S_ISDIR(mode)) {
+               if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
                        *header.typeflag = TYPEFLAG_DIR;
                        mode = (mode | 0777) & ~tar_umask;
                } else if (S_ISLNK(mode)) {
@@ -278,7 +278,7 @@ static int write_tar_entry(const unsigned char *sha1,
        memcpy(path.buf, base, baselen);
        memcpy(path.buf + baselen, filename, filenamelen);
        path.len = baselen + filenamelen;
-       if (S_ISDIR(mode)) {
+       if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
                strbuf_append_string(&path, "/");
                buffer = NULL;
                size = 0;
index 7c4984886f14aaba5d6a71c3b9213934b45d713a..1eaf262b7410e08f529ac48b9d56a131ba2a3ab3 100644 (file)
@@ -182,10 +182,10 @@ static int write_zip_entry(const unsigned char *sha1,
                goto out;
        }
 
-       if (S_ISDIR(mode)) {
+       if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
                method = 0;
                attr2 = 16;
-               result = READ_TREE_RECURSIVE;
+               result = (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
                out = NULL;
                uncompressed_size = 0;
                compressed_size = 0;