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

Re: git-clone file permissions and cpio

From
MHMark Hills <mark@pogo.org.uk>
Date
May 4, 2008, 11:32 UTC
Message-ID
<alpine.BSO.1.10.0805041227550.5819@zrgural.vwaro.pbz>
In-Reply-To
<480C7D82.9000602@gnu.org>
On Mon, 21 Apr 2008, Paolo Bonzini wrote:
Show 8 quoted lines
>> I got some kind of working behaviour with the diff below, which stops 
>> cpio 'fixing' the file permissions (only on the directories). But it 
>> seems the underlying cause is cpio trying to copy file permissions 
>> which it would be better off not doing in this case (and which there 
>> isn't a flag to disable).
>
> I don't think you want to have the setgid bit on files, only on 
> directories, so your patch seems okay to me.

I'm spent some time investigating this, as the patch has different behaviour with different version of cpio because of various bugs [1].

I looked at various other ways of achieving the copy of the directory including variations on cpio, tar, pax, rsync and decided it was best to explicitly divide this into two steps: create the directories honouring umask and setgid etc. at the destination, and then copy the files over with read-only permissions using the existing method.

I'll send a [PATCH] mail with this new diff, although I can see this might be superceded by a built in clone in the future.

Mark
[1] http://www.gnu.org/software/cpio/
diff --git a/git-clone.sh b/git-clone.sh
index 8c7fc7f..53c7e06 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -334,7 +334,10 @@ yes)
  			fi
  		fi &&
  		cd "$repo" &&
-		find objects -depth -print | cpio $cpio_quiet_flag -pumd$l "$GIT_DIR/" || \
+		# Create dirs using umask and permissions and destination
+		find objects -type d -print | (cd "$GIT_DIR" && xargs mkdir -p) &&
+		# Copy 0444 permissions on files
+		find objects -type f -print | cpio $cpio_quiet_flag -pumd$l "$GIT_DIR/" || \
  			exit 1
  	fi
  	git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1
Previous: Paolo Bonzini
Message 3 of 3 in “git-clone file permissions and cpio”
  1. Mark HillsApr 21, 2008
  2. Paolo BonziniApr 21, 2008
  3. Mark HillsMay 4, 2008

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.