# [PATCH v2] git-p4: do not pass '-r 0' to p4 commands

3 messages from 2016-12-29 to 2017-01-04. Participants: Igor Kushnir, Ori Rawlings, Luke Diamand.
Thread: https://gitlist.dev/t/44789

## Igor Kushnir, 2016-12-29 10:22

Subject: [PATCH v2] git-p4: do not pass '-r 0' to p4 commands
Message-ID: <20161229102223.6028-1-igorkuo@gmail.com>
URL: https://gitlist.dev/e/20161229102223.6028-1-igorkuo%40gmail.com

```
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 | 2 ++
 git-p4.py                | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index bae862ddc..7436c64a9 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -479,6 +479,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
 ~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/git-p4.py b/git-p4.py
index 22e3f57e7..7bda915bd 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


```

## Ori Rawlings, 2017-01-03 20:02

Subject: Re: [PATCH v2] git-p4: do not pass '-r 0' to p4 commands
Message-ID: <CAPv0x+PoQ+3ERAc_0gviYP5j1-Zg=X+B1OSC6vDKatqUhFtAag@mail.gmail.com>
URL: https://gitlist.dev/e/CAPv0x%2BPoQ%2B3ERAc_0gviYP5j1-Zg%3DX%2BB1OSC6vDKatqUhFtAag%40mail.gmail.com
In-Reply-To: <20161229102223.6028-1-igorkuo@gmail.com>

```
Looks good to me.


Ori Rawlings

```

## Luke Diamand, 2017-01-04 09:09

Subject: Re: [PATCH v2] git-p4: do not pass '-r 0' to p4 commands
Message-ID: <CAE5ih7_D4F=vic+Dud-QwTushVmW200W8C+T6H+igH+WoSz6rA@mail.gmail.com>
URL: https://gitlist.dev/e/CAE5ih7_D4F%3Dvic%2BDud-QwTushVmW200W8C%2BT6H%2BigH%2BWoSz6rA%40mail.gmail.com
In-Reply-To: <CAPv0x+PoQ+3ERAc_0gviYP5j1-Zg=X+B1OSC6vDKatqUhFtAag@mail.gmail.com>

```
On 3 January 2017 at 20:02, Ori Rawlings <orirawlings@gmail.com> wrote:
> Looks good to me.

And me.



>
>
> Ori Rawlings

```
