git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] transport-helper: check if the dry-run is supported
@ 2013-05-21  1:32 Felipe Contreras
  2013-05-21 16:55 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Felipe Contreras @ 2013-05-21  1:32 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Sverre Rabbelier, Jeff King, Felipe Contreras

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(+)

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] transport-helper: check if the dry-run is supported
  2013-05-21  1:32 [PATCH v2] transport-helper: check if the dry-run is supported Felipe Contreras
@ 2013-05-21 16:55 ` Junio C Hamano
  2013-05-21 21:14   ` Felipe Contreras
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2013-05-21 16:55 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git, Sverre Rabbelier, Jeff King

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.

Will queue both but not for 1.8.3.

>
> 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");

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] transport-helper: check if the dry-run is supported
  2013-05-21 16:55 ` Junio C Hamano
@ 2013-05-21 21:14   ` Felipe Contreras
  2013-05-22  0:47     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Felipe Contreras @ 2013-05-21 21:14 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Sverre Rabbelier, Jeff King

On Tue, May 21, 2013 at 11:55 AM, Junio C Hamano <gitster@pobox.com> wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] transport-helper: check if the dry-run is supported
  2013-05-21 21:14   ` Felipe Contreras
@ 2013-05-22  0:47     ` Junio C Hamano
  2013-05-22  3:07       ` Felipe Contreras
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2013-05-22  0:47 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git, Sverre Rabbelier, Jeff King

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.

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] transport-helper: check if the dry-run is supported
  2013-05-22  0:47     ` Junio C Hamano
@ 2013-05-22  3:07       ` Felipe Contreras
  0 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2013-05-22  3:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Sverre Rabbelier, Jeff King

On Tue, May 21, 2013 at 7:47 PM, Junio C Hamano <gitster@pobox.com> wrote:
> 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?

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-22  3:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21  1:32 [PATCH v2] transport-helper: check if the dry-run is supported Felipe Contreras
2013-05-21 16:55 ` Junio C Hamano
2013-05-21 21:14   ` Felipe Contreras
2013-05-22  0:47     ` Junio C Hamano
2013-05-22  3:07       ` Felipe Contreras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).