git-archive: don't die when repository uses subprojects
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>
Lars Hjemli committed
May 11, 2007 at 18:55 UTC
02851e0b9ed840c2e6881dd56072eefc17c8b98b
2 files changed
+4
-4
archive-tar.c
+2
-2
@@ -166,7 +166,7 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
166
} else {
167
if (verbose)
168
fprintf(stderr, "%.*s\n", path->len, path->buf);
169
- if (S_ISDIR(mode)) {
169
+ if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
170
*header.typeflag = TYPEFLAG_DIR;
171
mode = (mode | 0777) & ~tar_umask;
172
} else if (S_ISLNK(mode)) {
@@ -278,7 +278,7 @@ static int write_tar_entry(const unsigned char *sha1,
278
memcpy(path.buf, base, baselen);
279
memcpy(path.buf + baselen, filename, filenamelen);
280
path.len = baselen + filenamelen;
281
- if (S_ISDIR(mode)) {
281
+ if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
282
strbuf_append_string(&path, "/");
283
buffer = NULL;
284
size = 0;
archive-zip.c
+2
-2
@@ -182,10 +182,10 @@ static int write_zip_entry(const unsigned char *sha1,
182
goto out;
183
}
184
185
- if (S_ISDIR(mode)) {
185
+ if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
186
method = 0;
187
attr2 = 16;
188
- result = READ_TREE_RECURSIVE;
188
+ result = (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
189
out = NULL;
190
uncompressed_size = 0;
191
compressed_size = 0;