lördagen den 10 maj 2008 15.00.37 skrev Florian Koeberle: > +class AddRuleListFactory { > + /* > + * The add command of git 1.5.2.5 behaves a little bit stange: "git add > + * a/\*z" adds the file "a/b/xyz" but "git add a/x\*" does not. > + * > + * The first is parsed as pattern "*z" for whole directory tree "a". The > + * second is parsed as an path. > + * What do *you* do? > + */ > + > + private static List<String> getRelativePath(File projectDirectory, File file) > + throws PathNotInProjectDirectoryException, IOException { > + File currentFile = file.getCanonicalFile(); > + final LinkedList<String> relativePath = new LinkedList<String>(); > + while (!currentFile.equals(projectDirectory)) { > + relativePath.addFirst(currentFile.getName()); > + currentFile = currentFile.getParentFile(); > + if (currentFile == null) { > + throw new PathNotInProjectDirectoryException(); > + } > + } > + return relativePath; > + } Would be nice to have this logic in a utility class. -- robin -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html