This makes "git clone" use the HEAD information sent by an updated uploader to point the resulting HEAD at the current branch that is not 'master' but happens to point at the same commit as 'master'. IOW, immediately after doing: $ git checkout -b another master a clone made out of that repository will check out 'another' branch, not 'master'. Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- builtin-clone.c | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/builtin-clone.c b/builtin-clone.c index 2feac9c..a8b8d56 100644 --- a/builtin-clone.c +++ b/builtin-clone.c @@ -299,13 +299,27 @@ static const struct ref *locate_head(const struct ref *refs, const struct ref *remote_head = NULL; const struct ref *remote_master = NULL; const struct ref *r; - for (r = refs; r; r = r->next) - if (!strcmp(r->name, "HEAD")) + + for (r = refs; r; r = r->next) { + if (!strcmp(r->name, "HEAD")) { remote_head = r; + break; + } + } - for (r = mapped_refs; r; r = r->next) - if (!strcmp(r->name, "refs/heads/master")) - remote_master = r; + if (remote_head && remote_head->symref) { + for (r = mapped_refs; r; r = r->next) + if (!strcmp(r->name, remote_head->symref)) { + remote_master = r; + break; + } + } + + if (!remote_master) { + for (r = mapped_refs; r; r = r->next) + if (!strcmp(r->name, "refs/heads/master")) + remote_master = r; + } if (remote_head_p) *remote_head_p = remote_head; -- 1.6.0.4.864.g0f47a -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html