git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-p4: do not pass '-r 0' to p4 commands
@ 2016-12-29  9:05 Igor Kushnir
  2016-12-29  9:20 ` Luke Diamand
  2016-12-29 10:02 ` Lars Schneider
  0 siblings, 2 replies; 3+ messages in thread
From: Igor Kushnir @ 2016-12-29  9:05 UTC (permalink / raw)
  To: git; +Cc: Lars Schneider, Luke Diamand, Ori Rawlings, Igor Kushnir

git-p4 crashes when used with a very old p4 client version
that does not support the '-r <number>' option in its commands.

Allow making git-p4 work with old p4 clients by setting git-p4.retries to 0.

Alternatively git-p4.retries could be made opt-in.
But since only very old, barely maintained p4 versions don't support
the '-r' option, the setting-retries-to-0 workaround would do.

The "-r retries" option is present in Perforce 2012.2 Command Reference,
but absent from Perforce 2012.1 Command Reference.

Signed-off-by: Igor Kushnir <igorkuo@gmail.com>
---
 Documentation/git-p4.txt | 1 +
 git-p4.py                | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index bae862ddc..f4f1be5be 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -479,6 +479,7 @@ git-p4.client::
 git-p4.retries::
 	Specifies the number of times to retry a p4 command (notably,
 	'p4 sync') if the network times out. The default value is 3.
+	'-r 0' is not passed to p4 commands if this option is set to 0.
 
 Clone and sync variables
 ~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/git-p4.py b/git-p4.py
index 22e3f57e7..e5a9e1cce 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -83,7 +83,9 @@ def p4_build_cmd(cmd):
     if retries is None:
         # Perform 3 retries by default
         retries = 3
-    real_cmd += ["-r", str(retries)]
+    if retries != 0:
+        # Provide a way to not pass this option by setting git-p4.retries to 0
+        real_cmd += ["-r", str(retries)]
 
     if isinstance(cmd,basestring):
         real_cmd = ' '.join(real_cmd) + ' ' + cmd
-- 
2.11.0


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

* Re: [PATCH] git-p4: do not pass '-r 0' to p4 commands
  2016-12-29  9:05 [PATCH] git-p4: do not pass '-r 0' to p4 commands Igor Kushnir
@ 2016-12-29  9:20 ` Luke Diamand
  2016-12-29 10:02 ` Lars Schneider
  1 sibling, 0 replies; 3+ messages in thread
From: Luke Diamand @ 2016-12-29  9:20 UTC (permalink / raw)
  To: Igor Kushnir; +Cc: Git Users, Lars Schneider, Ori Rawlings

On 29 December 2016 at 09:05, Igor Kushnir <igorkuo@gmail.com> wrote:
> git-p4 crashes when used with a very old p4 client version
> that does not support the '-r <number>' option in its commands.
>
> Allow making git-p4 work with old p4 clients by setting git-p4.retries to 0.
>
> Alternatively git-p4.retries could be made opt-in.
> But since only very old, barely maintained p4 versions don't support
> the '-r' option, the setting-retries-to-0 workaround would do.
>
> The "-r retries" option is present in Perforce 2012.2 Command Reference,
> but absent from Perforce 2012.1 Command Reference.

That looks like a good fix, thanks.

I feel sad for anyone still using 2012.1.

Luke


>
> Signed-off-by: Igor Kushnir <igorkuo@gmail.com>
> ---
>  Documentation/git-p4.txt | 1 +
>  git-p4.py                | 4 +++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
> index bae862ddc..f4f1be5be 100644
> --- a/Documentation/git-p4.txt
> +++ b/Documentation/git-p4.txt
> @@ -479,6 +479,7 @@ git-p4.client::
>  git-p4.retries::
>         Specifies the number of times to retry a p4 command (notably,
>         'p4 sync') if the network times out. The default value is 3.
> +       '-r 0' is not passed to p4 commands if this option is set to 0.
>
>  Clone and sync variables
>  ~~~~~~~~~~~~~~~~~~~~~~~~
> diff --git a/git-p4.py b/git-p4.py
> index 22e3f57e7..e5a9e1cce 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -83,7 +83,9 @@ def p4_build_cmd(cmd):
>      if retries is None:
>          # Perform 3 retries by default
>          retries = 3
> -    real_cmd += ["-r", str(retries)]
> +    if retries != 0:
> +        # Provide a way to not pass this option by setting git-p4.retries to 0
> +        real_cmd += ["-r", str(retries)]
>
>      if isinstance(cmd,basestring):
>          real_cmd = ' '.join(real_cmd) + ' ' + cmd
> --
> 2.11.0
>

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

* Re: [PATCH] git-p4: do not pass '-r 0' to p4 commands
  2016-12-29  9:05 [PATCH] git-p4: do not pass '-r 0' to p4 commands Igor Kushnir
  2016-12-29  9:20 ` Luke Diamand
@ 2016-12-29 10:02 ` Lars Schneider
  1 sibling, 0 replies; 3+ messages in thread
From: Lars Schneider @ 2016-12-29 10:02 UTC (permalink / raw)
  To: Igor Kushnir; +Cc: git, Luke Diamand, Ori Rawlings


> On 29 Dec 2016, at 10:05, Igor Kushnir <igorkuo@gmail.com> wrote:
> 
> git-p4 crashes when used with a very old p4 client version
> that does not support the '-r <number>' option in its commands.
> 
> Allow making git-p4 work with old p4 clients by setting git-p4.retries to 0.
> 
> Alternatively git-p4.retries could be made opt-in.
> But since only very old, barely maintained p4 versions don't support
> the '-r' option, the setting-retries-to-0 workaround would do.
> 
> The "-r retries" option is present in Perforce 2012.2 Command Reference,
> but absent from Perforce 2012.1 Command Reference.

Thanks for this workaround!


> Signed-off-by: Igor Kushnir <igorkuo@gmail.com>
> ---
> Documentation/git-p4.txt | 1 +
> git-p4.py                | 4 +++-
> 2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
> index bae862ddc..f4f1be5be 100644
> --- a/Documentation/git-p4.txt
> +++ b/Documentation/git-p4.txt
> @@ -479,6 +479,7 @@ git-p4.client::
> git-p4.retries::
> 	Specifies the number of times to retry a p4 command (notably,
> 	'p4 sync') if the network times out. The default value is 3.
> +	'-r 0' is not passed to p4 commands if this option is set to 0.

At this point in the docs we have never talked about the "-r" flag and I
would argue it is an "implementation detail". Therefore, I would prefer
something like: "Set the value to 0 if want to disable retries or if 
your p4 version does not support retries (pre 2012.2)."


> 
> Clone and sync variables
> ~~~~~~~~~~~~~~~~~~~~~~~~
> diff --git a/git-p4.py b/git-p4.py
> index 22e3f57e7..e5a9e1cce 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -83,7 +83,9 @@ def p4_build_cmd(cmd):
>     if retries is None:
>         # Perform 3 retries by default
>         retries = 3
> -    real_cmd += ["-r", str(retries)]
> +    if retries != 0:

How about "retries > 0"?


> +        # Provide a way to not pass this option by setting git-p4.retries to 0
> +        real_cmd += ["-r", str(retries)]
> 
>     if isinstance(cmd,basestring):
>         real_cmd = ' '.join(real_cmd) + ' ' + cmd
> -- 
> 2.11.0
> 


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

end of thread, other threads:[~2016-12-29 10:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-29  9:05 [PATCH] git-p4: do not pass '-r 0' to p4 commands Igor Kushnir
2016-12-29  9:20 ` Luke Diamand
2016-12-29 10:02 ` Lars Schneider

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).