threads / patch / 33884

v2transport-helper: check if the dry-run is supported

Subject: [PATCH v2] transport-helper: check if the dry-run is supported

## tl;dr

5 messages between May 21, 2013 and May 22, 2013. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Felipe Contreras· May 21, 2013, 01:32 UTC · lore

Certain remote-helpers (the ones with 'export') would try to push regardless.

Obviously this is not what the user wants.

Also, add a check for the 'dry-run' option, so remote-helpers can implement it.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 transport-helper.c | 5 +++++
 1 file changed, 5 insertions(+)
Show changes to transport-helper.c +5 −0
diff --git a/transport-helper.c b/transport-helper.c
index 522d791..c8c39fc 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -789,6 +789,11 @@ static int push_refs_with_export(struct transport *transport,
 	struct string_list revlist_args = STRING_LIST_INIT_NODUP;
 	struct strbuf buf = STRBUF_INIT;
 
+	if (flags & TRANSPORT_PUSH_DRY_RUN) {
+		if (set_helper_option(transport, "dry-run", "true") != 0)
+			die("helper %s does not support dry-run", data->name);
+	}
+
 	helper = get_helper(transport);
 
 	write_constant(helper->in, "export\n");
-- 
1.8.3.rc3.1.gf11a2b7.dirty
Junio C Hamano· May 21, 2013, 16:55 UTC · re: Felipe Contreras · lore

Re: [PATCH v2] transport-helper: check if the dry-run is supported

Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 7 quoted lines
> Certain remote-helpers (the ones with 'export') would try to push
> regardless.
>
> Obviously this is not what the user wants.
>
> Also, add a check for the 'dry-run' option, so remote-helpers can
> implement it.

This sounds like a good thing to do. Perhaps the refspec mapping can be handled the same way as a backend feature so that you do not have to unconditionally disable it in the other patch.

Will queue both but not for 1.8.3.
Show 22 quoted lines
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  transport-helper.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/transport-helper.c b/transport-helper.c
> index 522d791..c8c39fc 100644
> --- a/transport-helper.c
> +++ b/transport-helper.c
> @@ -789,6 +789,11 @@ static int push_refs_with_export(struct transport *transport,
>  	struct string_list revlist_args = STRING_LIST_INIT_NODUP;
>  	struct strbuf buf = STRBUF_INIT;
>  
> +	if (flags & TRANSPORT_PUSH_DRY_RUN) {
> +		if (set_helper_option(transport, "dry-run", "true") != 0)
> +			die("helper %s does not support dry-run", data->name);
> +	}
> +
>  	helper = get_helper(transport);
>  
>  	write_constant(helper->in, "export\n");
Felipe Contreras· May 21, 2013, 21:14 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] transport-helper: check if the dry-run is supported

On Tue, May 21, 2013 at 11:55 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> Certain remote-helpers (the ones with 'export') would try to push
>> regardless.
>>
>> Obviously this is not what the user wants.
>>
>> Also, add a check for the 'dry-run' option, so remote-helpers can
>> implement it.
>
> This sounds like a good thing to do.  Perhaps the refspec mapping
> can be handled the same way as a backend feature so that you do not
> have to unconditionally disable it in the other patch.

With my patch the remote helper doesn't need to know about the refspec handling at all, it just works magically.

-- 
Felipe Contreras
Junio C Hamano· May 22, 2013, 00:47 UTC · re: Felipe Contreras · lore

Re: [PATCH v2] transport-helper: check if the dry-run is supported

Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 8 quoted lines
> On Tue, May 21, 2013 at 11:55 AM, Junio C Hamano <gitster@pobox.com> wrote:
>
>> This sounds like a good thing to do.  Perhaps the refspec mapping
>> can be handled the same way as a backend feature so that you do not
>> have to unconditionally disable it in the other patch.
>
> With my patch the remote helper doesn't need to know about the refspec
> handling at all, it just works magically.

The consumers of "git fast-export" do not need to know how to flip refspecs when consuming output from "git fast-export", because you taught "git fast-export" to do the mapping.

But doesn't that coin have a flip side? When somebody else (not git) generates a fast-import stream, because these consumers are not prepared to flip refspecs, they cannot rename while importing. All the producers have to be taught to do the ref mapping.

I do not know if this matters in real life, and even if it did, in the eventual ideal world, both importers and exporters would learn to do so. So I do not think what you did in your patch is a bad design in that sense. It is a half step in the right direction.

I however found it somewhat ugly that the interface to specify set of refs to traverse history to find the set of objects to export stays the same as before, and the ref-mapping arguments are bolted on to the machinery, without having any relationship between them. The user is free to tell it to export only 'next', while telling it to map 'master' to 'trunk', for example.

This is an external interface that is exposed to any users of "git fast-export", so if we go that route, we would have to keep that interface working forever, even when later somebody else wants to add an interface that only requires ref-mapping arguments (and infer what is exported from the left hand side of the refspecs).

That part is what I found is less than ideal in the patch.
Felipe Contreras· May 22, 2013, 03:07 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] transport-helper: check if the dry-run is supported

On Tue, May 21, 2013 at 7:47 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 19 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Tue, May 21, 2013 at 11:55 AM, Junio C Hamano <gitster@pobox.com> wrote:
>>
>>> This sounds like a good thing to do.  Perhaps the refspec mapping
>>> can be handled the same way as a backend feature so that you do not
>>> have to unconditionally disable it in the other patch.
>>
>> With my patch the remote helper doesn't need to know about the refspec
>> handling at all, it just works magically.
>
> The consumers of "git fast-export" do not need to know how to flip
> refspecs when consuming output from "git fast-export", because you
> taught "git fast-export" to do the mapping.
>
> But doesn't that coin have a flip side?  When somebody else (not
> git) generates a fast-import stream, because these consumers are not
> prepared to flip refspecs, they cannot rename while importing.  All
> the producers have to be taught to do the ref mapping.
Not true. There can be an intermediary in between.
> I do not know if this matters in real life, and even if it did, in
> the eventual ideal world, both importers and exporters would learn
> to do so.
No. Only one side *needs* to learn that.
> So I do not think what you did in your patch is a bad
> design in that sense.  It is a half step in the right direction.
What is the other step, and how would that benefit anyone?
Show 12 quoted lines
> I however found it somewhat ugly that the interface to specify set
> of refs to traverse history to find the set of objects to export
> stays the same as before, and the ref-mapping arguments are bolted
> on to the machinery, without having any relationship between them.
> The user is free to tell it to export only 'next', while telling it
> to map 'master' to 'trunk', for example.
>
> This is an external interface that is exposed to any users of "git
> fast-export", so if we go that route, we would have to keep that
> interface working forever, even when later somebody else wants to
> add an interface that only requires ref-mapping arguments (and infer
> what is exported from the left hand side of the refspecs).

Not true. We don't *have* to keep anything forever, we are free to decide anything we want, and live with the consequences.

If a better approach is found, we can remove this interface in v2.0, or v3.0, or even v10.0.

Why are we shooting ourselves in the foot in the meantime? We already have something that works perfectly fine.

Now, I specifically asked if such an interface would make sense, because there are too many warts, and I did not receive a satisfactory answer in my opinion. I will explore this interface once more, but I never received any positive feedback from yours that we indeed want to teach 'fast-export' to parse refspecs, it's just that the interface to do so was not ideal; you explicitly said you thought it made more sense on the other side; the receiver.

-- 
Felipe Contreras

← back to recent threads