diff mbox series

[v5,03/15] git-p4: select P4 binary by operating-system

Message ID e425ccc10fbc1f5e135eb59ffc84626f9d0ae4ff.1575740863.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series git-p4.py: Cast byte strings to unicode strings in python3 | expand

Commit Message

Linus Arver via GitGitGadget Dec. 7, 2019, 5:47 p.m. UTC
From: Ben Keene <seraphire@gmail.com>

The original code unconditionally used "p4" as the binary filename.

Depending on the version of Git and Python installed, the perforce
program (p4) may not resolve on Windows without the program extension.

Check the operating system (platform.system) and if it is reporting that
it is Windows, use the full filename of "p4.exe" instead of "p4"

This change is Python 2 and Python 3 compatible.

Signed-off-by: Ben Keene <seraphire@gmail.com>
---
 git-p4.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Junio C Hamano Dec. 9, 2019, 7:47 p.m. UTC | #1
"Ben Keene via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Ben Keene <seraphire@gmail.com>
>
> The original code unconditionally used "p4" as the binary filename.
>
> Depending on the version of Git and Python installed, the perforce
> program (p4) may not resolve on Windows without the program extension.
>
> Check the operating system (platform.system) and if it is reporting that
> it is Windows, use the full filename of "p4.exe" instead of "p4"
>
> This change is Python 2 and Python 3 compatible.
>
> Signed-off-by: Ben Keene <seraphire@gmail.com>
> ---
>  git-p4.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Makes sense.  Ack from somebody on Windows (not required but would
be nice to have)?

> diff --git a/git-p4.py b/git-p4.py
> index 60c73b6a37..65e926758c 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -75,7 +75,10 @@ def p4_build_cmd(cmd):
>      location. It means that hooking into the environment, or other configuration
>      can be done more easily.
>      """
> -    real_cmd = ["p4"]
> +    if (platform.system() == "Windows"):
> +        real_cmd = ["p4.exe"]
> +    else:
> +        real_cmd = ["p4"]
>  
>      user = gitConfig("git-p4.user")
>      if len(user) > 0:
diff mbox series

Patch

diff --git a/git-p4.py b/git-p4.py
index 60c73b6a37..65e926758c 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -75,7 +75,10 @@  def p4_build_cmd(cmd):
     location. It means that hooking into the environment, or other configuration
     can be done more easily.
     """
-    real_cmd = ["p4"]
+    if (platform.system() == "Windows"):
+        real_cmd = ["p4.exe"]
+    else:
+        real_cmd = ["p4"]
 
     user = gitConfig("git-p4.user")
     if len(user) > 0: