* [PATCH] Teach git-p4 to ignore case in perforce filenames if configured.
@ 2011-02-08 11:11 Tor Arvid Lund
2011-02-11 12:22 ` Pete Wyckoff
0 siblings, 1 reply; 2+ messages in thread
From: Tor Arvid Lund @ 2011-02-08 11:11 UTC (permalink / raw)
To: git; +Cc: Tor Arvid Lund
When files are added to perforce, the path to that file has whichever case
configuration that exists on the machine of the user who added the file.
What does that mean? It means that when Alice adds a file
//depot/DirA/FileA.txt
... and Bob adds:
//depot/dirA/FileB.txt
... we may or may not get a problem. If a user sets the config variable
git-p4.ignorecase to "true", we will consider //depot/DirA and //depot/dirA
to be the same directory.
---
contrib/fast-import/git-p4 | 22 ++++++++++++++--------
contrib/fast-import/git-p4.txt | 12 ++++++++++++
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 04ce7e3..ca3cea0 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -452,6 +452,12 @@ def p4ChangesForPaths(depotPaths, changeRange):
changelist.sort()
return changelist
+def p4PathStartsWith(path, prefix):
+ ignorecase = gitConfig("git-p4.ignorecase").lower()
+ if ignorecase in ["true", "yes", "1"]:
+ return path.lower().startswith(prefix.lower())
+ return path.startswith(prefix)
+
class Command:
def __init__(self):
self.usage = "usage: %prog [options]"
@@ -599,7 +605,7 @@ class P4Submit(Command):
lastTab = path.rfind("\t")
if lastTab != -1:
path = path[:lastTab]
- if not path.startswith(self.depotPath):
+ if not p4PathStartsWith(path, self.depotPath):
continue
else:
inFilesSection = False
@@ -891,11 +897,11 @@ class P4Sync(Command):
path = commit["depotFile%s" % fnum]
if [p for p in self.cloneExclude
- if path.startswith (p)]:
+ if p4PathStartsWith(path, p)]:
found = False
else:
found = [p for p in self.depotPaths
- if path.startswith (p)]
+ if p4PathStartsWith(path, p)]
if not found:
fnum = fnum + 1
continue
@@ -914,7 +920,7 @@ class P4Sync(Command):
prefixes = [re.sub("^(//[^/]+/).*", r'\1', prefixes[0])]
for p in prefixes:
- if path.startswith(p):
+ if p4PathStartsWith(path, p):
path = path[len(p):]
return path
@@ -925,7 +931,7 @@ class P4Sync(Command):
while commit.has_key("depotFile%s" % fnum):
path = commit["depotFile%s" % fnum]
found = [p for p in self.depotPaths
- if path.startswith (p)]
+ if p4PathStartsWith(path, p)]
if not found:
fnum = fnum + 1
continue
@@ -1031,7 +1037,7 @@ class P4Sync(Command):
for f in files:
includeFile = True
for val in self.clientSpecDirs:
- if f['path'].startswith(val[0]):
+ if p4PathStartsWith(f['path'], val[0]):
if val[1] <= 0:
includeFile = False
break
@@ -1077,7 +1083,7 @@ class P4Sync(Command):
# create a commit.
new_files = []
for f in files:
- if [p for p in branchPrefixes if f['path'].startswith(p)]:
+ if [p for p in branchPrefixes if p4PathStartsWith(f['path'], p)]:
new_files.append (f)
else:
sys.stderr.write("Ignoring file outside of prefix: %s\n" % path)
@@ -1241,7 +1247,7 @@ class P4Sync(Command):
source = paths[0]
destination = paths[1]
## HACK
- if source.startswith(self.depotPaths[0]) and destination.startswith(self.depotPaths[0]):
+ if p4PathStartsWith(source, self.depotPaths[0]) and p4PathStartsWith(destination, self.depotPaths[0]):
source = source[len(self.depotPaths[0]):-4]
destination = destination[len(self.depotPaths[0]):-4]
diff --git a/contrib/fast-import/git-p4.txt b/contrib/fast-import/git-p4.txt
index 49b3359..bf7904a 100644
--- a/contrib/fast-import/git-p4.txt
+++ b/contrib/fast-import/git-p4.txt
@@ -191,6 +191,18 @@ git-p4.useclientspec
git config [--global] git-p4.useclientspec false
+git-p4.ignorecase
+
+If this variable is set to 'true' (or 'yes' or '1'), perforce paths like:
+
+//depot/Path/
+//depot/path/
+//dePoT/PATH/
+
+will all be considered to be the same directory.
+
+ git config [--global] git-p4.ignorecase false
+
Implementation Details...
=========================
--
1.7.3.1.68.g06779.dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Teach git-p4 to ignore case in perforce filenames if configured.
2011-02-08 11:11 [PATCH] Teach git-p4 to ignore case in perforce filenames if configured Tor Arvid Lund
@ 2011-02-11 12:22 ` Pete Wyckoff
0 siblings, 0 replies; 2+ messages in thread
From: Pete Wyckoff @ 2011-02-11 12:22 UTC (permalink / raw)
To: Tor Arvid Lund; +Cc: git
torarvid@gmail.com wrote on Tue, 08 Feb 2011 12:11 +0100:
> When files are added to perforce, the path to that file has whichever case
> configuration that exists on the machine of the user who added the file.
> What does that mean? It means that when Alice adds a file
>
> //depot/DirA/FileA.txt
>
> ... and Bob adds:
>
> //depot/dirA/FileB.txt
>
> ... we may or may not get a problem. If a user sets the config variable
> git-p4.ignorecase to "true", we will consider //depot/DirA and //depot/dirA
> to be the same directory.
That's horrid. Seriously? A and B can both generate mixed-case
paths, but with a different mix?
If it's all just cast to lower, does it make sense to use
core.ignorecase for this?
> ---
> contrib/fast-import/git-p4 | 22 ++++++++++++++--------
> contrib/fast-import/git-p4.txt | 12 ++++++++++++
> 2 files changed, 26 insertions(+), 8 deletions(-)
>
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index 04ce7e3..ca3cea0 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -452,6 +452,12 @@ def p4ChangesForPaths(depotPaths, changeRange):
> changelist.sort()
> return changelist
>
> +def p4PathStartsWith(path, prefix):
> + ignorecase = gitConfig("git-p4.ignorecase").lower()
> + if ignorecase in ["true", "yes", "1"]:
> + return path.lower().startswith(prefix.lower())
> + return path.startswith(prefix)
git config --bool will always return "true" or "false" (or "").
I think we should start looking for "true" that rather than
checking for all four possible versions of true (+ "on").
Can you put a comment in this function explaining the mixed-case
problem? When reading the code, it's easier than searching
through the doc to learn about it.
Rest of patch looks fine.
-- Pete
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-02-11 12:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-08 11:11 [PATCH] Teach git-p4 to ignore case in perforce filenames if configured Tor Arvid Lund
2011-02-11 12:22 ` Pete Wyckoff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).