X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=contrib%2Fexamples%2Fgit-clone.sh;h=547228e13ce60e575d0b4a10a322edfff6c0622c;hb=1966af81760aea2966f8f218d442aed5f296b992;hp=8c7fc7f6317113fcef923dcc625fb94e13fb77a0;hpb=8434c2f1afedb936e0ea8c07ce25733013c2f743;p=git.git diff --git a/contrib/examples/git-clone.sh b/contrib/examples/git-clone.sh index 8c7fc7f63..547228e13 100755 --- a/contrib/examples/git-clone.sh +++ b/contrib/examples/git-clone.sh @@ -240,7 +240,6 @@ die "working tree '$GIT_WORK_TREE' already exists." D= W= cleanup() { - err=$? test -z "$D" && rm -rf "$dir" test -z "$W" && test -n "$GIT_WORK_TREE" && rm -rf "$GIT_WORK_TREE" cd .. @@ -248,7 +247,7 @@ cleanup() { test -n "$W" && rm -rf "$W" exit $err } -trap cleanup 0 +trap 'err=$?; cleanup' 0 mkdir -p "$dir" && D=$(cd "$dir" && pwd) || usage test -n "$GIT_WORK_TREE" && mkdir -p "$GIT_WORK_TREE" && W=$(cd "$GIT_WORK_TREE" && pwd) && GIT_WORK_TREE="$W" && export GIT_WORK_TREE @@ -334,7 +333,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 existing 0444 permissions on content + find objects ! -type d -print | cpio $cpio_quiet_flag -pumd$l "$GIT_DIR/" || \ exit 1 fi git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1