Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-10-26 18:21:31 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2013-11-02 01:47:06 +0400
commit2f03050f4fc50746faef46be498aa0af9697fee2 (patch)
treec13c6e468e35dcbaef6cfb692a92c6b127b52c3a /src/fetch.c
parent567649f2ada60e5c3009cc985af238b452b14a81 (diff)
remote: download HEAD when no refspecs are given
The correct behaviour when a remote has no refspecs (e.g. a URL from the command-line) is to download the remote's HEAD. Let's do that. This fixes #1261.
Diffstat (limited to 'src/fetch.c')
-rw-r--r--src/fetch.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/fetch.c b/src/fetch.c
index 5d97913e8..e83dc4add 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -23,7 +23,7 @@ struct filter_payload {
git_remote *remote;
const git_refspec *spec, *tagspec;
git_odb *odb;
- int found_head;
+ int want_head;
};
static int filter_ref__cb(git_remote_head *head, void *payload)
@@ -34,9 +34,9 @@ static int filter_ref__cb(git_remote_head *head, void *payload)
if (!git_reference_is_valid_name(head->name))
return 0;
- if (!p->found_head && strcmp(head->name, GIT_HEAD_FILE) == 0)
- p->found_head = 1;
- else if (p->remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
+ if ((strcmp(head->name, GIT_HEAD_FILE) == 0) && p->want_head) {
+ match = 1;
+ } else if (p->remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
/*
* If tagopt is --tags, then we only use the default
* tags refspec and ignore the remote's
@@ -77,8 +77,9 @@ static int filter_wants(git_remote *remote)
* HEAD, which will be stored in FETCH_HEAD after the fetch.
*/
p.tagspec = &tagspec;
- p.found_head = 0;
p.remote = remote;
+ if (remote->refspecs.length == 0)
+ p.want_head = 1;
if (git_repository_odb__weakptr(&p.odb, remote->repo) < 0)
goto cleanup;