Skip to content

Commit

Permalink
Added general variable git-p4.binary and added a default for windows …
Browse files Browse the repository at this point in the history
…of 'P4.EXE'

Signed-off-by: Ben Keene <seraphire@gmail.com>
  • Loading branch information
seraphire committed Nov 13, 2019
1 parent 0bca930 commit 98bae92
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Documentation/git-p4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
14 changes: 13 additions & 1 deletion git-p4.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import zlib
import ctypes
import errno
import os.path
from os import path

# support basestring in python3
try:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 98bae92

Please sign in to comment.