summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bc14fac)
raw | patch | inline | side by side (parent: bc14fac)
author | Jeff King <peff@peff.net> | |
Fri, 27 Feb 2009 19:10:06 +0000 (14:10 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 27 Feb 2009 23:19:23 +0000 (15:19 -0800) |
Our usual method for determining the ref pointed to by HEAD
is to compare HEAD's sha1 to the sha1 of all refs, trying to
find a unique match.
However, some transports actually get to look at HEAD
directly; we should make use of that information when it is
available. Currently, only http remotes support this
feature.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
is to compare HEAD's sha1 to the sha1 of all refs, trying to
find a unique match.
However, some transports actually get to look at HEAD
directly; we should make use of that information when it is
available. Currently, only http remotes support this
feature.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c | patch | blob | history | |
t/t5550-http-fetch.sh | patch | blob | history |
diff --git a/remote.c b/remote.c
index 2123005d4bade5688ad03c97edecd6f84a157e17..9b8522db35367e5a698bebfcac9c3a107bfa5298 100644 (file)
--- a/remote.c
+++ b/remote.c
if (!head)
return NULL;
+ /*
+ * Some transports support directly peeking at
+ * where HEAD points; if that is the case, then
+ * we don't have to guess.
+ */
+ if (head->symref)
+ return copy_ref(find_ref_by_name(refs, head->symref));
+
/* If refs/heads/master could be right, it is. */
if (!all) {
r = find_ref_by_name(refs, "refs/heads/master");
diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh
index b6e6ec96075d8e8485de466c4c5c6f325e7b0d62..05b1b62cb66956bca57e1fbacac534993637bdd9 100755 (executable)
--- a/t/t5550-http-fetch.sh
+++ b/t/t5550-http-fetch.sh
test_cmp file clone/file
'
+test_expect_success 'http remote detects correct HEAD' '
+ git push public master:other &&
+ (cd clone &&
+ git remote set-head origin -d &&
+ git remote set-head origin -a &&
+ git symbolic-ref refs/remotes/origin/HEAD > output &&
+ echo refs/remotes/origin/master > expect &&
+ test_cmp expect output
+ )
+'
+
stop_httpd
test_done