# [PATCH] git-clone: Error meaningfully on failed HTTP fetches of HEAD

4 messages from 2007-04-11 to 2007-04-12. Participants: Martin Langhoff, Junio C Hamano.
Thread: https://gitlist.dev/t/7616

## Martin Langhoff, 2007-04-11 22:05

Subject: [PATCH] git-clone: Error meaningfully on failed HTTP fetches of HEAD
Message-ID: <11763291192402-git-send-email-martin@catalyst.net.nz>
URL: https://gitlist.dev/e/11763291192402-git-send-email-martin%40catalyst.net.nz

```
A common problem when cloning over http is that the repo has
a symlink for HEAD, and apache refuses to serve symlinks by
default.

Without this patch, the clone succeeds as a "bare" and "HEADless"
clone, but does not give any indication that things have gone
wrong.

A bare clone that fails to fetch HEAD will still complete
"successfully". I'm not sure if that's expected/desired. Is a
HEADless repo valid in any situation?

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
---
 git-clone.sh |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index 513b574..ef8cd26 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -65,6 +65,11 @@ Perhaps git-update-server-info needs to be run there?"
 	rm -fr "$clone_tmp"
 	http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" ||
 	rm -f "$GIT_DIR/REMOTE_HEAD"
+
+	if test -z "$bare" && test ! -f "$GIT_DIR/REMOTE_HEAD"
+	then
+		die "Could not retrieve $1/HEAD - perhaps it is a symlink?"
+	fi
 }
 
 quiet=
-- 
1.5.1.106.ga32037

```

## Junio C Hamano, 2007-04-12 00:24

Subject: Re: [PATCH] git-clone: Error meaningfully on failed HTTP fetches of HEAD
Message-ID: <7vwt0imoc3.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vwt0imoc3.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <11763291192402-git-send-email-martin@catalyst.net.nz>

```
Martin Langhoff <martin@catalyst.net.nz> writes:

> A common problem when cloning over http is that the repo has
> a symlink for HEAD, and apache refuses to serve symlinks by
> default.
>
> Without this patch, the clone succeeds as a "bare" and "HEADless"
> clone, but does not give any indication that things have gone
> wrong.
>
> A bare clone that fails to fetch HEAD will still complete
> "successfully". I'm not sure if that's expected/desired. Is a
> HEADless repo valid in any situation?

You would get "fatal: Not a git repository".  Why not default to
'master' (if found) and issue a warning?

```

## Martin Langhoff, 2007-04-12 00:28

Subject: Re: [PATCH] git-clone: Error meaningfully on failed HTTP fetches of HEAD
Message-ID: <461D7D36.4000407@catalyst.net.nz>
URL: https://gitlist.dev/e/461D7D36.4000407%40catalyst.net.nz
In-Reply-To: <7vwt0imoc3.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:
>> A bare clone that fails to fetch HEAD will still complete
>> "successfully". I'm not sure if that's expected/desired. Is a
>> HEADless repo valid in any situation?
> 
> You would get "fatal: Not a git repository".  Why not default to
> 'master' (if found) and issue a warning?

And if not found die() for real...? Ok. I'll rework and resend.

cheers,



m
-- 
-----------------------------------------------------------------------
Martin @ Catalyst .Net .NZ  Ltd, PO Box 11-053, Manners St,  Wellington
WEB: http://catalyst.net.nz/           PHYS: Level 2, 150-154 Willis St
OFFICE: +64(4)916-7224  UK: 0845 868 5733 ext 7224  MOB: +64(21)364-017
      Make things as simple as possible, but no simpler - Einstein
-----------------------------------------------------------------------

```

## Junio C Hamano, 2007-04-12 00:38

Subject: Re: [PATCH] git-clone: Error meaningfully on failed HTTP fetches of HEAD
Message-ID: <7vk5wimnpo.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vk5wimnpo.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <461D7D36.4000407@catalyst.net.nz>

```
Martin Langhoff <martin@catalyst.net.nz> writes:

> Junio C Hamano wrote:
>>> A bare clone that fails to fetch HEAD will still complete
>>> "successfully". I'm not sure if that's expected/desired. Is a
>>> HEADless repo valid in any situation?
>> 
>> You would get "fatal: Not a git repository".  Why not default to
>> 'master' (if found) and issue a warning?
>
> And if not found die() for real...? Ok. I'll rework and resend.

Yeah, after making sure we have 'master' there, though ;-).

```
