Skip to content

Commit 02851e0

Browse files
hjemliJunio C Hamano
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2206537 commit 02851e0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

archive-tar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
166166
} else {
167167
if (verbose)
168168
fprintf(stderr, "%.*s\n", path->len, path->buf);
169-
if (S_ISDIR(mode)) {
169+
if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
170170
*header.typeflag = TYPEFLAG_DIR;
171171
mode = (mode | 0777) & ~tar_umask;
172172
} else if (S_ISLNK(mode)) {
@@ -278,7 +278,7 @@ static int write_tar_entry(const unsigned char *sha1,
278278
memcpy(path.buf, base, baselen);
279279
memcpy(path.buf + baselen, filename, filenamelen);
280280
path.len = baselen + filenamelen;
281-
if (S_ISDIR(mode)) {
281+
if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
282282
strbuf_append_string(&path, "/");
283283
buffer = NULL;
284284
size = 0;

archive-zip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ static int write_zip_entry(const unsigned char *sha1,
182182
goto out;
183183
}
184184

185-
if (S_ISDIR(mode)) {
185+
if (S_ISDIR(mode) || S_ISDIRLNK(mode)) {
186186
method = 0;
187187
attr2 = 16;
188-
result = READ_TREE_RECURSIVE;
188+
result = (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
189189
out = NULL;
190190
uncompressed_size = 0;
191191
compressed_size = 0;

0 commit comments

Comments
 (0)