aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2014-03-12 12:38:13 -0700
committerShawn Pearce <spearce@spearce.org>2014-03-12 16:06:08 -0700
commited3879e38964c8d41068c1171161bad2be0d3500 (patch)
tree58ad7ff29ba2d4917ba4fd5032853cdcdadeb3a6 /org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java
parentba0f89b4211fd57fe52120ec9a7c3cbaadbadd3b (diff)
downloadjgit-ed3879e38964c8d41068c1171161bad2be0d3500.tar.gz
jgit-ed3879e38964c8d41068c1171161bad2be0d3500.zip
Reject mixed case .git on Mac OS in ObjectChecker
Most Mac OS X systems use a case insensitive HFS+ volume. Like Windows ".git" and ".GIT" are the same path and can confuse a Git program into expecting a repository where one does not exist. Change-Id: Iec6ce9e6c2872f8b0850cc6aec023fa0fcb05ae4
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java
index 260a643e66..dd430024b0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java
@@ -100,6 +100,7 @@ public class ObjectChecker {
private boolean allowZeroMode;
private boolean windows;
+ private boolean macosx;
/**
* Enable accepting leading zero mode in tree entries.
@@ -133,6 +134,21 @@ public class ObjectChecker {
}
/**
+ * Restrict trees to only names legal on Mac OS X platforms.
+ * <p>
+ * Rejects any mixed case forms of reserved names ({@code .git})
+ * for users working on HFS+ in case-insensitive (default) mode.
+ *
+ * @param mac true if Mac OS X name checking should be performed.
+ * @return {@code this}.
+ * @since 3.4
+ */
+ public ObjectChecker setSafeForMacOS(boolean mac) {
+ macosx = mac;
+ return this;
+ }
+
+ /**
* Check an object for parsing errors.
*
* @param objType
@@ -491,7 +507,7 @@ public class ObjectChecker {
}
private boolean isDotGit(byte[] buf, int p) {
- if (windows)
+ if (windows || macosx)
return toLower(buf[p]) == 'g'
&& toLower(buf[p + 1]) == 'i'
&& toLower(buf[p + 2]) == 't';