Commit 2f03050f by Carlos Martín Nieto

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.
parent 567649f2
...@@ -54,7 +54,7 @@ GIT_EXTERN(int) git_remote_create( ...@@ -54,7 +54,7 @@ GIT_EXTERN(int) git_remote_create(
* *
* @param out pointer to the new remote object * @param out pointer to the new remote object
* @param repo the associated repository * @param repo the associated repository
* @param fetch the fetch refspec to use for this remote. May be NULL for defaults. * @param fetch the fetch refspec to use for this remote.
* @param url the remote repository's URL * @param url the remote repository's URL
* @return 0 or an error code * @return 0 or an error code
*/ */
......
...@@ -23,7 +23,7 @@ struct filter_payload { ...@@ -23,7 +23,7 @@ struct filter_payload {
git_remote *remote; git_remote *remote;
const git_refspec *spec, *tagspec; const git_refspec *spec, *tagspec;
git_odb *odb; git_odb *odb;
int found_head; int want_head;
}; };
static int filter_ref__cb(git_remote_head *head, void *payload) 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) ...@@ -34,9 +34,9 @@ static int filter_ref__cb(git_remote_head *head, void *payload)
if (!git_reference_is_valid_name(head->name)) if (!git_reference_is_valid_name(head->name))
return 0; return 0;
if (!p->found_head && strcmp(head->name, GIT_HEAD_FILE) == 0) if ((strcmp(head->name, GIT_HEAD_FILE) == 0) && p->want_head) {
p->found_head = 1; match = 1;
else if (p->remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) { } else if (p->remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
/* /*
* If tagopt is --tags, then we only use the default * If tagopt is --tags, then we only use the default
* tags refspec and ignore the remote's * tags refspec and ignore the remote's
...@@ -77,8 +77,9 @@ static int filter_wants(git_remote *remote) ...@@ -77,8 +77,9 @@ static int filter_wants(git_remote *remote)
* HEAD, which will be stored in FETCH_HEAD after the fetch. * HEAD, which will be stored in FETCH_HEAD after the fetch.
*/ */
p.tagspec = &tagspec; p.tagspec = &tagspec;
p.found_head = 0;
p.remote = remote; p.remote = remote;
if (remote->refspecs.length == 0)
p.want_head = 1;
if (git_repository_odb__weakptr(&p.odb, remote->repo) < 0) if (git_repository_odb__weakptr(&p.odb, remote->repo) < 0)
goto cleanup; goto cleanup;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment