[PATCH] Fix test failure due to overly strict .git directory tests
[gitweb.git] / git-fetch-script
index b44cf3f5a5bf61788ae6dc384ed59841ddd1f517..ea097144f712f9ef1beb0531f1bf945db9485c3f 100755 (executable)
@@ -9,10 +9,19 @@ merge_store="$_remote_store"
 TMP_HEAD="$GIT_DIR/TMP_HEAD"
 
 case "$merge_repo" in
-http://*)
-       head=$(wget -q -O - "$merge_repo/$merge_head") || exit 1
+http://* | https://*)
+        if [ -n "$GIT_SSL_NO_VERIFY" ]; then
+            curl_extra_args="-k"
+        fi
+       _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' &&
+       _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" &&
+       head=$(curl -nsf $curl_extra_args "$merge_repo/$merge_head") &&
+       expr "$head" : "$_x40\$" >/dev/null || {
+               echo >&2 "Failed to fetch $merge_head from $merge_repo"
+               exit 1
+       }
        echo Fetching "$merge_head" using http
-       git-http-pull -v -a "$head" "$merge_repo/"
+       git-http-pull -v -a "$head" "$merge_repo/" || exit
        ;;
 rsync://*)
        rsync -L "$merge_repo/$merge_head" "$TMP_HEAD" || exit 1
@@ -22,6 +31,10 @@ rsync://*)
        ;;
 *)
        head=$(git-fetch-pack "$merge_repo" "$merge_head")
+       if h=`expr "$head" : '\([^ ][^ ]*\) '`
+       then
+           head=$h
+       fi
        ;;
 esac || exit 1