DirCacheCheckout is generating names for temporary files. It was not checking the length of this filenames. It may happen that a generated filename is longer than 255 chars which causes problems on certain platforms. Make sure that filenames for temporary files do not exceed 255 chars. Bug: 508823 Change-Id: I9475c04351ce3faebdc6ad40ea4faa3c326815f4tags/v4.8.0.201705170830-rc1
@@ -1672,6 +1672,20 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testLongFilename() throws Exception { | |||
char[] bytes = new char[253]; | |||
Arrays.fill(bytes, 'f'); | |||
String longFileName = new String(bytes); | |||
// 1 | |||
doit(mkmap(longFileName, "a"), mkmap(longFileName, "b"), | |||
mkmap(longFileName, "a")); | |||
writeTrashFile(longFileName, "a"); | |||
checkout(); | |||
assertNoConflicts(); | |||
assertUpdated(longFileName); | |||
} | |||
public void assertWorkDir(Map<String, String> i) | |||
throws CorruptObjectException, | |||
IOException { |
@@ -1299,8 +1299,13 @@ public class DirCacheCheckout { | |||
return; | |||
} | |||
String name = f.getName(); | |||
if (name.length() > 200) { | |||
name = name.substring(0, 200); | |||
} | |||
File tmpFile = File.createTempFile( | |||
"._" + f.getName(), null, parentDir); //$NON-NLS-1$ | |||
"._" + name, null, parentDir); //$NON-NLS-1$ | |||
EolStreamType nonNullEolStreamType; | |||
if (checkoutMetadata.eolStreamType != null) { | |||
nonNullEolStreamType = checkoutMetadata.eolStreamType; |