### Question:
GitPathResolver { String relativize(String absoluteNativePath) { if (!absoluteNativePath.startsWith(repositoryRootDir)) { throw new RuntimeException("Cannot relativize path '" + absoluteNativePath + "' to directory '" + repositoryRootDir + "'"); } String result = absoluteNativePath.substring(repositoryRootDir.length()); if (nativePathSeparator != CANONICAL_PATH_SEPARATOR) { result = result.replace(nativePathSeparator, CANONICAL_PATH_SEPARATOR); } return result; } GitPathResolver(String repositoryRootDir);   GitPathResolver(String repositoryRootDir, char nativePathSeparator); String relativize(File path);  }### Answer:
@Test public void relativize() throws Exception { assertRelativized("/path/to/my/git/repo", '/', "/path/to/my/git/repo/dir/file.txt", "dir/file.txt"); assertRelativized("/path/to/my/git/repo/", '/', "/path/to/my/git/repo/dir/file.txt", "dir/file.txt"); assertFail("/path/to/my/git/repo/", '/', "/path/to/other/git/repo/dir/file.txt"); assertRelativized("c:\\path\\to\\my\\repo", '\\', "c:\\path\\to\\my\\repo\\dir\\file.txt", "dir/file.txt"); assertRelativized("c:\\path\\to\\my\\repo\\", '\\', "c:\\path\\to\\my\\repo\\dir\\file.txt", "dir/file.txt"); assertRelativized("\\\\path\\to\\my\\repo", '\\', "\\\\path\\to\\my\\repo\\dir\\file.txt", "dir/file.txt"); assertRelativized("\\\\path\\to\\my\\repo\\", '\\', "\\\\path\\to\\my\\repo\\dir\\file.txt", "dir/file.txt"); assertFail("c:\\path\\to\\my\\repo\\", '\\', "c:\\path\\to\\other\\repo\\dir\\file.txt"); }