Bind the configuration and remotes to a repository

Configurations when taken from a repository and remotes should be
identifiable as coming from a particular repository. This allows us to
reduce the amount of variables that the user has to keep track of.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
Carlos Martín Nieto 2011-08-03 22:03:57 +02:00 committed by Vicent Marti
parent da2902204b
commit 44daec4229
5 changed files with 11 additions and 4 deletions

View File

@ -4,12 +4,14 @@
#include "git2.h" #include "git2.h"
#include "git2/config.h" #include "git2/config.h"
#include "vector.h" #include "vector.h"
#include "repository.h"
#define GIT_CONFIG_FILENAME ".gitconfig" #define GIT_CONFIG_FILENAME ".gitconfig"
#define GIT_CONFIG_FILENAME_INREPO "config" #define GIT_CONFIG_FILENAME_INREPO "config"
struct git_config { struct git_config {
git_vector files; git_vector files;
git_repository *repo;
}; };
#endif #endif

View File

@ -48,11 +48,12 @@ static int whn_cmp(const void *a, const void *b)
* FIXME: we assume that the transport has been connected, enforce * FIXME: we assume that the transport has been connected, enforce
* that somehow, we also want to be called from _negotiate * that somehow, we also want to be called from _negotiate
*/ */
int git_fetch_list_want(git_headarray *whn_list, git_repository *repo, git_remote *remote) int git_fetch_list_want(git_headarray *whn_list, git_remote *remote)
{ {
git_vector list; git_vector list;
git_headarray refs; git_headarray refs;
git_transport *t = remote->transport; git_transport *t = remote->transport;
git_repository *repo = remote->repo;
const git_refspec *spec; const git_refspec *spec;
int error; int error;
unsigned int i; unsigned int i;
@ -136,13 +137,14 @@ cleanup:
* them out. When we get an ACK we hide that commit and continue * them out. When we get an ACK we hide that commit and continue
* traversing until we're done * traversing until we're done
*/ */
int git_fetch_negotiate(git_headarray *list, git_repository *repo, git_remote *remote) int git_fetch_negotiate(git_headarray *list, git_remote *remote)
{ {
git_revwalk *walk; git_revwalk *walk;
int error; int error;
unsigned int i; unsigned int i;
git_reference *ref; git_reference *ref;
git_strarray refs; git_strarray refs;
git_repository *repo = remote->repo;
git_oid oid; git_oid oid;
/* Don't try to negotiate when we don't want anything */ /* Don't try to negotiate when we don't want anything */
@ -195,7 +197,7 @@ cleanup:
return error; return error;
} }
int git_fetch_download_pack(git_remote *remote, git_repository *repo) int git_fetch_download_pack(git_remote *remote)
{ {
return git_transport_download_pack(remote->transport, repo); return git_transport_download_pack(remote->transport, remote->repo);
} }

View File

@ -110,6 +110,7 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
goto cleanup; goto cleanup;
} }
remote->repo = cfg->repo;
remote->url = git__strdup(val); remote->url = git__strdup(val);
if (remote->url == NULL) { if (remote->url == NULL) {
error = GIT_ENOMEM; error = GIT_ENOMEM;

View File

@ -11,6 +11,7 @@ struct git_remote {
struct git_refspec fetch; struct git_refspec fetch;
struct git_refspec push; struct git_refspec push;
git_transport *transport; git_transport *transport;
git_repository *repo;
}; };
#endif #endif

View File

@ -317,6 +317,7 @@ int git_repository_config(
goto cleanup; goto cleanup;
} }
(*out)->repo = repo;
return GIT_SUCCESS; return GIT_SUCCESS;
cleanup: cleanup: