diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2014-09-02 13:10:19 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-09-02 13:10:19 +0200 |
| commit | e128a1af6ec552f880051b67d72ab0a4c4c7d074 (patch) | |
| tree | 6a02fb68d05a9567de568075cf6a437b8b269ecc /src/clone.c | |
| parent | 538f908175a0912e0119f0ea8935e2d2b2dc416c (diff) | |
| download | libgit2-e128a1af6ec552f880051b67d72ab0a4c4c7d074.tar.gz | |
clone: correct handling of an unborn HEAD
If the remote does not advertise HEAD, then it is unborn and we cannot
checkout that branch. Handle it the same way as an empty repo.
Diffstat (limited to 'src/clone.c')
| -rw-r--r-- | src/clone.c | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/src/clone.c b/src/clone.c index 3dce67de1..4472651da 100644 --- a/src/clone.c +++ b/src/clone.c @@ -138,23 +138,6 @@ static int update_head_to_new_branch( return error; } -/** - * Check whether there are any branches among the listed - * references. It's possible for a repository to have a long list of - * references without us downloading any of them. - */ -static bool remote_has_branches(const git_remote_head **refs, size_t len) -{ - size_t i; - - for (i = 0; i < len; i++) { - if (!git__prefixcmp(refs[i]->name, GIT_REFS_HEADS_DIR)) - return true; - } - - return false; -} - static int update_head_to_remote( git_repository *repo, git_remote *remote, @@ -172,8 +155,8 @@ static int update_head_to_remote( if ((error = git_remote_ls(&refs, &refs_len, remote)) < 0) return error; - /* Did we just clone an empty repository? */ - if (!remote_has_branches(refs, refs_len)) + /* We cloned an empty repository or one with an unborn HEAD */ + if (refs_len == 0 || strcmp(refs[0]->name, GIT_HEAD_FILE)) return setup_tracking_config( repo, "master", GIT_REMOTE_ORIGIN, GIT_REFS_HEADS_MASTER_FILE); |
