GIT 1.1.5
[gitweb.git] / tar-tree.c
index 2716ae3eb1430abfc43d980d904fc192f8dcbbf4..f749d4b869ff9cf97506bc8eb3d401ec8b8ff9e3 100644 (file)
@@ -34,10 +34,8 @@ struct path_prefix {
 static void reliable_write(void *buf, unsigned long size)
 {
        while (size > 0) {
-               long ret = write(1, buf, size);
+               long ret = xwrite(1, buf, size);
                if (ret < 0) {
-                       if (errno == EAGAIN)
-                               continue;
                        if (errno == EPIPE)
                                exit(0);
                        die("git-tar-tree: %s", strerror(errno));
@@ -353,6 +351,8 @@ static void traverse_tree(void *buffer, unsigned long size,
 
                if (size < namelen + 20 || sscanf(buffer, "%o", &mode) != 1)
                        die("corrupt 'tree' file");
+               if (S_ISDIR(mode) || S_ISREG(mode))
+                       mode |= (mode & 0100) ? 0777 : 0666;
                buffer = sha1 + 20;
                size -= namelen + 20;
 
@@ -405,6 +405,8 @@ int main(int argc, char **argv)
        void *buffer;
        unsigned long size;
 
+       setup_git_directory();
+
        switch (argc) {
        case 3:
                basedir = argv[2];
@@ -431,7 +433,7 @@ int main(int argc, char **argv)
                archive_time = time(NULL);
        if (basedir)
                write_header((unsigned char *)"0", TYPEFLAG_DIR, NULL, NULL,
-                       basedir, 040755, NULL, 0);
+                       basedir, 040777, NULL, 0);
        traverse_tree(buffer, size, NULL);
        free(buffer);
        write_trailer();