@matheusbsbs / matheus-bagliano / commits / 473d404b53
Fork 0

tar-tree: file/dirmode fix.

This fixes two bugs introduced when we switched to generic tree traversal code. (1) directory mode recorded silently became 0755, not 0777 (2) if passed a tree object (not a commit), it emitted an alarming error message (but proceeded anyway). Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Mar 3, 2006 at 21:34 UTC 473d404b53488a17458beea81913c1bc5df47a8a
1 file changed +6 -4
tar-tree.c
+6 -4
@@ -304,9 +304,11 @@ static void write_header(const unsigned char *sha1, char typeflag, const char *b
304 }
305
306 if (S_ISDIR(mode))
307 - mode |= 0755; /* GIT doesn't store permissions of dirs */
308 - if (S_ISLNK(mode))
309 - mode |= 0777; /* ... nor of symlinks */
307 + mode |= 0777;
308 + else if (S_ISREG(mode))
309 + mode |= (mode & 0100) ? 0777 : 0666;
310 + else if (S_ISLNK(mode))
311 + mode |= 0777;
312 sprintf(&header[100], "%07o", mode & 07777);
313
314 /* XXX: should we provide more meaningful info here? */
@@ -391,7 +393,7 @@ int main(int argc, char **argv)
393 usage(tar_tree_usage);
394 }
395
394 - commit = lookup_commit_reference(sha1);
396 + commit = lookup_commit_reference_gently(sha1, 1);
397 if (commit) {
398 write_global_extended_header(commit->object.sha1);
399 archive_time = commit->date;