git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] tar-tree: file/dirmode fix.

From
Junio C Hamano <junkio@cox.net>
Date
Mar 4, 2006, 05:35 UTC
Message-ID
<7vy7zqvkl2.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1141446331.3171.4.camel@mattlaptop>

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>
---
 tar-tree.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
815afaf1bd0ddf419231d2d9f129260ce1ddbecc
diff --git a/tar-tree.c b/tar-tree.c
index e85a1ed..e478e13 100644
--- a/tar-tree.c
+++ b/tar-tree.c
@@ -304,9 +304,11 @@ static void write_header(const unsigned 
 	}
 
 	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? */
@@ -391,7 +393,7 @@ int main(int argc, char **argv)
 		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;
-- 
1.2.4.gfe04
Previous: Junio C Hamano
Message 3 of 3 in “Producing tar file with 666/777 permissions”
  1. Matt McCutchenMar 4, 2006
  2. Junio C HamanoMar 4, 2006
  3. tar-tree: file/dirmode fix.Junio C Hamano, Mar 4, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.