Commits

Anonymous committed 473d404

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>

  • Participants
  • Parent commits 1142038

Comments (0)

Files changed (1)

 	}
 
 	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? */
 		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;