threads / patch / 33529

patch, 6 partstransport-helper: some clarifications and a fix

Subject: [PATCH 0/6] transport-helper: some clarifications and a fix

## tl;dr

14 messages between Apr 18, 2013 and Apr 18, 2013. Diffs are folded; open one to read it.

replies: 13people: 4as markdown or json

Felipe Contreras· Apr 18, 2013, 00:05 UTC · lore
Hi,

It seems the workings of transport-helper are anything but clear, so let's try to clarify them a bit, and after that, hopefully it would become clearer why the last patch is actually a good fix.

Felipe Contreras (6):
  transport-helper: clarify *:* refspec
  transport-helper: update refspec documentation
  transport-helper: clarify pushing without refspecs
  transport-helper: warn when refspec is not used
  transport-helper: trivial code shuffle
  transport-helper: update remote helper namespace
 Documentation/gitremote-helpers.txt | 12 ++++++------
 t/t5801-remote-helpers.sh           | 39 ++++++++++++++++++-------------------
 transport-helper.c                  | 37 +++++++++++++++++++++++------------
 3 files changed, 50 insertions(+), 38 deletions(-)
-- 
1.8.2.1.679.g509521a
Felipe Contreras· Apr 18, 2013, 00:05 UTC · re: Felipe Contreras · lore

[PATCH 1/6] transport-helper: clarify *:* refspec

The *:* refspec doesn't work, and never has, clarify the code and documentation to reflect that. This in effect reverts commit 9e7673e (gitremote-helpers(1): clarify refspec behaviour).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Documentation/gitremote-helpers.txt |  4 ++--
 t/t5801-remote-helpers.sh           | 15 ---------------
 transport-helper.c                  |  2 +-
 3 files changed, 3 insertions(+), 18 deletions(-)
Show changes to 3 files +3 −18

Documentation/gitremote-helpers.txt, t/t5801-remote-helpers.sh, transport-helper.c

diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt
index f506031..0c91aba 100644
--- a/Documentation/gitremote-helpers.txt
+++ b/Documentation/gitremote-helpers.txt
@@ -174,8 +174,8 @@ ref.
 This capability can be advertised multiple times.  The first
 applicable refspec takes precedence.  The left-hand of refspecs
 advertised with this capability must cover all refs reported by
-the list command.  If a helper does not need a specific 'refspec'
-capability then it should advertise `refspec *:*`.
+the list command.  If no 'refspec' capability is advertised,
+there is an implied `refspec *:*`.
 
 'bidi-import'::
 	This modifies the 'import' capability.
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index f387027..cd1873c 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -120,21 +120,6 @@ test_expect_failure 'pushing without refspecs' '
 	compare_refs local2 HEAD server HEAD
 '
 
-test_expect_success 'pulling with straight refspec' '
-	(cd local2 &&
-	GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
-	compare_refs local2 HEAD server HEAD
-'
-
-test_expect_failure 'pushing with straight refspec' '
-	test_when_finished "(cd local2 && git reset --hard origin)" &&
-	(cd local2 &&
-	echo content >>file &&
-	git commit -a -m eleven &&
-	GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
-	compare_refs local2 HEAD server HEAD
-'
-
 test_expect_success 'pulling without marks' '
 	(cd local2 &&
 	GIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) &&
diff --git a/transport-helper.c b/transport-helper.c
index dcd8d97..cea787c 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -469,7 +469,7 @@ static int fetch_with_import(struct transport *transport,
 	 * were fetching.
 	 *
 	 * (If no "refspec" capability was specified, for historical
-	 * reasons we default to *:*.)
+	 * reasons we default to the equivalent of *:*.)
 	 *
 	 * Store the result in to_fetch[i].old_sha1.  Callers such
 	 * as "git fetch" can use the value to write feedback to the
-- 
1.8.2.1.679.g509521a
Thomas Rast· Apr 18, 2013, 07:28 UTC · re: Felipe Contreras · lore

Re: [PATCH 1/6] transport-helper: clarify *:* refspec

Felipe Contreras <felipe.contreras@gmail.com> writes:
> The *:* refspec doesn't work, and never has, clarify the code and
> documentation to reflect that. This in effect reverts commit 9e7673e
> (gitremote-helpers(1): clarify refspec behaviour).
[...]
Show 14 quoted lines
> -test_expect_success 'pulling with straight refspec' '
> -	(cd local2 &&
> -	GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
> -	compare_refs local2 HEAD server HEAD
> -'
> -
> -test_expect_failure 'pushing with straight refspec' '
> -	test_when_finished "(cd local2 && git reset --hard origin)" &&
> -	(cd local2 &&
> -	echo content >>file &&
> -	git commit -a -m eleven &&
> -	GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
> -	compare_refs local2 HEAD server HEAD
> -'

So what's wrong with the tests? Do they fail to test what they claim (how?), test something that wasn't reasonable to begin with, or something entirely different?

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Felipe Contreras· Apr 18, 2013, 08:18 UTC · re: Thomas Rast · lore

Re: [PATCH 1/6] transport-helper: clarify *:* refspec

On Thu, Apr 18, 2013 at 2:28 AM, Thomas Rast <trast@inf.ethz.ch> wrote:
Show 24 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> The *:* refspec doesn't work, and never has, clarify the code and
>> documentation to reflect that. This in effect reverts commit 9e7673e
>> (gitremote-helpers(1): clarify refspec behaviour).
> [...]
>> -test_expect_success 'pulling with straight refspec' '
>> -     (cd local2 &&
>> -     GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
>> -     compare_refs local2 HEAD server HEAD
>> -'
>> -
>> -test_expect_failure 'pushing with straight refspec' '
>> -     test_when_finished "(cd local2 && git reset --hard origin)" &&
>> -     (cd local2 &&
>> -     echo content >>file &&
>> -     git commit -a -m eleven &&
>> -     GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
>> -     compare_refs local2 HEAD server HEAD
>> -'
>
> So what's wrong with the tests?  Do they fail to test what they claim
> (how?), test something that wasn't reasonable to begin with, or
> something entirely different?

Look at the code comment, and look at the now updated documentation that assumes that *:* was reasonable. Given the available information, it would be reasonable to assume that *:* did work, but it didn't work, and it's not really possible to fix it, even if we wanted to, it would be a hack. It's better to accept that fact and stop worrying too much about what would be the best way to do the wrong thing.

-- 
Felipe Contreras
Thomas Rast· Apr 18, 2013, 12:39 UTC · re: Felipe Contreras · lore

Re: [PATCH 1/6] transport-helper: clarify *:* refspec

Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 32 quoted lines
> On Thu, Apr 18, 2013 at 2:28 AM, Thomas Rast <trast@inf.ethz.ch> wrote:
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>> The *:* refspec doesn't work, and never has, clarify the code and
>>> documentation to reflect that. This in effect reverts commit 9e7673e
>>> (gitremote-helpers(1): clarify refspec behaviour).
>> [...]
>>> -test_expect_success 'pulling with straight refspec' '
>>> -     (cd local2 &&
>>> -     GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
>>> -     compare_refs local2 HEAD server HEAD
>>> -'
>>> -
>>> -test_expect_failure 'pushing with straight refspec' '
>>> -     test_when_finished "(cd local2 && git reset --hard origin)" &&
>>> -     (cd local2 &&
>>> -     echo content >>file &&
>>> -     git commit -a -m eleven &&
>>> -     GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
>>> -     compare_refs local2 HEAD server HEAD
>>> -'
>>
>> So what's wrong with the tests?  Do they fail to test what they claim
>> (how?), test something that wasn't reasonable to begin with, or
>> something entirely different?
>
> Look at the code comment, and look at the now updated documentation
> that assumes that *:* was reasonable. Given the available information,
> it would be reasonable to assume that *:* did work, but it didn't
> work, and it's not really possible to fix it, even if we wanted to, it
> would be a hack. It's better to accept that fact and stop worrying too
> much about what would be the best way to do the wrong thing.

Ok, you say that the *failing* test set an expectation that is unrealistic, so let's drop it.

But then what about the successful test? Does it actually work (and by removing the test, you are saying that we don't care if we subsequently break that (mis)feature)? Or did it test the wrong thing?

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Felipe Contreras· Apr 18, 2013, 13:06 UTC · re: Thomas Rast · lore

Re: [PATCH 1/6] transport-helper: clarify *:* refspec

On Thu, Apr 18, 2013 at 7:39 AM, Thomas Rast <trast@inf.ethz.ch> wrote:
Show 41 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Thu, Apr 18, 2013 at 2:28 AM, Thomas Rast <trast@inf.ethz.ch> wrote:
>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>
>>>> The *:* refspec doesn't work, and never has, clarify the code and
>>>> documentation to reflect that. This in effect reverts commit 9e7673e
>>>> (gitremote-helpers(1): clarify refspec behaviour).
>>> [...]
>>>> -test_expect_success 'pulling with straight refspec' '
>>>> -     (cd local2 &&
>>>> -     GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
>>>> -     compare_refs local2 HEAD server HEAD
>>>> -'
>>>> -
>>>> -test_expect_failure 'pushing with straight refspec' '
>>>> -     test_when_finished "(cd local2 && git reset --hard origin)" &&
>>>> -     (cd local2 &&
>>>> -     echo content >>file &&
>>>> -     git commit -a -m eleven &&
>>>> -     GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
>>>> -     compare_refs local2 HEAD server HEAD
>>>> -'
>>>
>>> So what's wrong with the tests?  Do they fail to test what they claim
>>> (how?), test something that wasn't reasonable to begin with, or
>>> something entirely different?
>>
>> Look at the code comment, and look at the now updated documentation
>> that assumes that *:* was reasonable. Given the available information,
>> it would be reasonable to assume that *:* did work, but it didn't
>> work, and it's not really possible to fix it, even if we wanted to, it
>> would be a hack. It's better to accept that fact and stop worrying too
>> much about what would be the best way to do the wrong thing.
>
> Ok, you say that the *failing* test set an expectation that is
> unrealistic, so let's drop it.
>
> But then what about the successful test?  Does it actually work (and by
> removing the test, you are saying that we don't care if we subsequently
> break that (mis)feature)?  Or did it test the wrong thing?

Yeah, it works, in the sense that peeing in a bottle is a solution; it might work, but it's not recommendable. So, if suddenly working, frankly I don't care. I added those tests, and I don't think they are needed. In a not too distant future it should not be permitted to "work"; we don't want developers to shoot themselves in the foot, and heir users too.

-- 
Felipe Contreras
Felipe Contreras· Apr 18, 2013, 00:05 UTC · re: Felipe Contreras · lore

[PATCH 2/6] transport-helper: update refspec documentation

The refspec capability is not only used by 'import', also by 'export', and it's recommend in both.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Documentation/gitremote-helpers.txt | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Show changes to Documentation/gitremote-helpers.txt +5 −5
diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt
index 0c91aba..ba7240c 100644
--- a/Documentation/gitremote-helpers.txt
+++ b/Documentation/gitremote-helpers.txt
@@ -159,11 +159,11 @@ Miscellaneous capabilities
 	carried out.
 
 'refspec' <refspec>::
-	This modifies the 'import' capability, allowing the produced
-	fast-import stream to modify refs in a private namespace
-	instead of writing to refs/heads or refs/remotes directly.
-	It is recommended that all importers providing the 'import'
-	capability use this.
+	For remote helpers that implement 'import' or 'export', this capability
+	allows the refs to be constrained to a private namespace, instead of
+	writing to refs/heads or refs/remotes directly.
+	It is recommended that all importers providing the 'import' or 'export'
+	capabilities use this.
 +
 A helper advertising the capability
 `refspec refs/heads/*:refs/svn/origin/branches/*`
-- 
1.8.2.1.679.g509521a
Felipe Contreras· Apr 18, 2013, 00:05 UTC · re: Felipe Contreras · lore

[PATCH 3/6] transport-helper: clarify pushing without refspecs

This has never worked, since it's inception the code simply skips all the refs, essentially telling fast-export to do nothing.

Let's at least tell the user what's going on.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Documentation/gitremote-helpers.txt | 4 ++--
 t/t5801-remote-helpers.sh           | 6 +++---
 transport-helper.c                  | 5 +++--
 3 files changed, 8 insertions(+), 7 deletions(-)
Show changes to 3 files +8 −7

Documentation/gitremote-helpers.txt, t/t5801-remote-helpers.sh, transport-helper.c

diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt
index ba7240c..4d26e37 100644
--- a/Documentation/gitremote-helpers.txt
+++ b/Documentation/gitremote-helpers.txt
@@ -162,8 +162,8 @@ Miscellaneous capabilities
 	For remote helpers that implement 'import' or 'export', this capability
 	allows the refs to be constrained to a private namespace, instead of
 	writing to refs/heads or refs/remotes directly.
-	It is recommended that all importers providing the 'import' or 'export'
-	capabilities use this.
+	It is recommended that all importers providing the 'import'
+	capability use this. It's mandatory for 'export'.
 +
 A helper advertising the capability
 `refspec refs/heads/*:refs/svn/origin/branches/*`
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index cd1873c..3eeb309 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -111,13 +111,13 @@ test_expect_success 'pulling without refspecs' '
 	compare_refs local2 HEAD server HEAD
 '
 
-test_expect_failure 'pushing without refspecs' '
+test_expect_success 'pushing without refspecs' '
 	test_when_finished "(cd local2 && git reset --hard origin)" &&
 	(cd local2 &&
 	echo content >>file &&
 	git commit -a -m ten &&
-	GIT_REMOTE_TESTGIT_REFSPEC="" git push) &&
-	compare_refs local2 HEAD server HEAD
+	GIT_REMOTE_TESTGIT_REFSPEC="" test_must_fail git push 2> ../error) &&
+	grep "remote-helper doesn.t support push; refspec needed" error
 '
 
 test_expect_success 'pulling without marks' '
diff --git a/transport-helper.c b/transport-helper.c
index cea787c..4d98567 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -785,6 +785,9 @@ static int push_refs_with_export(struct transport *transport,
 	struct string_list revlist_args = STRING_LIST_INIT_NODUP;
 	struct strbuf buf = STRBUF_INIT;
 
+	if (!data->refspecs)
+		die("remote-helper doesn't support push; refspec needed");
+
 	helper = get_helper(transport);
 
 	write_constant(helper->in, "export\n");
@@ -795,8 +798,6 @@ static int push_refs_with_export(struct transport *transport,
 		char *private;
 		unsigned char sha1[20];
 
-		if (!data->refspecs)
-			continue;
 		private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
 		if (private && !get_sha1(private, sha1)) {
 			strbuf_addf(&buf, "^%s", private);
-- 
1.8.2.1.679.g509521a
Sverre Rabbelier· Apr 18, 2013, 00:14 UTC · re: Felipe Contreras · lore

Re: [PATCH 3/6] transport-helper: clarify pushing without refspecs

On Wed, Apr 17, 2013 at 5:05 PM, Felipe Contreras <felipe.contreras@gmail.com> wrote:

> This has never worked, since it's inception the code simply skips all
> the refs, essentially telling fast-export to do nothing.
Makes sense.

-- Cheers,

Sverre Rabbelier
Stefano Lattarini· Apr 18, 2013, 18:56 UTC · re: Felipe Contreras · lore

Re: [PATCH 3/6] transport-helper: clarify pushing without refspecs

On 04/18/2013 02:05 AM, Felipe Contreras wrote:
> This has never worked, since it's inception the code simply skips all
>
s/it's/its/ (sorry for nitpicking)
Show 6 quoted lines
> the refs, essentially telling fast-export to do nothing.
> 
> Let's at least tell the user what's going on.
> 
> [SNIP]
>
Regards,
  Stefano
Felipe Contreras· Apr 18, 2013, 00:05 UTC · re: Felipe Contreras · lore

[PATCH 4/6] transport-helper: warn when refspec is not used

For the modes that need it. In the future we should probably error out, instead of providing half-assed support.

The reason we want to do this is because if it's not present, the remote helper might be updating refs/heads/*, or refs/remotes/origin/*, directly, and in the process fetch will get confused trying to update refs that are already updated, or older than what they should be. We shouldn't be messing with the rest of git.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t5801-remote-helpers.sh | 6 ++++--
 transport-helper.c        | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
Show changes to 2 files +6 −2

t/t5801-remote-helpers.sh, transport-helper.c

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 3eeb309..1bb7529 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -100,14 +100,16 @@ test_expect_failure 'push new branch with old:new refspec' '
 
 test_expect_success 'cloning without refspec' '
 	GIT_REMOTE_TESTGIT_REFSPEC="" \
-	git clone "testgit::${PWD}/server" local2 &&
+	git clone "testgit::${PWD}/server" local2 2> error &&
+	grep "This remote helper should implement refspec capability" error &&
 	compare_refs local2 HEAD server HEAD
 '
 
 test_expect_success 'pulling without refspecs' '
 	(cd local2 &&
 	git reset --hard &&
-	GIT_REMOTE_TESTGIT_REFSPEC="" git pull) &&
+	GIT_REMOTE_TESTGIT_REFSPEC="" git pull 2> ../error) &&
+	grep "This remote helper should implement refspec capability" error &&
 	compare_refs local2 HEAD server HEAD
 '
 
diff --git a/transport-helper.c b/transport-helper.c
index 4d98567..573eaf7 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -215,6 +215,8 @@ static struct child_process *get_helper(struct transport *transport)
 			free((char *)refspecs[i]);
 		}
 		free(refspecs);
+	} else if (data->import || data->bidi_import || data->export) {
+		warning("This remote helper should implement refspec capability.");
 	}
 	strbuf_release(&buf);
 	if (debug)
-- 
1.8.2.1.679.g509521a
Felipe Contreras· Apr 18, 2013, 00:05 UTC · re: Felipe Contreras · lore

[PATCH 5/6] transport-helper: trivial code shuffle

Just shuffle the die() part to make it more explicit, and cleanup the code-style.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 transport-helper.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
Show changes to transport-helper.c +3 −5
diff --git a/transport-helper.c b/transport-helper.c
index 573eaf7..9d31f2d 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -800,6 +800,9 @@ static int push_refs_with_export(struct transport *transport,
 		char *private;
 		unsigned char sha1[20];
 
+		if (ref->deletion)
+			die("remote-helpers do not support ref deletion");
+
 		private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
 		if (private && !get_sha1(private, sha1)) {
 			strbuf_addf(&buf, "^%s", private);
@@ -807,13 +810,8 @@ static int push_refs_with_export(struct transport *transport,
 		}
 		free(private);
 
-		if (ref->deletion) {
-			die("remote-helpers do not support ref deletion");
-		}
-
 		if (ref->peer_ref)
 			string_list_append(&revlist_args, ref->peer_ref->name);
-
 	}
 
 	if (get_exporter(transport, &exporter, &revlist_args))
-- 
1.8.2.1.679.g509521a
Felipe Contreras· Apr 18, 2013, 00:05 UTC · re: Felipe Contreras · lore

[PATCH 6/6] transport-helper: update remote helper namespace

When pushing, the remote namespace is updated correctly (e.g. refs/origin/master), but not the remote helper's (e.g. refs/testgit/origin/master), which currently is only updated while fetching.

Since the remote namespace is used to tell fast-export which commits to avoid (because they were already imported/exported), it makes sense to have them in sync so they don't get generated twice. If the remote helper was implemented properly, they would be ignored, if not, they probably would end up repeated (probably).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t5801-remote-helpers.sh | 12 ++++++++++++
 transport-helper.c        | 20 ++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)
Show changes to 2 files +28 −4

t/t5801-remote-helpers.sh, transport-helper.c

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 1bb7529..097691c 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -153,4 +153,16 @@ test_expect_success 'push ref with existing object' '
 	compare_refs local dup server dup
 '
 
+test_expect_success 'push update refs' '
+	(cd local &&
+	git checkout -b update master &&
+	echo update >>file &&
+	git commit -a -m update &&
+	git push origin update
+	git rev-parse --verify testgit/origin/heads/update >expect &&
+	git rev-parse --verify remotes/origin/update >actual
+	test_cmp expect actual
+	)
+'
+
 test_done
diff --git a/transport-helper.c b/transport-helper.c
index 9d31f2d..414d6c8 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -11,6 +11,7 @@
 #include "thread-utils.h"
 #include "sigchain.h"
 #include "argv-array.h"
+#include "refs.h"
 
 static int debug;
 
@@ -620,7 +621,7 @@ static int fetch(struct transport *transport,
 	return -1;
 }
 
-static void push_update_ref_status(struct strbuf *buf,
+static int push_update_ref_status(struct strbuf *buf,
 				   struct ref **ref,
 				   struct ref *remote_refs)
 {
@@ -686,7 +687,7 @@ static void push_update_ref_status(struct strbuf *buf,
 		*ref = find_ref_by_name(remote_refs, refname);
 	if (!*ref) {
 		warning("helper reported unexpected status of %s", refname);
-		return;
+		return 1;
 	}
 
 	if ((*ref)->status != REF_STATUS_NONE) {
@@ -695,11 +696,12 @@ static void push_update_ref_status(struct strbuf *buf,
 		 * status reported by the remote helper if the latter is 'no match'.
 		 */
 		if (status == REF_STATUS_NONE)
-			return;
+			return 1;
 	}
 
 	(*ref)->status = status;
 	(*ref)->remote_status = msg;
+	return 0;
 }
 
 static void push_update_refs_status(struct helper_data *data,
@@ -708,11 +710,21 @@ static void push_update_refs_status(struct helper_data *data,
 	struct strbuf buf = STRBUF_INIT;
 	struct ref *ref = remote_refs;
 	for (;;) {
+		char *private;
+
 		recvline(data, &buf);
 		if (!buf.len)
 			break;
 
-		push_update_ref_status(&buf, &ref, remote_refs);
+		if (push_update_ref_status(&buf, &ref, remote_refs))
+			continue;
+
+		/* propagate back the update to the remote namespace */
+		private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
+		if (!private)
+			continue;
+		update_ref("update by helper", private, ref->new_sha1, NULL, 0, 0);
+		free(private);
 	}
 	strbuf_release(&buf);
 }
-- 
1.8.2.1.679.g509521a
Felipe Contreras· Apr 18, 2013, 04:14 UTC · re: Felipe Contreras · lore

Re: [PATCH 6/6] transport-helper: update remote helper namespace

On Wed, Apr 17, 2013 at 7:05 PM, Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 15 quoted lines
> --- a/t/t5801-remote-helpers.sh
> +++ b/t/t5801-remote-helpers.sh
> @@ -153,4 +153,16 @@ test_expect_success 'push ref with existing object' '
>         compare_refs local dup server dup
>  '
>
> +test_expect_success 'push update refs' '
> +       (cd local &&
> +       git checkout -b update master &&
> +       echo update >>file &&
> +       git commit -a -m update &&
> +       git push origin update
> +       git rev-parse --verify testgit/origin/heads/update >expect &&
> +       git rev-parse --verify remotes/origin/update >actual
> +       test_cmp expect actual
Slightly confusing and a bit buggy:
-       git rev-parse --verify testgit/origin/heads/update >expect &&
-       git rev-parse --verify remotes/origin/update >actual
+       git rev-parse --verify remotes/origin/update >expect &&
+       git rev-parse --verify testgit/origin/heads/update >actual &&
Show 14 quoted lines
>  static void push_update_refs_status(struct helper_data *data,
> @@ -708,11 +710,21 @@ static void push_update_refs_status(struct helper_data *data,
>         struct strbuf buf = STRBUF_INIT;
>         struct ref *ref = remote_refs;
>         for (;;) {
> +               char *private;
> +
>                 recvline(data, &buf);
>                 if (!buf.len)
>                         break;
>
> -               push_update_ref_status(&buf, &ref, remote_refs);
> +               if (push_update_ref_status(&buf, &ref, remote_refs))
> +                       continue;
Actually, since this function is also used by push_with_push:
               if (!data->refspecs)
                       continue;
I had it in my previous series but removed it.
I'll reroll.
-- 
Felipe Contreras

← back to recent threads