remote: get rid of the run-time refspec setters These were left over from the culling as it's not clear which use-cases might benefit from this. It is not clear that we want to support any use-case which depends on changing the remote's idea of the base refspecs rather than passing in different per-operation refspec list, so remove these functions.
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 100 101 102 103 104 105 106 107 108 109 110 111 112
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 794897a..f9ec250 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -97,6 +97,10 @@ support for HTTPS connections insead of OpenSSL.
`git_remote_set_transport()` have been removed and the remote no
longer stores this configuration.
+* `git_remote_set_fetch_refpecs()` and
+ `git_remote_set_push_refspecs()` have been removed. There is no
+ longer a way to set the base refspecs at run-time.
+
### Breaking API changes
* `git_smart_subtransport_cb` now has a `param` parameter.
diff --git a/include/git2/remote.h b/include/git2/remote.h
index ab14ad4..36e9deb 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -190,16 +190,6 @@ GIT_EXTERN(int) git_remote_add_fetch(git_repository *repo, const char *remote, c
GIT_EXTERN(int) git_remote_get_fetch_refspecs(git_strarray *array, const git_remote *remote);
/**
- * Set the remote's list of fetch refspecs
- *
- * The contents of the string array are copied.
- *
- * @param remote the remote to modify
- * @param array the new list of fetch resfpecs
- */
-GIT_EXTERN(int) git_remote_set_fetch_refspecs(git_remote *remote, git_strarray *array);
-
-/**
* Add a push refspec to the remote's configuration
*
* Add the given refspec to the push list in the configuration. No
@@ -224,16 +214,6 @@ GIT_EXTERN(int) git_remote_add_push(git_repository *repo, const char *remote, co
GIT_EXTERN(int) git_remote_get_push_refspecs(git_strarray *array, const git_remote *remote);
/**
- * Set the remote's list of push refspecs
- *
- * The contents of the string array are copied.
- *
- * @param remote the remote to modify
- * @param array the new list of push resfpecs
- */
-GIT_EXTERN(int) git_remote_set_push_refspecs(git_remote *remote, git_strarray *array);
-
-/**
* Get the number of refspecs for a remote
*
* @param remote the remote
diff --git a/src/remote.c b/src/remote.c
index 44885bd..c561ecd 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -318,8 +318,9 @@ int git_remote_create_anonymous(git_remote **out, git_repository *repo, const ch
int git_remote_dup(git_remote **dest, git_remote *source)
{
+ size_t i;
int error = 0;
- git_strarray refspecs = { 0 };
+ git_refspec *spec;
git_remote *remote = git__calloc(1, sizeof(git_remote));
GITERR_CHECK_ALLOC(remote);
@@ -349,22 +350,15 @@ int git_remote_dup(git_remote **dest, git_remote *source)
goto cleanup;
}
- if ((error = git_remote_get_fetch_refspecs(&refspecs, source)) < 0 ||
- (error = git_remote_set_fetch_refspecs(remote, &refspecs)) < 0)
- goto cleanup;
-
- git_strarray_free(&refspecs);
-
- if ((error = git_remote_get_push_refspecs(&refspecs, source)) < 0 ||
- (error = git_remote_set_push_refspecs(remote, &refspecs)) < 0)
- goto cleanup;
+ git_vector_foreach(&source->refspecs, i, spec) {
+ if ((error = add_refspec(remote, spec->string, !spec->push)) < 0)
+ goto cleanup;
+ }
*dest = remote;
cleanup:
- git_strarray_free(&refspecs);
-
if (error < 0)
git__free(remote);
@@ -2046,16 +2040,6 @@ static int set_refspecs(git_remote *remote, git_strarray *array, int push)
return 0;
}
-int git_remote_set_fetch_refspecs(git_remote *remote, git_strarray *array)
-{
- return set_refspecs(remote, array, false);
-}
-
-int git_remote_set_push_refspecs(git_remote *remote, git_strarray *array)
-{
- return set_refspecs(remote, array, true);
-}
-
static int copy_refspecs(git_strarray *array, const git_remote *remote, unsigned int push)
{
size_t i;