Skip to content

Commit c904bf3

Browse files
Mark Hillsgitster
authored andcommitted
Be more careful with objects directory permissions on clone
Honour the setgid and umask when re-creating the objects directory at the destination. cpio in copy-pass mode aims to copy file permissions which causes this problem and cannot be disabled. Be explicit by copying the directory structure first, honouring the permissions at the destination, then copy the files with 0444 permissions. This also avoids bugs in some versions of cpio. Signed-off-by: Mark Hills <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 867fa20 commit c904bf3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

git-clone.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,10 @@ yes)
334334
fi
335335
fi &&
336336
cd "$repo" &&
337-
find objects -depth -print | cpio $cpio_quiet_flag -pumd$l "$GIT_DIR/" || \
337+
# Create dirs using umask and permissions and destination
338+
find objects -type d -print | (cd "$GIT_DIR" && xargs mkdir -p) &&
339+
# Copy existing 0444 permissions on content
340+
find objects ! -type d -print | cpio $cpio_quiet_flag -pumd$l "$GIT_DIR/" || \
338341
exit 1
339342
fi
340343
git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1

0 commit comments

Comments
 (0)