1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-04 03:06:13 +02:00

git-p4: add config to retry p4 commands; retry 3 times by default

P4 commands can fail due to random network issues. P4 users can counter
these issues by using a retry flag supported by all p4 commands [1].

Add an integer Git config value `git-p4.retries` to define the number of
retries for all p4 invocations. If the config is not defined then set
the default retry count to 3.

[1] https://www.perforce.com/perforce/doc.current/manuals/cmdref/global.options.html

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Reviewed-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Lars Schneider 2016-12-04 15:03:11 +01:00 committed by Junio C Hamano
parent 454cb6bd52
commit 89a6ecc55b
2 changed files with 9 additions and 0 deletions

View File

@ -467,6 +467,10 @@ git-p4.client::
Client specified as an option to all p4 commands, with
'-c <client>', including the client spec.
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.
Clone and sync variables
~~~~~~~~~~~~~~~~~~~~~~~~
git-p4.syncFromOrigin::

View File

@ -78,6 +78,11 @@ def p4_build_cmd(cmd):
if len(client) > 0:
real_cmd += ["-c", client]
retries = gitConfigInt("git-p4.retries")
if retries is None:
# Perform 3 retries by default
retries = 3
real_cmd += ["-r", str(retries)]
if isinstance(cmd,basestring):
real_cmd = ' '.join(real_cmd) + ' ' + cmd