On Sat, Jun 30, 2018 at 10:35 AM, Christian Couder
<[email protected]> wrote:
> Changes compared to V1 of this patch series
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> - fix tests failures
> - error out when more than one "odb.<name>.promisorremote" exist
> with the same <name>
Here is the diff with V1:
diff --git a/remote-odb.c b/remote-odb.c
index 5b9d1930b5..eb580ca513 100644
--- a/remote-odb.c
+++ b/remote-odb.c
@@ -21,6 +21,17 @@ static struct odb_helper
*find_or_create_helper(const char *name, int len)
return o;
}
+static struct odb_helper *do_find_odb_helper(const char *remote)
+{
+ struct odb_helper *o;
+
+ for (o = helpers; o; o = o->next)
+ if (o->remote && !strcmp(o->remote, remote))
+ return o;
+
+ return NULL;
+}
+
static int remote_odb_config(const char *var, const char *value, void *data)
{
struct odb_helper *o;
@@ -33,8 +44,22 @@ static int remote_odb_config(const char *var, const
char *value, void *data)
o = find_or_create_helper(name, namelen);
- if (!strcmp(subkey, "promisorremote"))
- return git_config_string(&o->remote, var, value);
+ if (!strcmp(subkey, "promisorremote")) {
+ const char *remote;
+ int res = git_config_string(&remote, var, value);
+
+ if (res)
+ return res;
+
+ if (do_find_odb_helper(remote))
+ return error(_("when parsing config key '%s' "
+ "helper for remote '%s' already exists"),
+ var, remote);
+
+ o->remote = remote;
+
+ return 0;
+ }
if (!strcmp(subkey, "partialclonefilter"))
return git_config_string(&o->partial_clone_filter, var, value);
@@ -71,11 +96,7 @@ struct odb_helper *find_odb_helper(const char *remote)
if (!remote)
return helpers;
- for (o = helpers; o; o = o->next)
- if (!strcmp(o->remote, remote))
- return o;
-
- return NULL;
+ return do_find_odb_helper(remote);
}
int has_remote_odb(void)
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index b29c0d3d39..9d513ebf57 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -23,10 +23,10 @@ promise_and_delete () {
delete_object repo "$HASH"
}
-test_expect_success 'extensions.partialclone without filter' '
+test_expect_success 'promisor remote without filter' '
test_create_repo server &&
git clone --filter="blob:none" "file://$(pwd)/server" client &&
- git -C client config --unset core.partialclonefilter &&
+ git -C client config --unset odb.origin.partialclonefilter &&
git -C client fetch origin
'
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index a4fe6508bd..0c47599568 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -285,7 +285,7 @@ test_expect_success 'partial fetch' '
rm -rf client "$(pwd)/trace" &&
git init client &&
SERVER="file://$(pwd)/server" &&
- test_config -C client extensions.partialClone "$SERVER" &&
+ test_config -C client odb.magic.promisorRemote "$SERVER" &&
GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
fetch --filter=blob:none "$SERVER" master:refs/heads/other &&