}
if (S_ISDIR(mode))
- mode |= 0755; /* GIT doesn't store permissions of dirs */
- if (S_ISLNK(mode))
- mode |= 0777; /* ... nor of symlinks */
+ mode |= 0777;
+ else if (S_ISREG(mode))
+ mode |= (mode & 0100) ? 0777 : 0666;
+ else if (S_ISLNK(mode))
+ mode |= 0777;
sprintf(&header[100], "%07o", mode & 07777);
/* XXX: should we provide more meaningful info here? */
int main(int argc, char **argv)
{
- unsigned char sha1[20];
+ unsigned char sha1[20], tree_sha1[20];
struct commit *commit;
struct tree_desc tree;
usage(tar_tree_usage);
}
- commit = lookup_commit_reference(sha1);
+ commit = lookup_commit_reference_gently(sha1, 1);
if (commit) {
write_global_extended_header(commit->object.sha1);
archive_time = commit->date;
}
- tree.buf = read_object_with_reference(sha1, "tree", &tree.size, NULL);
+ tree.buf = read_object_with_reference(sha1, "tree", &tree.size,
+ tree_sha1);
if (!tree.buf)
die("not a reference to a tag, commit or tree object: %s",
sha1_to_hex(sha1));
if (!archive_time)
archive_time = time(NULL);
if (basedir)
- write_header((unsigned char *)"0", TYPEFLAG_DIR, NULL, NULL,
+ write_header(tree_sha1, TYPEFLAG_DIR, NULL, NULL,
basedir, 040777, NULL, 0);
traverse_tree(&tree, NULL);
write_trailer();