aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java9
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java14
3 files changed, 17 insertions, 10 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
index 13d546f2b7..3f4478a771 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
@@ -53,6 +53,7 @@ import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.eclipse.jgit.util.FileUtils.pathToString;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -855,14 +856,6 @@ public class ConfigTest {
assertEquals("bar", parsed.getString("other", null, "more"));
}
- public static String pathToString(File file) {
- final String path = file.getPath();
- if (SystemReader.getInstance().isWindows()) {
- return path.replace('\\', '/');
- }
- return path;
- }
-
private static void assertReadLong(long exp) throws ConfigInvalidException {
assertReadLong(exp, String.valueOf(exp));
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java
index 2134e1b8dc..eb7bc4f7e7 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.storage.file;
+import static org.eclipse.jgit.util.FileUtils.pathToString;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -52,7 +53,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.eclipse.jgit.lib.ConfigTest;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.IO;
@@ -164,7 +164,7 @@ public class FileBasedConfigTest {
final File includedFile = createFile(CONTENT1.getBytes());
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
bos.write("[include]\npath=".getBytes());
- bos.write(ConfigTest.pathToString(includedFile).getBytes());
+ bos.write(pathToString(includedFile).getBytes());
final File file = createFile(bos.toByteArray());
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
index 98c991ae25..2b6c8c94df 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
@@ -869,4 +869,18 @@ public class FileUtils {
}
}
+ /**
+ * Convert a path to String, replacing separators as necessary.
+ *
+ * @param file
+ * @return file's path as a String
+ * @since 4.10
+ */
+ public static String pathToString(File file) {
+ final String path = file.getPath();
+ if (SystemReader.getInstance().isWindows()) {
+ return path.replace('\\', '/');
+ }
+ return path;
+ }
}