mirror of
				https://git.proxmox.com/git/libgit2
				synced 2025-11-04 10:33:00 +00:00 
			
		
		
		
	remote: remove fetch parameter from create_anonymous
An anonymous remote is not configured and cannot therefore have configured refspecs. Remove the parameter which adds this from the constructor.
This commit is contained in:
		
							parent
							
								
									70f7484d2a
								
							
						
					
					
						commit
						ae5b93629c
					
				@ -183,6 +183,9 @@ support for HTTPS connections insead of OpenSSL.
 | 
			
		||||
  well as a boolean whether to write `FETCH_HEAD` and the autotag
 | 
			
		||||
  setting.
 | 
			
		||||
 | 
			
		||||
* `git_remote_create_anonymous()` no longer takes a fetch refspec as
 | 
			
		||||
  url-only remotes cannot have configured refspecs.
 | 
			
		||||
 | 
			
		||||
* The `git_submodule_update_options` struct now has fetch options in
 | 
			
		||||
  the `fetch_opts` field instead of callbacks in the
 | 
			
		||||
  `remote_callbacks` field.
 | 
			
		||||
 | 
			
		||||
@ -92,7 +92,7 @@ int fetch(git_repository *repo, int argc, char **argv)
 | 
			
		||||
	// Figure out whether it's a named remote or a URL
 | 
			
		||||
	printf("Fetching %s for repo %p\n", argv[1], repo);
 | 
			
		||||
	if (git_remote_lookup(&remote, repo, argv[1]) < 0) {
 | 
			
		||||
		if (git_remote_create_anonymous(&remote, repo, argv[1], NULL) < 0)
 | 
			
		||||
		if (git_remote_create_anonymous(&remote, repo, argv[1]) < 0)
 | 
			
		||||
			return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ static int use_remote(git_repository *repo, char *name)
 | 
			
		||||
	// Find the remote by name
 | 
			
		||||
	error = git_remote_lookup(&remote, repo, name);
 | 
			
		||||
	if (error < 0) {
 | 
			
		||||
		error = git_remote_create_anonymous(&remote, repo, name, NULL);
 | 
			
		||||
		error = git_remote_create_anonymous(&remote, repo, name);
 | 
			
		||||
		if (error < 0)
 | 
			
		||||
			goto cleanup;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -63,24 +63,18 @@ GIT_EXTERN(int) git_remote_create_with_fetchspec(
 | 
			
		||||
/**
 | 
			
		||||
 * Create an anonymous remote
 | 
			
		||||
 *
 | 
			
		||||
 * Create a remote with the given url and refspec in memory. You can use
 | 
			
		||||
 * this when you have a URL instead of a remote's name.  Note that anonymous
 | 
			
		||||
 * remotes cannot be converted to persisted remotes.
 | 
			
		||||
 * Create a remote with the given url in-memory. You can use this when
 | 
			
		||||
 * you have a URL instead of a remote's name.
 | 
			
		||||
 *
 | 
			
		||||
 * The name, when provided, will be checked for validity.
 | 
			
		||||
 * See `git_tag_create()` for rules about valid names.
 | 
			
		||||
 *
 | 
			
		||||
 * @param out pointer to the new remote object
 | 
			
		||||
 * @param out pointer to the new remote objects
 | 
			
		||||
 * @param repo the associated repository
 | 
			
		||||
 * @param url the remote repository's URL
 | 
			
		||||
 * @param fetch the fetch refspec to use for this remote.
 | 
			
		||||
 * @return 0 or an error code
 | 
			
		||||
 */
 | 
			
		||||
GIT_EXTERN(int) git_remote_create_anonymous(
 | 
			
		||||
		git_remote **out,
 | 
			
		||||
		git_repository *repo,
 | 
			
		||||
		const char *url,
 | 
			
		||||
		const char *fetch);
 | 
			
		||||
		const char *url);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get the information for a particular remote
 | 
			
		||||
 | 
			
		||||
@ -311,9 +311,9 @@ on_error:
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int git_remote_create_anonymous(git_remote **out, git_repository *repo, const char *url, const char *fetch)
 | 
			
		||||
int git_remote_create_anonymous(git_remote **out, git_repository *repo, const char *url)
 | 
			
		||||
{
 | 
			
		||||
	return create_internal(out, repo, NULL, url, fetch);
 | 
			
		||||
	return create_internal(out, repo, NULL, url, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int git_remote_dup(git_remote **dest, git_remote *source)
 | 
			
		||||
 | 
			
		||||
@ -39,7 +39,7 @@ static void connect_to_local_repository(const char *local_repository)
 | 
			
		||||
{
 | 
			
		||||
	git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
 | 
			
		||||
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf), NULL));
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf)));
 | 
			
		||||
	cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -71,7 +71,7 @@ void test_network_remote_local__retrieve_advertised_before_connect(void)
 | 
			
		||||
 | 
			
		||||
	git_buf_sets(&file_path_buf, cl_git_path_url(cl_fixture("testrepo.git")));
 | 
			
		||||
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf), NULL));
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf)));
 | 
			
		||||
	cl_git_fail(git_remote_ls(&refs, &refs_len, remote));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -213,7 +213,7 @@ void test_network_remote_local__push_to_bare_remote(void)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Connect to the bare repo */
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git", NULL));
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git"));
 | 
			
		||||
	cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL));
 | 
			
		||||
 | 
			
		||||
	/* Try to push */
 | 
			
		||||
@ -252,7 +252,7 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void)
 | 
			
		||||
	url = cl_git_path_url("./localbare.git");
 | 
			
		||||
 | 
			
		||||
	/* Connect to the bare repo */
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&localremote, repo, url, NULL));
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&localremote, repo, url));
 | 
			
		||||
	cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL));
 | 
			
		||||
 | 
			
		||||
	/* Try to push */
 | 
			
		||||
@ -289,7 +289,7 @@ void test_network_remote_local__push_to_non_bare_remote(void)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Connect to the bare repo */
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare", NULL));
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare"));
 | 
			
		||||
	cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL));
 | 
			
		||||
 | 
			
		||||
	/* Try to push */
 | 
			
		||||
 | 
			
		||||
@ -90,7 +90,7 @@ void test_network_remote_remotes__error_when_no_push_available(void)
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git"), NULL));
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git")));
 | 
			
		||||
 | 
			
		||||
	callbacks.transport = git_transport_local;
 | 
			
		||||
	cl_git_pass(git_remote_connect(r, GIT_DIRECTION_PUSH, &callbacks));
 | 
			
		||||
@ -465,13 +465,3 @@ void test_network_remote_remotes__query_refspecs(void)
 | 
			
		||||
	git_remote_free(remote);
 | 
			
		||||
	git_remote_delete(_repo, "test");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void test_network_remote_remotes__fetch_from_anonymous(void)
 | 
			
		||||
{
 | 
			
		||||
	git_remote *remote;
 | 
			
		||||
 | 
			
		||||
	cl_git_pass(git_remote_create_anonymous(&remote, _repo, cl_fixture("testrepo.git"),
 | 
			
		||||
						"refs/heads/*:refs/other/*"));
 | 
			
		||||
	cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL));
 | 
			
		||||
	git_remote_free(remote);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user