git-p4: do not pass '-r 0' to p4 commands
authorIgor Kushnir <igorkuo@gmail.com>
Thu, 29 Dec 2016 10:22:23 +0000 (12:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 29 Dec 2016 21:54:05 +0000 (13:54 -0800)
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>
Acked-by: Lars Schneider <larsxschneider@gmail.com>
Reviewed-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-p4.txt
git-p4.py
index 656587248cc466143589742b093ae8cb43030263..5352cae4b48948926b042ee5ef59ba1b148ba462 100644 (file)
@@ -470,6 +470,8 @@ 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.
+       Set the value to 0 to disable retries or if your p4 version
+       does not support retries (pre 2012.2).
 
 Clone and sync variables
 ~~~~~~~~~~~~~~~~~~~~~~~~
index 2422178210f344131a783edd3c1d5acbd0229512..2d39d10122caa2e5a5c6814200639912d87f1f68 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -82,7 +82,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