X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=archive-tar.c;h=56ff356966c002a0d0a86b1b0d88a3ae60718172;hb=af9b54bb2cb0e15780bf3e820b5f1ce399deb2c4;hp=af47fdc95572bfa67b9c67369222a69c32ddea02;hpb=e035ce939d7e26afee4936ed32f1db9428ac026e;p=git.git diff --git a/archive-tar.c b/archive-tar.c index af47fdc95..56ff35696 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -15,7 +15,7 @@ static char block[BLOCKSIZE]; static unsigned long offset; static time_t archive_time; -static int tar_umask; +static int tar_umask = 002; static int verbose; /* writes out the whole block, but only if it is full */ @@ -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)) { @@ -210,11 +210,10 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path, sprintf(header.size, "%011lo", S_ISREG(mode) ? size : 0); sprintf(header.mtime, "%011lo", archive_time); - /* XXX: should we provide more meaningful info here? */ sprintf(header.uid, "%07o", 0); sprintf(header.gid, "%07o", 0); - strlcpy(header.uname, "git", sizeof(header.uname)); - strlcpy(header.gname, "git", sizeof(header.gname)); + strlcpy(header.uname, "root", sizeof(header.uname)); + strlcpy(header.gname, "root", sizeof(header.gname)); sprintf(header.devmajor, "%07o", 0); sprintf(header.devminor, "%07o", 0); @@ -263,7 +262,7 @@ static int write_tar_entry(const unsigned char *sha1, static struct strbuf path; int filenamelen = strlen(filename); void *buffer; - char type[20]; + enum object_type type; unsigned long size; if (!path.alloc) { @@ -279,12 +278,12 @@ 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; } else { - buffer = read_sha1_file(sha1, type, &size); + buffer = read_sha1_file(sha1, &type, &size); if (!buffer) die("cannot read %s", sha1_to_hex(sha1)); }