Fix common path "calculation" from logs of multiple branches. Need to use min instead of max for prev/cur to avoid out-of-bounds string access. Also treat "i" as index of the last match instead of a length because in case of a complete match of the two strings i was off by one.
Fix common path "calculation" from logs of multiple branches. Need to use min instead of max for prev/cur to avoid out-of-bounds string access. Also treat "i" as index of the last match instead of a length because in case of a complete match of the two strings i was off by one. Signed-off-by: Simon Hausmann <shausman@trolltech.com>
Simon Hausmann committed
Jun 7, 2007 at 09:37 UTC
583e170706f5d69770d0de220286f8f0f73667f3
1 file changed
+3
-2
contrib/fast-import/git-p4
+3
-2
@@ -1059,11 +1059,12 @@ class P4Sync(Command):
1059
else:
1060
paths = []
1061
for (prev, cur) in zip(self.previousDepotPaths, depotPaths):
1062
- for i in range(0, max(len(cur), len(prev))):
1062
+ for i in range(0, min(len(cur), len(prev))):
1063
if cur[i] <> prev[i]:
1064
+ i = i - 1
1065
break
1066
1066
- paths.append (cur[:i])
1067
+ paths.append (cur[:i + 1])
1068
1069
self.previousDepotPaths = paths
1070