Ensure we add directories in the correct order
[gitweb.git] / git-clone.sh
index 4c9b1c9710c0fd55dfdbaf6bec6b77e0dae93562..5e582fe247892fa7dffc44556c939863c36edc35 100755 (executable)
@@ -34,7 +34,11 @@ fi
 
 http_fetch () {
        # $1 = Remote, $2 = Local
-       curl -nsfL $curl_extra_args "$1" >"$2"
+       curl -nsfL $curl_extra_args "$1" >"$2" ||
+               case $? in
+               126|127) exit ;;
+               *)       return $? ;;
+               esac
 }
 
 clone_dumb_http () {
@@ -99,6 +103,7 @@ origin_override=
 use_separate_remote=t
 depth=
 no_progress=
+local_explicitly_asked_for=
 test -t 1 || no_progress=--no-progress
 while
        case "$#,$1" in
@@ -109,6 +114,7 @@ while
        *,--na|*,--nak|*,--nake|*,--naked|\
        *,-b|*,--b|*,--ba|*,--bar|*,--bare) bare=yes ;;
        *,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local)
+         local_explicitly_asked_for=yes
          use_local_hardlink=yes ;;
        *,--no-h|*,--no-ha|*,--no-har|*,--no-hard|*,--no-hardl|\
        *,--no-hardli|*,--no-hardlin|*,--no-hardlink|*,--no-hardlinks)
@@ -215,7 +221,12 @@ else
        GIT_DIR="$D/.git"
 fi &&
 export GIT_DIR &&
-git-init $quiet ${template+"$template"} || usage
+GIT_CONFIG="$GIT_DIR/config" git-init $quiet ${template+"$template"} || usage
+
+if test -n "$bare"
+then
+       GIT_CONFIG="$GIT_DIR/config" git config core.bare true
+fi
 
 if test -n "$reference"
 then
@@ -276,7 +287,8 @@ yes)
                        then
                                rm -f "$GIT_DIR/objects/sample"
                                l=l
-                       else
+                       elif test -n "$local_explicitly_asked_for"
+                       then
                                echo >&2 "Warning: -l asked but cannot hardlink to $repo"
                        fi
                fi &&