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

[PATCH v2 2/3] Added general variable git-p4.binary and added a default for windows of 'P4.EXE'

From
Ben Keene via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 15, 2019, 14:42 UTC
Message-ID
<98bae92fda9ca01d01b2e9fb70b04b00470e7bec.1573828978.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.465.v2.git.1573828978.gitgitgadget@gmail.com>
From: Ben Keene <seraphire@gmail.com>
Signed-off-by: Ben Keene <seraphire@gmail.com>
---
 Documentation/git-p4.txt |  5 +++++
 git-p4.py                | 14 +++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index 3494a1db3e..e206e69250 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -547,6 +547,11 @@ git-p4.retries::
 	Set the value to 0 to disable retries or if your p4 version
 	does not support retries (pre 2012.2).
 
+git-p4.binary::
+	Specifies the p4 executable used by git-p4 to process commands.
+	The default value for Windows is `p4.exe` and for all other
+	systems the default is `p4`. 
+
 Clone and sync variables
 ~~~~~~~~~~~~~~~~~~~~~~~~
 git-p4.syncFromOrigin::
diff --git a/git-p4.py b/git-p4.py
index 6e8b3a26cd..160d966ee1 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -26,6 +26,8 @@
 import zlib
 import ctypes
 import errno
+import os.path
+from os import path
 
 # support basestring in python3
 try:
@@ -85,7 +87,17 @@ def p4_build_cmd(cmd):
     location. It means that hooking into the environment, or other configuration
     can be done more easily.
     """
-    real_cmd = ["p4"]
+    # Look for the P4 binary
+    p4bin = gitConfig("git-p4.binary")
+    real_cmd = []
+    if p4bin != "":
+        if path.exists(p4bin):
+            real_cmd = [p4bin]
+    if real_cmd == []:
+        if (platform.system() == "Windows"):
+            real_cmd = ["p4.exe"]    
+        else:
+            real_cmd = ["p4"]
 
     user = gitConfig("git-p4.user")
     if len(user) > 0:
-- 
gitgitgadget
Previous: Ben Keene via GitGitGadgetNext: Junio C Hamano
Message 13 of 17 in “Feature: New Variable git-p4.binary”
  1. 0/2 Feature: New Variable git-p4.binaryBen Keene via GitGitGadget, Nov 13, 2019
  2. 2/2 Added general variable git-p4.binary and added a default for windows of 'P4.EXE'Ben Keene via GitGitGadget, Nov 13, 2019
  3. 1/2 Cast byte strings to unicode strings in python3Ben Keene via GitGitGadget, Nov 13, 2019
  4. Junio C HamanoNov 14, 2019
  5. Luke DiamandNov 14, 2019
  6. Ben KeeneNov 14, 2019
  7. Luke DiamandNov 15, 2019
  8. 0/3 Feature: New Variable git-p4.p4programBen Keene via GitGitGadget, Nov 15, 2019
  9. 1/3 Cast byte strings to unicode strings in python3Ben Keene via GitGitGadget, Nov 15, 2019
  10. Junio C HamanoNov 16, 2019
  11. Junio C HamanoNov 16, 2019
  12. 3/3 Changed the name of the parameter from git-p4.binary to git-p4.p4programBen Keene via GitGitGadget, Nov 15, 2019
  13. 2/3 Added general variable git-p4.binary and added a default for windows of 'P4.EXE'Ben Keene via GitGitGadget, Nov 15, 2019
  14. Junio C HamanoNov 16, 2019
  15. Junio C HamanoNov 16, 2019
  16. Junio C HamanoNov 18, 2019
  17. Ben KeeneDec 3, 2019

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.