aboutsummaryrefslogtreecommitdiffstats
path: root/git-p4.py
diff options
context:
space:
mode:
authorMazo, Andrey <amazo@checkvideo.com>2019-04-01 18:02:32 +0000
committerJunio C Hamano <gitster@pobox.com>2019-04-02 11:25:41 +0900
commita2bee10ad9ed4dc45c1f7da76f01388925b80212 (patch)
tree810beb7f27c96c7fe252f595dbc94db538d046a3 /git-p4.py
parentd6045201fcec7bd9738fea4daf9d176d8df9f5ba (diff)
downloadgit-a2bee10ad9ed4dc45c1f7da76f01388925b80212.tar.gz
git-p4: don't exclude other files with same prefix
Make sure not to exclude files unintentionally if exclude paths are specified without a trailing /. I.e., don't exclude "//depot/file_dont_exclude" if run with "-//depot/file". Do this by ensuring that paths without a trailing "/" are only matched completely. Also, abort path search on the first match as a micro-optimization. Signed-off-by: Andrey Mazo <amazo@checkvideo.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-p4.py')
-rwxr-xr-xgit-p4.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/git-p4.py b/git-p4.py
index 7edcbad055..c47bd8c4d8 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2623,18 +2623,25 @@ class P4Sync(Command, P4UserMap):
if self.verbose:
print("checkpoint finished: " + out)
+ def isPathWanted(self, path):
+ for p in self.cloneExclude:
+ if p.endswith("/"):
+ if p4PathStartsWith(path, p):
+ return False
+ # "-//depot/file1" without a trailing "/" should only exclude "file1", but not "file111" or "file1_dir/file2"
+ elif path.lower() == p.lower():
+ return False
+ for p in self.depotPaths:
+ if p4PathStartsWith(path, p):
+ return True
+ return False
+
def extractFilesFromCommit(self, commit, shelved=False, shelved_cl = 0):
files = []
fnum = 0
while "depotFile%s" % fnum in commit:
path = commit["depotFile%s" % fnum]
-
- if [p for p in self.cloneExclude
- if p4PathStartsWith(path, p)]:
- found = False
- else:
- found = [p for p in self.depotPaths
- if p4PathStartsWith(path, p)]
+ found = self.isPathWanted(path)
if not found:
fnum = fnum + 1
continue