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>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
diff --git a/src/config.h b/src/config.h
index 673887e..e2f301b 100644
--- a/src/config.h
+++ b/src/config.h
@@ -4,12 +4,14 @@
#include "git2.h"
#include "git2/config.h"
#include "vector.h"
+#include "repository.h"
#define GIT_CONFIG_FILENAME ".gitconfig"
#define GIT_CONFIG_FILENAME_INREPO "config"
struct git_config {
git_vector files;
+ git_repository *repo;
};
#endif
diff --git a/src/fetch.c b/src/fetch.c
index 522625e..5dc0440 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -48,11 +48,12 @@ static int whn_cmp(const void *a, const void *b)
* FIXME: we assume that the transport has been connected, enforce
* 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_headarray refs;
git_transport *t = remote->transport;
+ git_repository *repo = remote->repo;
const git_refspec *spec;
int error;
unsigned int i;
@@ -136,13 +137,14 @@ cleanup:
* them out. When we get an ACK we hide that commit and continue
* 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;
int error;
unsigned int i;
git_reference *ref;
git_strarray refs;
+ git_repository *repo = remote->repo;
git_oid oid;
/* Don't try to negotiate when we don't want anything */
@@ -195,7 +197,7 @@ cleanup:
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);
}
diff --git a/src/remote.c b/src/remote.c
index 2812f5d..809bfbb 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -110,6 +110,7 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
goto cleanup;
}
+ remote->repo = cfg->repo;
remote->url = git__strdup(val);
if (remote->url == NULL) {
error = GIT_ENOMEM;
diff --git a/src/remote.h b/src/remote.h
index 129671f..b94193c 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -11,6 +11,7 @@ struct git_remote {
struct git_refspec fetch;
struct git_refspec push;
git_transport *transport;
+ git_repository *repo;
};
#endif
diff --git a/src/repository.c b/src/repository.c
index cb62d9e..c0e99bb 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -317,6 +317,7 @@ int git_repository_config(
goto cleanup;
}
+ (*out)->repo = repo;
return GIT_SUCCESS;
cleanup: