[PATCH] git-p4: Fix git-p4.mapUser on Windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: George Vanburgh <gvanburgh@xxxxxxxxxxxxx>

When running git-p4 on Windows, with multiple git-p4.mapUser entries in
git config - no user mappings are applied to the generated repository.

Reproduction Steps:

1. Add multiple git-p4.mapUser entries to git config on a Windows
   machine
2. Attempt to clone a p4 repository

None of the user mappings will be applied.

This issue is caused by the fact that gitConfigList,
uses split(os.linesep) to convert the output of
git config --get-all into a list.

On Windows, os.linesep is equal to '\r\n' - however git.exe
returns configuration with a line seperator of '\n'. This leads to
the list returned by gitConfigList containing only one element - which
contains the full output of git config --get-all in string form. This
causes problems for the code introduced to getUserMapFromPerforceServer
in 10d08a1.

This issue should be caught by the test introduced in 10d08a1, and
would require running on Windows to reproduce. When running inside
MinGW/Cygwin, however, os.linesep correctly returns '\n', and everything
works as expected.

The simplest fix for this issue would be to convert the line split logic
inside gitConfigList to use splitlines(), which splits on any standard
line delimiter. However, this function was only introduced in Python
2.7, and would mean a bump in the minimum required version of Python
required to run git-p4. The alternative fix, implemented here, is to use
'\n' as a delimiter, which git.exe appears to output consistently on
Windows anyway.

Signed-off-by: George Vanburgh <gvanburgh@xxxxxxxxxxxxx>
---
 git-p4.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-p4.py b/git-p4.py
index f427bf6..c134a58 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -656,7 +656,7 @@ def gitConfigInt(key):
 def gitConfigList(key):
     if not _gitConfig.has_key(key):
         s = read_pipe(["git", "config", "--get-all", key], ignore_error=True)
-        _gitConfig[key] = s.strip().split(os.linesep)
+        _gitConfig[key] = s.strip().split("\n")
         if _gitConfig[key] == ['']:
             _gitConfig[key] = []
     return _gitConfig[key]

--
https://github.com/git/git/pull/319



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]