git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1] git-p4: add config to retry p4 commands; retry 3 times by default

From
larsxschneider@gmail.com <larsxschneider@gmail.com>
Date
Dec 4, 2016, 14:03 UTC
Message-ID
<20161204140311.26269-1-larsxschneider@gmail.com>
From: Lars Schneider <lars.schneider@autodesk.com>

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>
---
Notes:
    Base Commit: 454cb6b (v2.11.0)
    Diff on Web: https://github.com/git/git/compare/454cb6b...larsxschneider:654c727
    Checkout:    git fetch https://github.com/larsxschneider/git git-p4/retries-v1 && git checkout 654c727
 Documentation/git-p4.txt | 4 ++++
 git-p4.py                | 5 +++++
 2 files changed, 9 insertions(+)
diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index c83aaf39c3..656587248c 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -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::
diff --git a/git-p4.py b/git-p4.py
index fd5ca52462..2422178210 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -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
-- 
2.11.0
Next: Lars Schneider
Message 1 of 4 in “git-p4: add config to retry p4 commands; retry 3 times by default”
  1. git-p4: add config to retry p4 commands; retry 3 times by defaultlarsxschneider@gmail.com, Dec 4, 2016
  2. Lars SchneiderDec 5, 2016
  3. Luke DiamandDec 5, 2016
  4. Ori RawlingsDec 5, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.