private void createNewRepository(final List<RemoteRefUpdate> updates) throws TransportException { try { final String ref = "ref: " + pickHEAD(updates) + "\n"; final byte[] bytes = Constants.encode(ref); dest.writeFile(ROOT_DIR + Constants.HEAD, bytes); } catch (IOException e) { throw new TransportException(uri, "cannot create HEAD", e); } try { final String config = "[core]\n" + "\trepositoryformatversion = 0\n"; final byte[] bytes = Constants.encode(config); dest.writeFile(ROOT_DIR + "config", bytes); } catch (IOException e) { throw new TransportException(uri, "cannot create config", e); } }
public void testMatch_TooSmall() { final byte[] src = Constants.encodeASCII("author "); final byte[] dst = Constants.encodeASCII("author autho"); assertTrue(RawParseUtils.match(dst, src.length + 1, src) < 0); }
public void testMatch_NotEqual() { final byte[] src = Constants.encodeASCII(" differ\n"); final byte[] dst = Constants.encodeASCII("a differ\n"); assertTrue(RawParseUtils.match(dst, 2, src) < 0); }
public void testMatch_Prefix() { final byte[] src = Constants.encodeASCII("author "); final byte[] dst = Constants.encodeASCII("author A. U. Thor"); assertTrue(RawParseUtils.match(dst, 0, src) == src.length); assertTrue(RawParseUtils.match(dst, 1, src) < 0); }
public void testMatch_Equal() { final byte[] src = Constants.encodeASCII(" differ\n"); final byte[] dst = Constants.encodeASCII("foo differ\n"); assertTrue(RawParseUtils.match(dst, 3, src) == 3 + src.length); }