Declare essentially static methods as static
Change-Id: I83ca25fb569c0dbc36eb374d5437fcf2b65a6f68
This commit is contained in:
parent
04bc9b3ddc
commit
a57dd1c164
|
@ -104,7 +104,7 @@ public ReceivePack create(final HttpServletRequest req, final Repository db)
|
||||||
throw new ServiceNotAuthorizedException();
|
throw new ServiceNotAuthorizedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReceivePack createFor(final HttpServletRequest req,
|
private static ReceivePack createFor(final HttpServletRequest req,
|
||||||
final Repository db, final String user) {
|
final Repository db, final String user) {
|
||||||
final ReceivePack rp = new ReceivePack(db);
|
final ReceivePack rp = new ReceivePack(db);
|
||||||
rp.setRefLogIdent(toPersonIdent(req, user));
|
rp.setRefLogIdent(toPersonIdent(req, user));
|
||||||
|
|
|
@ -81,7 +81,7 @@ public void testUnreasonableNames() throws ServiceNotEnabledException {
|
||||||
assertUnreasonable("C:/windows");
|
assertUnreasonable("C:/windows");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertUnreasonable(String name)
|
private static void assertUnreasonable(String name)
|
||||||
throws ServiceNotEnabledException {
|
throws ServiceNotEnabledException {
|
||||||
FileResolver<RepositoryResolver> r = new FileResolver<RepositoryResolver>(
|
FileResolver<RepositoryResolver> r = new FileResolver<RepositoryResolver>(
|
||||||
new File("."), false);
|
new File("."), false);
|
||||||
|
|
|
@ -176,7 +176,7 @@ public void testPush_UnpackError_TruncatedPack() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void packHeader(ByteArrayOutputStream tinyPack, int cnt)
|
private static void packHeader(ByteArrayOutputStream tinyPack, int cnt)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final byte[] hdr = new byte[8];
|
final byte[] hdr = new byte[8];
|
||||||
NB.encodeInt32(hdr, 0, 2);
|
NB.encodeInt32(hdr, 0, 2);
|
||||||
|
|
|
@ -156,7 +156,7 @@ private Set<CQ> queryOneProject(Project project) throws IOException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BufferedReader reader(HttpURLConnection conn)
|
private static BufferedReader reader(HttpURLConnection conn)
|
||||||
throws UnsupportedEncodingException, IOException {
|
throws UnsupportedEncodingException, IOException {
|
||||||
String encoding = conn.getContentEncoding();
|
String encoding = conn.getContentEncoding();
|
||||||
InputStream in = conn.getInputStream();
|
InputStream in = conn.getInputStream();
|
||||||
|
@ -206,7 +206,7 @@ private void login() throws MalformedURLException,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readFully(HttpURLConnection c) throws IOException {
|
private static String readFully(HttpURLConnection c) throws IOException {
|
||||||
String enc = c.getContentEncoding();
|
String enc = c.getContentEncoding();
|
||||||
Reader reader;
|
Reader reader;
|
||||||
if (enc != null) {
|
if (enc != null) {
|
||||||
|
@ -240,7 +240,7 @@ private HttpURLConnection open(URL url) throws ConnectException,
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCookie(URL url, String name, String value)
|
private static void setCookie(URL url, String name, String value)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Map<String, List<String>> cols = new HashMap<String, List<String>>();
|
Map<String, List<String>> cols = new HashMap<String, List<String>>();
|
||||||
cols.put("Set-Cookie", Collections.singletonList(name + "=" + value));
|
cols.put("Set-Cookie", Collections.singletonList(name + "=" + value));
|
||||||
|
@ -253,7 +253,7 @@ private void setCookie(URL url, String name, String value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CQ parseOneCQ(Map<String, String> row) {
|
private static CQ parseOneCQ(Map<String, String> row) {
|
||||||
long id = Long.parseLong(row.get("bug_id"));
|
long id = Long.parseLong(row.get("bug_id"));
|
||||||
String state = row.get("bug_severity");
|
String state = row.get("bug_severity");
|
||||||
String bug_status = row.get("bug_status");
|
String bug_status = row.get("bug_status");
|
||||||
|
|
|
@ -273,7 +273,7 @@ private void loadCommitters(Repository repo) throws IOException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date parseDate(SimpleDateFormat dt, String value)
|
private static Date parseDate(SimpleDateFormat dt, String value)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if ("NULL".equals(value) || "".equals(value) || value == null)
|
if ("NULL".equals(value) || "".equals(value) || value == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -524,7 +524,7 @@ private Element createConsumes(Project p) {
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateProjectType(Project p, Element project) {
|
private static void populateProjectType(Project p, Element project) {
|
||||||
required(project, "id", p.getID());
|
required(project, "id", p.getID());
|
||||||
required(project, "name", p.getName());
|
required(project, "name", p.getName());
|
||||||
optional(project, "comments", p.getComments());
|
optional(project, "comments", p.getComments());
|
||||||
|
@ -557,7 +557,7 @@ private Element createCQ(CQ cq) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String mapCQState(String state) {
|
private static String mapCQState(String state) {
|
||||||
// "approved" CQs shall be listed as "active" in the iplog
|
// "approved" CQs shall be listed as "active" in the iplog
|
||||||
if (state.equals("approved"))
|
if (state.equals("approved"))
|
||||||
return "active";
|
return "active";
|
||||||
|
@ -602,13 +602,13 @@ private Element createElement(String name) {
|
||||||
return doc.createElementNS(IPLOG_NS, IPLOG_PFX + name);
|
return doc.createElementNS(IPLOG_NS, IPLOG_PFX + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void required(Element r, String name, String value) {
|
private static void required(Element r, String name, String value) {
|
||||||
if (value == null)
|
if (value == null)
|
||||||
value = "";
|
value = "";
|
||||||
r.setAttribute(name, value);
|
r.setAttribute(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void optional(Element r, String name, String value) {
|
private static void optional(Element r, String name, String value) {
|
||||||
if (value != null && value.length() > 0)
|
if (value != null && value.length() > 0)
|
||||||
r.setAttribute(name, value);
|
r.setAttribute(name, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ void loadFrom(Config cfg) {
|
||||||
reviewUrl = cfg.getString(S_REVIEW, null, K_URL);
|
reviewUrl = cfg.getString(S_REVIEW, null, K_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Project> parseProjects(final Config cfg,
|
private static List<Project> parseProjects(final Config cfg,
|
||||||
final String sectionName) {
|
final String sectionName) {
|
||||||
final List<Project> dst = new ArrayList<Project>();
|
final List<Project> dst = new ArrayList<Project>();
|
||||||
for (String id : cfg.getSubsections(sectionName)) {
|
for (String id : cfg.getSubsections(sectionName)) {
|
||||||
|
|
|
@ -112,7 +112,7 @@ public void put(URI uri, Map<String, List<String>> responseHeaders)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String hostOf(URI uri) {
|
private static String hostOf(URI uri) {
|
||||||
StringBuilder key = new StringBuilder();
|
StringBuilder key = new StringBuilder();
|
||||||
key.append(uri.getScheme());
|
key.append(uri.getScheme());
|
||||||
key.append(':');
|
key.append(':');
|
||||||
|
|
|
@ -162,7 +162,7 @@ private void ceilTestDirectories(List<File> ceilings) {
|
||||||
mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY, makePath(ceilings));
|
mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY, makePath(ceilings));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makePath(List<?> objects) {
|
private static String makePath(List<?> objects) {
|
||||||
final StringBuilder stringBuilder = new StringBuilder();
|
final StringBuilder stringBuilder = new StringBuilder();
|
||||||
for (Object object : objects) {
|
for (Object object : objects) {
|
||||||
if (stringBuilder.length() > 0)
|
if (stringBuilder.length() > 0)
|
||||||
|
@ -303,7 +303,7 @@ public void addRepoToClose(Repository r) {
|
||||||
toClose.add(r);
|
toClose.add(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createUniqueTestFolderPrefix() {
|
private static String createUniqueTestFolderPrefix() {
|
||||||
return "test" + (System.currentTimeMillis() + "_" + (testCount++));
|
return "test" + (System.currentTimeMillis() + "_" + (testCount++));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -673,7 +673,7 @@ public void packAndPrune() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prunePacked(ObjectDirectory odb) throws IOException {
|
private static void prunePacked(ObjectDirectory odb) throws IOException {
|
||||||
for (PackFile p : odb.getPacks()) {
|
for (PackFile p : odb.getPacks()) {
|
||||||
for (MutableEntry e : p)
|
for (MutableEntry e : p)
|
||||||
FileUtils.delete(odb.fileFor(e.toObjectId()));
|
FileUtils.delete(odb.fileFor(e.toObjectId()));
|
||||||
|
|
|
@ -128,7 +128,8 @@ else if (0 <= cr)
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String longTypeOf(ObjectReader reader, final TrackingRefUpdate u) {
|
private static String longTypeOf(ObjectReader reader,
|
||||||
|
final TrackingRefUpdate u) {
|
||||||
final RefUpdate.Result r = u.getResult();
|
final RefUpdate.Result r = u.getResult();
|
||||||
if (r == RefUpdate.Result.LOCK_FAILURE)
|
if (r == RefUpdate.Result.LOCK_FAILURE)
|
||||||
return "[lock fail]";
|
return "[lock fail]";
|
||||||
|
@ -164,7 +165,7 @@ else if (u.getLocalName().startsWith(Constants.R_TAGS))
|
||||||
return "[" + r.name() + "]"; //$NON-NLS-1$//$NON-NLS-2$
|
return "[" + r.name() + "]"; //$NON-NLS-1$//$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
private String safeAbbreviate(ObjectReader reader, ObjectId id) {
|
private static String safeAbbreviate(ObjectReader reader, ObjectId id) {
|
||||||
try {
|
try {
|
||||||
return reader.abbreviate(id).name();
|
return reader.abbreviate(id).name();
|
||||||
} catch (IOException cannotAbbreviate) {
|
} catch (IOException cannotAbbreviate) {
|
||||||
|
|
|
@ -150,7 +150,7 @@ private FetchResult runFetch() throws URISyntaxException, IOException {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Ref guessHEAD(final FetchResult result) {
|
private static Ref guessHEAD(final FetchResult result) {
|
||||||
final Ref idHEAD = result.getAdvertisedRef(Constants.HEAD);
|
final Ref idHEAD = result.getAdvertisedRef(Constants.HEAD);
|
||||||
final List<Ref> availableRefs = new ArrayList<Ref>();
|
final List<Ref> availableRefs = new ArrayList<Ref>();
|
||||||
Ref head = null;
|
Ref head = null;
|
||||||
|
@ -201,4 +201,4 @@ private RevCommit parseCommit(final Ref branch)
|
||||||
}
|
}
|
||||||
return commit;
|
return commit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,8 @@ protected void run() throws Exception {
|
||||||
outw.println(MessageFormat.format(CLIText.get().listeningOn, d.getAddress()));
|
outw.println(MessageFormat.format(CLIText.get().listeningOn, d.getAddress()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private DaemonService service(final org.eclipse.jgit.transport.Daemon d,
|
private static DaemonService service(
|
||||||
|
final org.eclipse.jgit.transport.Daemon d,
|
||||||
final String n) {
|
final String n) {
|
||||||
final DaemonService svc = d.getService(n);
|
final DaemonService svc = d.getService(n);
|
||||||
if (svc == null)
|
if (svc == null)
|
||||||
|
|
|
@ -241,7 +241,7 @@ private void printRefUpdateResult(final ObjectReader reader,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String safeAbbreviate(ObjectReader reader, ObjectId id) {
|
private static String safeAbbreviate(ObjectReader reader, ObjectId id) {
|
||||||
try {
|
try {
|
||||||
return reader.abbreviate(id).name();
|
return reader.abbreviate(id).name();
|
||||||
} catch (IOException cannotAbbreviate) {
|
} catch (IOException cannotAbbreviate) {
|
||||||
|
|
|
@ -90,7 +90,7 @@ protected void run() throws Exception {
|
||||||
outw.println(BinaryDelta.format(delta));
|
outw.println(BinaryDelta.format(delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] getDelta(ObjectReader reader, RevObject obj)
|
private static byte[] getDelta(ObjectReader reader, RevObject obj)
|
||||||
throws IOException, MissingObjectException,
|
throws IOException, MissingObjectException,
|
||||||
StoredObjectRepresentationNotAvailableException {
|
StoredObjectRepresentationNotAvailableException {
|
||||||
ObjectReuseAsIs asis = (ObjectReuseAsIs) reader;
|
ObjectReuseAsIs asis = (ObjectReuseAsIs) reader;
|
||||||
|
|
|
@ -369,7 +369,8 @@ private void run(Repository db) throws Exception {
|
||||||
outw.flush();
|
outw.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testOne(Function fun, RawText txt, int[] elements, int cnt) {
|
private static void testOne(Function fun, RawText txt, int[] elements,
|
||||||
|
int cnt) {
|
||||||
final Hash cmp = fun.hash;
|
final Hash cmp = fun.hash;
|
||||||
final Fold fold = fun.fold;
|
final Fold fold = fun.fold;
|
||||||
|
|
||||||
|
|
|
@ -697,7 +697,7 @@ public boolean isCaseSensitive() {
|
||||||
assertEquals(FileMode.EXECUTABLE_FILE, walk.getFileMode(0));
|
assertEquals(FileMode.EXECUTABLE_FILE, walk.getFileMode(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private DirCacheEntry addEntryToBuilder(String path, File file,
|
private static DirCacheEntry addEntryToBuilder(String path, File file,
|
||||||
ObjectInserter newObjectInserter, DirCacheBuilder builder, int stage)
|
ObjectInserter newObjectInserter, DirCacheBuilder builder, int stage)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
FileInputStream inputStream = new FileInputStream(file);
|
FileInputStream inputStream = new FileInputStream(file);
|
||||||
|
|
|
@ -178,7 +178,7 @@ public void testModifyZ() throws Exception {
|
||||||
b.getString(0, b.size(), false));
|
b.getString(0, b.size(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] readFile(final String patchFile) throws IOException {
|
private static byte[] readFile(final String patchFile) throws IOException {
|
||||||
final InputStream in = DiffFormatterReflowTest.class
|
final InputStream in = DiffFormatterReflowTest.class
|
||||||
.getResourceAsStream(patchFile);
|
.getResourceAsStream(patchFile);
|
||||||
if (in == null) {
|
if (in == null) {
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
*/
|
*/
|
||||||
public class BlameCommandTest extends RepositoryTestCase {
|
public class BlameCommandTest extends RepositoryTestCase {
|
||||||
|
|
||||||
private String join(String... lines) {
|
private static String join(String... lines) {
|
||||||
StringBuilder joined = new StringBuilder();
|
StringBuilder joined = new StringBuilder();
|
||||||
for (String line : lines)
|
for (String line : lines)
|
||||||
joined.append(line).append('\n');
|
joined.append(line).append('\n');
|
||||||
|
|
|
@ -1267,7 +1267,7 @@ private void prepare_f3_f2_14(final Git git, final int state,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String expected_f3_head(final int state) {
|
private static String expected_f3_head(final int state) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -1280,7 +1280,7 @@ private String expected_f3_head(final int state) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String expected_f3_idx(final int state) {
|
private static String expected_f3_idx(final int state) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0:
|
case 0:
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -1294,7 +1294,8 @@ private String expected_f3_idx(final int state) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHead(final Git git, final String path) throws Exception {
|
static private String getHead(final Git git, final String path)
|
||||||
|
throws Exception {
|
||||||
try {
|
try {
|
||||||
final Repository repo = git.getRepository();
|
final Repository repo = git.getRepository();
|
||||||
final ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}");
|
final ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}");
|
||||||
|
|
|
@ -228,7 +228,7 @@ public void testAddHugeFile() throws Exception {
|
||||||
assertEquals(0, status.getUntracked().size());
|
assertEquals(0, status.getUntracked().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertCollectionEquals(Collection<?> asList,
|
private static void assertCollectionEquals(Collection<?> asList,
|
||||||
Collection<?> added) {
|
Collection<?> added) {
|
||||||
assertEquals(asList.toString(), added.toString());
|
assertEquals(asList.toString(), added.toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1328,17 +1328,17 @@ public void testSquashMergeConflict() throws Exception {
|
||||||
assertEquals(StatusCommandTest.set("file2"), stat.getConflicting());
|
assertEquals(StatusCommandTest.set("file2"), stat.getConflicting());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setExecutable(Git git, String path, boolean executable) {
|
private static void setExecutable(Git git, String path, boolean executable) {
|
||||||
FS.DETECTED.setExecute(
|
FS.DETECTED.setExecute(
|
||||||
new File(git.getRepository().getWorkTree(), path), executable);
|
new File(git.getRepository().getWorkTree(), path), executable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canExecute(Git git, String path) {
|
private static boolean canExecute(Git git, String path) {
|
||||||
return FS.DETECTED.canExecute(new File(git.getRepository()
|
return FS.DETECTED.canExecute(new File(git.getRepository()
|
||||||
.getWorkTree(), path));
|
.getWorkTree(), path));
|
||||||
}
|
}
|
||||||
|
|
||||||
private RevCommit addAllAndCommit(final Git git) throws Exception {
|
private static RevCommit addAllAndCommit(final Git git) throws Exception {
|
||||||
git.add().addFilepattern(".").call();
|
git.add().addFilepattern(".").call();
|
||||||
return git.commit().setMessage("message").call();
|
return git.commit().setMessage("message").call();
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,8 @@ public void setUp() throws Exception {
|
||||||
assertFileContentsEqual(targetFile, "Hello world");
|
assertFileContentsEqual(targetFile, "Hello world");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeToFile(File actFile, String string) throws IOException {
|
private static void writeToFile(File actFile, String string)
|
||||||
|
throws IOException {
|
||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
try {
|
try {
|
||||||
fos = new FileOutputStream(actFile);
|
fos = new FileOutputStream(actFile);
|
||||||
|
@ -280,7 +281,7 @@ private void writeToFile(File actFile, String string) throws IOException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertFileContentsEqual(File actFile, String string)
|
private static void assertFileContentsEqual(File actFile, String string)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
|
|
|
@ -340,7 +340,8 @@ public void setUp() throws Exception {
|
||||||
assertFileContentsEqual(targetFile, "Hello world");
|
assertFileContentsEqual(targetFile, "Hello world");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeToFile(File actFile, String string) throws IOException {
|
private static void writeToFile(File actFile, String string)
|
||||||
|
throws IOException {
|
||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
try {
|
try {
|
||||||
fos = new FileOutputStream(actFile);
|
fos = new FileOutputStream(actFile);
|
||||||
|
@ -352,7 +353,7 @@ private void writeToFile(File actFile, String string) throws IOException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertFileContentsEqual(File actFile, String string)
|
private static void assertFileContentsEqual(File actFile, String string)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
|
|
|
@ -288,7 +288,8 @@ public void testDiff() throws Exception {
|
||||||
assertEquals(expected.toString(), actual);
|
assertEquals(expected.toString(), actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makeDiffHeader(String pathA, String pathB, ObjectId aId,
|
private static String makeDiffHeader(String pathA, String pathB,
|
||||||
|
ObjectId aId,
|
||||||
ObjectId bId) {
|
ObjectId bId) {
|
||||||
String a = aId.abbreviate(8).name();
|
String a = aId.abbreviate(8).name();
|
||||||
String b = bId.abbreviate(8).name();
|
String b = bId.abbreviate(8).name();
|
||||||
|
@ -298,7 +299,7 @@ private String makeDiffHeader(String pathA, String pathB, ObjectId aId,
|
||||||
"+++ b/" + pathB + "\n";
|
"+++ b/" + pathB + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makeDiffHeaderModeChange(String pathA, String pathB,
|
private static String makeDiffHeaderModeChange(String pathA, String pathB,
|
||||||
ObjectId aId, ObjectId bId, String modeA, String modeB) {
|
ObjectId aId, ObjectId bId, String modeA, String modeB) {
|
||||||
String a = aId.abbreviate(8).name();
|
String a = aId.abbreviate(8).name();
|
||||||
String b = bId.abbreviate(8).name();
|
String b = bId.abbreviate(8).name();
|
||||||
|
|
|
@ -227,11 +227,11 @@ private static void assertV3TreeEntry(int indexPosition, String path,
|
||||||
assertEquals(intentToAdd, entry.isIntentToAdd());
|
assertEquals(intentToAdd, entry.isIntentToAdd());
|
||||||
}
|
}
|
||||||
|
|
||||||
private File pathOf(final String name) {
|
private static File pathOf(final String name) {
|
||||||
return JGitTestUtil.getTestResourceFile(name);
|
return JGitTestUtil.getTestResourceFile(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, CGitIndexRecord> readLsFiles() throws Exception {
|
private static Map<String, CGitIndexRecord> readLsFiles() throws Exception {
|
||||||
final LinkedHashMap<String, CGitIndexRecord> r = new LinkedHashMap<String, CGitIndexRecord>();
|
final LinkedHashMap<String, CGitIndexRecord> r = new LinkedHashMap<String, CGitIndexRecord>();
|
||||||
final BufferedReader br = new BufferedReader(new InputStreamReader(
|
final BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||||
new FileInputStream(pathOf("gitgit.lsfiles")), "UTF-8"));
|
new FileInputStream(pathOf("gitgit.lsfiles")), "UTF-8"));
|
||||||
|
@ -247,7 +247,7 @@ private Map<String, CGitIndexRecord> readLsFiles() throws Exception {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, CGitLsTreeRecord> readLsTree() throws Exception {
|
private static Map<String, CGitLsTreeRecord> readLsTree() throws Exception {
|
||||||
final LinkedHashMap<String, CGitLsTreeRecord> r = new LinkedHashMap<String, CGitLsTreeRecord>();
|
final LinkedHashMap<String, CGitLsTreeRecord> r = new LinkedHashMap<String, CGitLsTreeRecord>();
|
||||||
final BufferedReader br = new BufferedReader(new InputStreamReader(
|
final BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||||
new FileInputStream(pathOf("gitgit.lstree")), "UTF-8"));
|
new FileInputStream(pathOf("gitgit.lstree")), "UTF-8"));
|
||||||
|
|
|
@ -176,7 +176,7 @@ public void testCopyMetaDataWithoutStage() {
|
||||||
copyMetaDataHelper(true);
|
copyMetaDataHelper(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyMetaDataHelper(final boolean keepStage) {
|
private static void copyMetaDataHelper(final boolean keepStage) {
|
||||||
DirCacheEntry e = new DirCacheEntry("some/path", DirCacheEntry.STAGE_2);
|
DirCacheEntry e = new DirCacheEntry("some/path", DirCacheEntry.STAGE_2);
|
||||||
e.setAssumeValid(false);
|
e.setAssumeValid(false);
|
||||||
e.setCreationTime(2L);
|
e.setCreationTime(2L);
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
public class FileNameMatcherTest {
|
public class FileNameMatcherTest {
|
||||||
|
|
||||||
private void assertMatch(final String pattern, final String input,
|
private static void assertMatch(final String pattern, final String input,
|
||||||
final boolean matchExpected, final boolean appendCanMatchExpected)
|
final boolean matchExpected, final boolean appendCanMatchExpected)
|
||||||
throws InvalidPatternException {
|
throws InvalidPatternException {
|
||||||
final FileNameMatcher matcher = new FileNameMatcher(pattern, null);
|
final FileNameMatcher matcher = new FileNameMatcher(pattern, null);
|
||||||
|
@ -63,7 +63,8 @@ private void assertMatch(final String pattern, final String input,
|
||||||
assertEquals(appendCanMatchExpected, matcher.canAppendMatch());
|
assertEquals(appendCanMatchExpected, matcher.canAppendMatch());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertFileNameMatch(final String pattern, final String input,
|
private static void assertFileNameMatch(final String pattern,
|
||||||
|
final String input,
|
||||||
final char excludedCharacter, final boolean matchExpected,
|
final char excludedCharacter, final boolean matchExpected,
|
||||||
final boolean appendCanMatchExpected)
|
final boolean appendCanMatchExpected)
|
||||||
throws InvalidPatternException {
|
throws InvalidPatternException {
|
||||||
|
|
|
@ -378,7 +378,7 @@ public void assertNotMatched(String pattern, String target) {
|
||||||
* @return
|
* @return
|
||||||
* Result of {@link IgnoreRule#isMatch(String, boolean)}
|
* Result of {@link IgnoreRule#isMatch(String, boolean)}
|
||||||
*/
|
*/
|
||||||
private boolean match(String pattern, String target) {
|
private static boolean match(String pattern, String target) {
|
||||||
IgnoreRule r = new IgnoreRule(pattern);
|
IgnoreRule r = new IgnoreRule(pattern);
|
||||||
//If speed of this test is ever an issue, we can use a presetRule field
|
//If speed of this test is ever an issue, we can use a presetRule field
|
||||||
//to avoid recompiling a pattern each time.
|
//to avoid recompiling a pattern each time.
|
||||||
|
|
|
@ -144,7 +144,7 @@ public void getTrackingBranchShouldHandleNormalCaseForRemoteTrackingBranch() {
|
||||||
branchConfig.getTrackingBranch());
|
branchConfig.getTrackingBranch());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Config parse(final String content) {
|
private static Config parse(final String content) {
|
||||||
final Config c = new Config(null);
|
final Config c = new Config(null);
|
||||||
try {
|
try {
|
||||||
c.fromText(content);
|
c.fromText(content);
|
||||||
|
|
|
@ -465,17 +465,18 @@ public void testQuotingForSubSectionNames() {
|
||||||
assertEquals(result, config.toText());
|
assertEquals(result, config.toText());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertReadLong(long exp) throws ConfigInvalidException {
|
private static void assertReadLong(long exp) throws ConfigInvalidException {
|
||||||
assertReadLong(exp, String.valueOf(exp));
|
assertReadLong(exp, String.valueOf(exp));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertReadLong(long exp, String act)
|
private static void assertReadLong(long exp, String act)
|
||||||
throws ConfigInvalidException {
|
throws ConfigInvalidException {
|
||||||
final Config c = parse("[s]\na = " + act + "\n");
|
final Config c = parse("[s]\na = " + act + "\n");
|
||||||
assertEquals(exp, c.getLong("s", null, "a", 0L));
|
assertEquals(exp, c.getLong("s", null, "a", 0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Config parse(final String content) throws ConfigInvalidException {
|
private static Config parse(final String content)
|
||||||
|
throws ConfigInvalidException {
|
||||||
final Config c = new Config(null);
|
final Config c = new Config(null);
|
||||||
c.fromText(content);
|
c.fromText(content);
|
||||||
return c;
|
return c;
|
||||||
|
|
|
@ -61,7 +61,8 @@ public class T0002_TreeTest extends SampleDataRepositoryTestCase {
|
||||||
private static final ObjectId SOME_FAKE_ID = ObjectId.fromString(
|
private static final ObjectId SOME_FAKE_ID = ObjectId.fromString(
|
||||||
"0123456789abcdef0123456789abcdef01234567");
|
"0123456789abcdef0123456789abcdef01234567");
|
||||||
|
|
||||||
private int compareNamesUsingSpecialCompare(String a,String b) throws UnsupportedEncodingException {
|
private static int compareNamesUsingSpecialCompare(String a, String b)
|
||||||
|
throws UnsupportedEncodingException {
|
||||||
char lasta = '\0';
|
char lasta = '\0';
|
||||||
byte[] abytes;
|
byte[] abytes;
|
||||||
if (a.length() > 0 && a.charAt(a.length()-1) == '/') {
|
if (a.length() > 0 && a.charAt(a.length()-1) == '/') {
|
||||||
|
|
|
@ -183,12 +183,13 @@ public void testRevert() throws Exception {
|
||||||
assertFalse(tw.next());
|
assertFalse(tw.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertCorrectId(final DirCache treeT, final TreeWalk tw) {
|
private static void assertCorrectId(final DirCache treeT, final TreeWalk tw) {
|
||||||
assertEquals(treeT.getEntry(tw.getPathString()).getObjectId(), tw
|
assertEquals(treeT.getEntry(tw.getPathString()).getObjectId(), tw
|
||||||
.getObjectId(0));
|
.getObjectId(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ObjectId commit(final ObjectInserter odi, final DirCache treeB,
|
private static ObjectId commit(final ObjectInserter odi,
|
||||||
|
final DirCache treeB,
|
||||||
final ObjectId[] parentIds) throws Exception {
|
final ObjectId[] parentIds) throws Exception {
|
||||||
final CommitBuilder c = new CommitBuilder();
|
final CommitBuilder c = new CommitBuilder();
|
||||||
c.setTreeId(treeB.writeTree(odi));
|
c.setTreeId(treeB.writeTree(odi));
|
||||||
|
|
|
@ -373,12 +373,13 @@ public void testTrivialTwoWay_rightDFconflict2() throws Exception {
|
||||||
assertFalse(merge);
|
assertFalse(merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertCorrectId(final DirCache treeT, final TreeWalk tw) {
|
private static void assertCorrectId(final DirCache treeT, final TreeWalk tw) {
|
||||||
assertEquals(treeT.getEntry(tw.getPathString()).getObjectId(), tw
|
assertEquals(treeT.getEntry(tw.getPathString()).getObjectId(), tw
|
||||||
.getObjectId(0));
|
.getObjectId(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ObjectId commit(final ObjectInserter odi, final DirCache treeB,
|
private static ObjectId commit(final ObjectInserter odi,
|
||||||
|
final DirCache treeB,
|
||||||
final ObjectId[] parentIds) throws Exception {
|
final ObjectId[] parentIds) throws Exception {
|
||||||
final CommitBuilder c = new CommitBuilder();
|
final CommitBuilder c = new CommitBuilder();
|
||||||
c.setTreeId(treeB.writeTree(odi));
|
c.setTreeId(treeB.writeTree(odi));
|
||||||
|
|
|
@ -68,7 +68,7 @@ public void tearDown() throws Exception {
|
||||||
FileUtils.delete(trash, FileUtils.RECURSIVE | FileUtils.SKIP_MISSING);
|
FileUtils.delete(trash, FileUtils.RECURSIVE | FileUtils.SKIP_MISSING);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitNextSec(File f) {
|
private static void waitNextSec(File f) {
|
||||||
long initialLastModified = f.lastModified();
|
long initialLastModified = f.lastModified();
|
||||||
do {
|
do {
|
||||||
f.setLastModified(System.currentTimeMillis());
|
f.setLastModified(System.currentTimeMillis());
|
||||||
|
@ -144,7 +144,7 @@ private File createFile(String string) throws IOException {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void append(File f, byte b) throws IOException {
|
private static void append(File f, byte b) throws IOException {
|
||||||
FileOutputStream os = new FileOutputStream(f, true);
|
FileOutputStream os = new FileOutputStream(f, true);
|
||||||
try {
|
try {
|
||||||
os.write(b);
|
os.write(b);
|
||||||
|
|
|
@ -303,14 +303,14 @@ public void testDelta_LargeObjectChain() throws Exception {
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] clone(int first, byte[] base) {
|
private static byte[] clone(int first, byte[] base) {
|
||||||
byte[] r = new byte[base.length];
|
byte[] r = new byte[base.length];
|
||||||
System.arraycopy(base, 1, r, 1, r.length - 1);
|
System.arraycopy(base, 1, r, 1, r.length - 1);
|
||||||
r[0] = (byte) first;
|
r[0] = (byte) first;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] delta(byte[] base, byte[] dest) throws IOException {
|
private static byte[] delta(byte[] base, byte[] dest) throws IOException {
|
||||||
ByteArrayOutputStream tmp = new ByteArrayOutputStream();
|
ByteArrayOutputStream tmp = new ByteArrayOutputStream();
|
||||||
DeltaEncoder de = new DeltaEncoder(tmp, base.length, dest.length);
|
DeltaEncoder de = new DeltaEncoder(tmp, base.length, dest.length);
|
||||||
de.insert(dest, 0, 1);
|
de.insert(dest, 0, 1);
|
||||||
|
@ -318,7 +318,7 @@ private byte[] delta(byte[] base, byte[] dest) throws IOException {
|
||||||
return tmp.toByteArray();
|
return tmp.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void packHeader(TemporaryBuffer.Heap pack, int cnt)
|
private static void packHeader(TemporaryBuffer.Heap pack, int cnt)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final byte[] hdr = new byte[8];
|
final byte[] hdr = new byte[8];
|
||||||
NB.encodeInt32(hdr, 0, 2);
|
NB.encodeInt32(hdr, 0, 2);
|
||||||
|
@ -327,7 +327,7 @@ private void packHeader(TemporaryBuffer.Heap pack, int cnt)
|
||||||
pack.write(hdr, 0, 8);
|
pack.write(hdr, 0, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void objectHeader(TemporaryBuffer.Heap pack, int type, int sz)
|
private static void objectHeader(TemporaryBuffer.Heap pack, int type, int sz)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
byte[] buf = new byte[8];
|
byte[] buf = new byte[8];
|
||||||
int nextLength = sz >>> 4;
|
int nextLength = sz >>> 4;
|
||||||
|
@ -342,7 +342,7 @@ private void objectHeader(TemporaryBuffer.Heap pack, int type, int sz)
|
||||||
pack.write(buf, 0, n);
|
pack.write(buf, 0, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deflate(TemporaryBuffer.Heap pack, final byte[] content)
|
private static void deflate(TemporaryBuffer.Heap pack, final byte[] content)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final Deflater deflater = new Deflater();
|
final Deflater deflater = new Deflater();
|
||||||
final byte[] buf = new byte[128];
|
final byte[] buf = new byte[128];
|
||||||
|
@ -356,7 +356,7 @@ private void deflate(TemporaryBuffer.Heap pack, final byte[] content)
|
||||||
deflater.end();
|
deflater.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void digest(TemporaryBuffer.Heap buf) throws IOException {
|
private static void digest(TemporaryBuffer.Heap buf) throws IOException {
|
||||||
MessageDigest md = Constants.newMessageDigest();
|
MessageDigest md = Constants.newMessageDigest();
|
||||||
md.update(buf.toByteArray());
|
md.update(buf.toByteArray());
|
||||||
buf.write(md.digest());
|
buf.write(md.digest());
|
||||||
|
|
|
@ -479,7 +479,7 @@ public void testExclude() throws Exception {
|
||||||
contentB.getId()));
|
contentB.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertContent(PackIndex pi, List<ObjectId> expected) {
|
private static void assertContent(PackIndex pi, List<ObjectId> expected) {
|
||||||
assertEquals("Pack index has wrong size.", expected.size(),
|
assertEquals("Pack index has wrong size.", expected.size(),
|
||||||
pi.getObjectCount());
|
pi.getObjectCount());
|
||||||
for (int i = 0; i < pi.getObjectCount(); i++)
|
for (int i = 0; i < pi.getObjectCount(); i++)
|
||||||
|
@ -489,7 +489,7 @@ private void assertContent(PackIndex pi, List<ObjectId> expected) {
|
||||||
expected.contains(pi.getObjectId(i)));
|
expected.contains(pi.getObjectId(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private PackIndex writePack(FileRepository repo,
|
private static PackIndex writePack(FileRepository repo,
|
||||||
Set<? extends ObjectId> want, Set<PackIndex> excludeObjects)
|
Set<? extends ObjectId> want, Set<PackIndex> excludeObjects)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
PackWriter pw = new PackWriter(repo);
|
PackWriter pw = new PackWriter(repo);
|
||||||
|
|
|
@ -863,7 +863,7 @@ public void testRenameRefNameColission2avoided() throws IOException {
|
||||||
"HEAD").getReverseEntries().get(0).getComment());
|
"HEAD").getReverseEntries().get(0).getComment());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeReflog(Repository db, ObjectId newId, String msg,
|
private static void writeReflog(Repository db, ObjectId newId, String msg,
|
||||||
String refName) throws IOException {
|
String refName) throws IOException {
|
||||||
RefDirectory refs = (RefDirectory) db.getRefDatabase();
|
RefDirectory refs = (RefDirectory) db.getRefDatabase();
|
||||||
RefDirectoryUpdate update = refs.newUpdate(refName, true);
|
RefDirectoryUpdate update = refs.newUpdate(refName, true);
|
||||||
|
|
|
@ -110,7 +110,7 @@ public void testReadOneLine() throws Exception {
|
||||||
e.getComment());
|
e.getComment());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String iso(PersonIdent id) {
|
private static String iso(PersonIdent id) {
|
||||||
final SimpleDateFormat fmt;
|
final SimpleDateFormat fmt;
|
||||||
fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
fmt.setTimeZone(id.getTimeZone());
|
fmt.setTimeZone(id.getTimeZone());
|
||||||
|
|
|
@ -183,7 +183,7 @@ public void testExceptionThrown_BareRepoGetIndexFile() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getFile(String... pathComponents) throws IOException {
|
private static File getFile(String... pathComponents) throws IOException {
|
||||||
String rootPath = new File(new File("target"), "trash").getPath();
|
String rootPath = new File(new File("target"), "trash").getPath();
|
||||||
for (String pathComponent : pathComponents)
|
for (String pathComponent : pathComponents)
|
||||||
rootPath = rootPath + File.separatorChar + pathComponent;
|
rootPath = rootPath + File.separatorChar + pathComponent;
|
||||||
|
@ -192,7 +192,7 @@ private File getFile(String... pathComponents) throws IOException {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBare(File gitDir, boolean bare) throws IOException,
|
private static void setBare(File gitDir, boolean bare) throws IOException,
|
||||||
ConfigInvalidException {
|
ConfigInvalidException {
|
||||||
FileBasedConfig cfg = configFor(gitDir);
|
FileBasedConfig cfg = configFor(gitDir);
|
||||||
cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
|
cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
|
||||||
|
@ -200,7 +200,8 @@ private void setBare(File gitDir, boolean bare) throws IOException,
|
||||||
cfg.save();
|
cfg.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWorkTree(File gitDir, File workTree) throws IOException,
|
private static void setWorkTree(File gitDir, File workTree)
|
||||||
|
throws IOException,
|
||||||
ConfigInvalidException {
|
ConfigInvalidException {
|
||||||
String path = workTree.getAbsolutePath();
|
String path = workTree.getAbsolutePath();
|
||||||
FileBasedConfig cfg = configFor(gitDir);
|
FileBasedConfig cfg = configFor(gitDir);
|
||||||
|
@ -209,7 +210,7 @@ private void setWorkTree(File gitDir, File workTree) throws IOException,
|
||||||
cfg.save();
|
cfg.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileBasedConfig configFor(File gitDir) throws IOException,
|
private static FileBasedConfig configFor(File gitDir) throws IOException,
|
||||||
ConfigInvalidException {
|
ConfigInvalidException {
|
||||||
File configPath = new File(gitDir, Constants.CONFIG);
|
File configPath = new File(gitDir, Constants.CONFIG);
|
||||||
FileBasedConfig cfg = new FileBasedConfig(configPath, FS.DETECTED);
|
FileBasedConfig cfg = new FileBasedConfig(configPath, FS.DETECTED);
|
||||||
|
@ -217,14 +218,14 @@ private FileBasedConfig configFor(File gitDir) throws IOException,
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertGitdirPath(Repository repo, String... expected)
|
private static void assertGitdirPath(Repository repo, String... expected)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
File exp = getFile(expected).getCanonicalFile();
|
File exp = getFile(expected).getCanonicalFile();
|
||||||
File act = repo.getDirectory().getCanonicalFile();
|
File act = repo.getDirectory().getCanonicalFile();
|
||||||
assertEquals("Wrong Git Directory", exp, act);
|
assertEquals("Wrong Git Directory", exp, act);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertWorkdirPath(Repository repo, String... expected)
|
private static void assertWorkdirPath(Repository repo, String... expected)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
File exp = getFile(expected).getCanonicalFile();
|
File exp = getFile(expected).getCanonicalFile();
|
||||||
File act = repo.getWorkTree().getCanonicalFile();
|
File act = repo.getWorkTree().getCanonicalFile();
|
||||||
|
|
|
@ -520,14 +520,14 @@ public void testPackFormat_DeltaNotAllowed() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] compressStandardFormat(int type, byte[] data)
|
private static byte[] compressStandardFormat(int type, byte[] data)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
String typeString = Constants.typeString(type);
|
String typeString = Constants.typeString(type);
|
||||||
String length = String.valueOf(data.length);
|
String length = String.valueOf(data.length);
|
||||||
return compressStandardFormat(typeString, length, data);
|
return compressStandardFormat(typeString, length, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] compressStandardFormat(String type, String length,
|
private static byte[] compressStandardFormat(String type, String length,
|
||||||
byte[] data) throws IOException {
|
byte[] data) throws IOException {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
DeflaterOutputStream d = new DeflaterOutputStream(out);
|
DeflaterOutputStream d = new DeflaterOutputStream(out);
|
||||||
|
@ -540,7 +540,8 @@ private byte[] compressStandardFormat(String type, String length,
|
||||||
return out.toByteArray();
|
return out.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] compressPackFormat(int type, byte[] data) throws IOException {
|
private static byte[] compressPackFormat(int type, byte[] data)
|
||||||
|
throws IOException {
|
||||||
byte[] hdr = new byte[64];
|
byte[] hdr = new byte[64];
|
||||||
int rawLength = data.length;
|
int rawLength = data.length;
|
||||||
int nextLength = rawLength >>> 4;
|
int nextLength = rawLength >>> 4;
|
||||||
|
|
|
@ -126,7 +126,7 @@ public void testCache_TooSmallLimit() throws IOException {
|
||||||
checkLimits(cfg);
|
checkLimits(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkLimits(final WindowCacheConfig cfg) {
|
private static void checkLimits(final WindowCacheConfig cfg) {
|
||||||
final WindowCache cache = WindowCache.getInstance();
|
final WindowCache cache = WindowCache.getInstance();
|
||||||
assertTrue(cache.getOpenFiles() <= cfg.getPackedGitOpenFiles());
|
assertTrue(cache.getOpenFiles() <= cfg.getPackedGitOpenFiles());
|
||||||
assertTrue(cache.getOpenBytes() <= cfg.getPackedGitLimit());
|
assertTrue(cache.getOpenBytes() <= cfg.getPackedGitLimit());
|
||||||
|
|
|
@ -140,7 +140,7 @@ public void testWrite1() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FetchResult fetchFromBundle(final Repository newRepo,
|
private static FetchResult fetchFromBundle(final Repository newRepo,
|
||||||
final byte[] bundle) throws URISyntaxException,
|
final byte[] bundle) throws URISyntaxException,
|
||||||
NotSupportedException, TransportException {
|
NotSupportedException, TransportException {
|
||||||
final URIish uri = new URIish("in-memory://");
|
final URIish uri = new URIish("in-memory://");
|
||||||
|
|
|
@ -452,7 +452,7 @@ public void testDataAfterPackFooterSplitHeaderRead() throws Exception {
|
||||||
assertEquals(0x7e, in.read());
|
assertEquals(0x7e, in.read());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void packHeader(TemporaryBuffer.Heap tinyPack, int cnt)
|
private static void packHeader(TemporaryBuffer.Heap tinyPack, int cnt)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final byte[] hdr = new byte[8];
|
final byte[] hdr = new byte[8];
|
||||||
NB.encodeInt32(hdr, 0, 2);
|
NB.encodeInt32(hdr, 0, 2);
|
||||||
|
@ -462,7 +462,8 @@ private void packHeader(TemporaryBuffer.Heap tinyPack, int cnt)
|
||||||
tinyPack.write(hdr, 0, 8);
|
tinyPack.write(hdr, 0, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deflate(TemporaryBuffer.Heap tinyPack, final byte[] content)
|
private static void deflate(TemporaryBuffer.Heap tinyPack,
|
||||||
|
final byte[] content)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final Deflater deflater = new Deflater();
|
final Deflater deflater = new Deflater();
|
||||||
final byte[] buf = new byte[128];
|
final byte[] buf = new byte[128];
|
||||||
|
@ -475,7 +476,7 @@ private void deflate(TemporaryBuffer.Heap tinyPack, final byte[] content)
|
||||||
} while (!deflater.finished());
|
} while (!deflater.finished());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void digest(TemporaryBuffer.Heap buf) throws IOException {
|
private static void digest(TemporaryBuffer.Heap buf) throws IOException {
|
||||||
MessageDigest md = Constants.newMessageDigest();
|
MessageDigest md = Constants.newMessageDigest();
|
||||||
md.update(buf.toByteArray());
|
md.update(buf.toByteArray());
|
||||||
buf.write(md.digest());
|
buf.write(md.digest());
|
||||||
|
|
|
@ -283,7 +283,7 @@ public void testCreateBranchAtHiddenCommitFails() throws Exception {
|
||||||
assertSame(PacketLineIn.END, r.readString());
|
assertSame(PacketLineIn.END, r.readString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void receive(final ReceivePack rp,
|
private static void receive(final ReceivePack rp,
|
||||||
final TemporaryBuffer.Heap inBuf, final TemporaryBuffer.Heap outBuf)
|
final TemporaryBuffer.Heap inBuf, final TemporaryBuffer.Heap outBuf)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
rp.receive(new ByteArrayInputStream(inBuf.toByteArray()), outBuf, null);
|
rp.receive(new ByteArrayInputStream(inBuf.toByteArray()), outBuf, null);
|
||||||
|
@ -490,7 +490,7 @@ public void testUsingUnknownTreeFails() throws Exception {
|
||||||
assertSame(PacketLineIn.END, r.readString());
|
assertSame(PacketLineIn.END, r.readString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void packHeader(TemporaryBuffer.Heap tinyPack, int cnt)
|
private static void packHeader(TemporaryBuffer.Heap tinyPack, int cnt)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final byte[] hdr = new byte[8];
|
final byte[] hdr = new byte[8];
|
||||||
NB.encodeInt32(hdr, 0, 2);
|
NB.encodeInt32(hdr, 0, 2);
|
||||||
|
@ -500,7 +500,7 @@ private void packHeader(TemporaryBuffer.Heap tinyPack, int cnt)
|
||||||
tinyPack.write(hdr, 0, 8);
|
tinyPack.write(hdr, 0, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copy(TemporaryBuffer.Heap tinyPack, ObjectLoader ldr)
|
private static void copy(TemporaryBuffer.Heap tinyPack, ObjectLoader ldr)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final byte[] buf = new byte[64];
|
final byte[] buf = new byte[64];
|
||||||
final byte[] content = ldr.getCachedBytes();
|
final byte[] content = ldr.getCachedBytes();
|
||||||
|
@ -519,7 +519,8 @@ private void copy(TemporaryBuffer.Heap tinyPack, ObjectLoader ldr)
|
||||||
deflate(tinyPack, content);
|
deflate(tinyPack, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deflate(TemporaryBuffer.Heap tinyPack, final byte[] content)
|
private static void deflate(TemporaryBuffer.Heap tinyPack,
|
||||||
|
final byte[] content)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final Deflater deflater = new Deflater();
|
final Deflater deflater = new Deflater();
|
||||||
final byte[] buf = new byte[128];
|
final byte[] buf = new byte[128];
|
||||||
|
@ -532,7 +533,7 @@ private void deflate(TemporaryBuffer.Heap tinyPack, final byte[] content)
|
||||||
} while (!deflater.finished());
|
} while (!deflater.finished());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void digest(TemporaryBuffer.Heap buf) throws IOException {
|
private static void digest(TemporaryBuffer.Heap buf) throws IOException {
|
||||||
MessageDigest md = Constants.newMessageDigest();
|
MessageDigest md = Constants.newMessageDigest();
|
||||||
md.update(buf.toByteArray());
|
md.update(buf.toByteArray());
|
||||||
buf.write(md.digest());
|
buf.write(md.digest());
|
||||||
|
|
|
@ -462,7 +462,7 @@ public void idOffset() throws Exception {
|
||||||
assertFalse(tw.next());
|
assertFalse(tw.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertEntry(String sha1string, String path, TreeWalk tw)
|
private static void assertEntry(String sha1string, String path, TreeWalk tw)
|
||||||
throws MissingObjectException, IncorrectObjectTypeException,
|
throws MissingObjectException, IncorrectObjectTypeException,
|
||||||
CorruptObjectException, IOException {
|
CorruptObjectException, IOException {
|
||||||
assertTrue(tw.next());
|
assertTrue(tw.next());
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class TreeWalkBasicDiffTest extends RepositoryTestCase {
|
public class TreeWalkBasicDiffTest extends RepositoryTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testMissingSubtree_DetectFileAdded_FileModified()
|
public void testMissingSubtree_DetectFileAdded_FileModified()
|
||||||
|
|
|
@ -619,7 +619,7 @@ private TreeWalk createTreeWalk(RevCommit commit, boolean isRecursive,
|
||||||
return treeWalk;
|
return treeWalk;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertPaths(TreeWalk treeWalk, String... paths)
|
private static void assertPaths(TreeWalk treeWalk, String... paths)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
for (int i = 0; i < paths.length; i++) {
|
for (int i = 0; i < paths.length; i++) {
|
||||||
assertTrue(treeWalk.next());
|
assertTrue(treeWalk.next());
|
||||||
|
@ -628,7 +628,7 @@ private void assertPaths(TreeWalk treeWalk, String... paths)
|
||||||
assertFalse(treeWalk.next());
|
assertFalse(treeWalk.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertPath(String path, String... paths) {
|
private static void assertPath(String path, String... paths) {
|
||||||
for (String p : paths)
|
for (String p : paths)
|
||||||
if (p.equals(path))
|
if (p.equals(path))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -157,7 +157,7 @@ public void testDequote_OctalAll() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String octalEscape(int i) {
|
private static String octalEscape(int i) {
|
||||||
String s = Integer.toOctalString(i);
|
String s = Integer.toOctalString(i);
|
||||||
while (s.length() < 3) {
|
while (s.length() < 3) {
|
||||||
s = "0" + s;
|
s = "0" + s;
|
||||||
|
|
|
@ -137,7 +137,7 @@ public void testParsePersonIdent_malformedCases() {
|
||||||
assertPersonIdent("Me <me@example.com 1234567890 -0700", null);
|
assertPersonIdent("Me <me@example.com 1234567890 -0700", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertPersonIdent(String line, PersonIdent expected) {
|
private static void assertPersonIdent(String line, PersonIdent expected) {
|
||||||
PersonIdent actual = RawParseUtils.parsePersonIdent(line);
|
PersonIdent actual = RawParseUtils.parsePersonIdent(line);
|
||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
|
@ -450,7 +450,7 @@ public void testCopyConstructorReusesArray() {
|
||||||
assertSame(REF_B, two.get(0));
|
assertSame(REF_B, two.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private RefList<Ref> toList(Ref... refs) {
|
private static RefList<Ref> toList(Ref... refs) {
|
||||||
RefList.Builder<Ref> b = new RefList.Builder<Ref>(refs.length);
|
RefList.Builder<Ref> b = new RefList.Builder<Ref>(refs.length);
|
||||||
b.addAll(refs, 0, refs.length);
|
b.addAll(refs, 0, refs.length);
|
||||||
return b.toRefList();
|
return b.toRefList();
|
||||||
|
|
|
@ -480,7 +480,7 @@ public void testEntryTypeSet() {
|
||||||
assertEquals(1, map.size());
|
assertEquals(1, map.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private RefList<Ref> toList(Ref... refs) {
|
private static RefList<Ref> toList(Ref... refs) {
|
||||||
RefList.Builder<Ref> b = new RefList.Builder<Ref>(refs.length);
|
RefList.Builder<Ref> b = new RefList.Builder<Ref>(refs.length);
|
||||||
b.addAll(refs, 0, refs.length);
|
b.addAll(refs, 0, refs.length);
|
||||||
return b.toRefList();
|
return b.toRefList();
|
||||||
|
|
|
@ -63,7 +63,7 @@ public void setUp() {
|
||||||
SystemReader.setInstance(new MockSystemReader());
|
SystemReader.setInstance(new MockSystemReader());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertFormat(long ageFromNow, long timeUnit,
|
private static void assertFormat(long ageFromNow, long timeUnit,
|
||||||
String expectedFormat) {
|
String expectedFormat) {
|
||||||
Date d = new Date(SystemReader.getInstance().getCurrentTime()
|
Date d = new Date(SystemReader.getInstance().getCurrentTime()
|
||||||
- ageFromNow * timeUnit);
|
- ageFromNow * timeUnit);
|
||||||
|
|
|
@ -94,7 +94,8 @@ public void testBinaryDontDetect() throws IOException {
|
||||||
test(asBytes("1\r\n2\r\n3\0"), asBytes("1\n2\n3\0"), false);
|
test(asBytes("1\r\n2\r\n3\0"), asBytes("1\n2\n3\0"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void test(byte[] input, byte[] expected, boolean detectBinary) throws IOException {
|
private static void test(byte[] input, byte[] expected,
|
||||||
|
boolean detectBinary) throws IOException {
|
||||||
final InputStream bis1 = new ByteArrayInputStream(input);
|
final InputStream bis1 = new ByteArrayInputStream(input);
|
||||||
final InputStream cis1 = new EolCanonicalizingInputStream(bis1, detectBinary);
|
final InputStream cis1 = new EolCanonicalizingInputStream(bis1, detectBinary);
|
||||||
int index1 = 0;
|
int index1 = 0;
|
||||||
|
|
|
@ -135,7 +135,7 @@ public boolean get(URIish uri, CredentialItem... items)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean interactive(URIish uri, CredentialItem[] items) {
|
private static boolean interactive(URIish uri, CredentialItem[] items) {
|
||||||
final GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1, 1,
|
final GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1, 1,
|
||||||
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
|
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
|
||||||
new Insets(0, 0, 0, 0), 0, 0);
|
new Insets(0, 0, 0, 0), 0, 0);
|
||||||
|
|
Loading…
Reference in New Issue