Skip to contentSkip to conversation

git-p4: do not pass '-r 0' to p4 commands

PATCH Superseded Igor Kushnir 3 participants 3 messages Dec 29, 2016 Documentation

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-p4: do not pass '-r 0' to p4 commands

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.

---
 Documentation/git-p4.txt | 1 +
 git-p4.py                | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
Documentation/git-p4.txt +1 -0
index bae862ddc..f4f1be5be 100644
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~
git-p4.py +3 -1
index 22e3f57e7..e5a9e1cce 100755
@@ -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
Signature · 1 line
2.11.0
#1 lore raw
Quoted 11 lines · 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.

That looks like a good fix, thanks.

I feel sad for anyone still using 2012.1.

Luke

Quoted 37 lines
---
 Documentation/git-p4.txt | 1 +
 git-p4.py                | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
Documentation/git-p4.txt +1 -0
index bae862ddc..f4f1be5be 100644
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~
git-p4.py +3 -2
index 22e3f57e7..e5a9e1cce 100755
@@ -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

#2 lore raw
In reply to Igor Kushnir
Quoted 6 lines · 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.

Quoted 8 lines

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!

Quoted 14 lines

---
Documentation/git-p4.txt | 1 +
git-p4.py | 4 +++-

2 files changed, 4 insertions(+), 1 deletion(-)
Documentation/git-p4.txt +0 -0
index bae862ddc..f4f1be5be 100644
@@ -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.

Documentation/git-p4.txt git-p4.client:: · line 482

Quoted 1 line
Documentation/git-p4.txt +1 -0
+	'-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)."

git-p4.py def p4_build_cmd(cmd): · line 86

Quoted 13 lines

Clone and sync variables
~~~~~~~~~~~~~~~~~~~~~~~~

git-p4.py +1 -1
index 22e3f57e7..e5a9e1cce 100755
@@ -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"?

Quoted 8 lines
git-p4.py +2 -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
Signature · 1 line
2.11.0