class AsIsFileFilter implements Filter {
private final AsIsFileService asIs;
- AsIsFileFilter(final AsIsFileService getAnyFile) {
+ AsIsFileFilter(AsIsFileService getAnyFile) {
this.asIs = getAnyFile;
}
private long end;
- FileSender(final File path) throws FileNotFoundException {
+ FileSender(File path) throws FileNotFoundException {
this.path = path;
this.source = new RandomAccessFile(path, "r");
}
@Override
- String etag(final FileSender sender) throws IOException {
+ String etag(FileSender sender) throws IOException {
return Long.toHexString(sender.getLastModified());
}
}
}
@Override
- String etag(final FileSender sender) throws IOException {
+ String etag(FileSender sender) throws IOException {
return sender.getTailChecksum();
}
}
private final String contentType;
- ObjectFileServlet(final String contentType) {
+ ObjectFileServlet(String contentType) {
this.contentType = contentType;
}
return content;
}
- static boolean acceptsGzipEncoding(final HttpServletRequest req) {
+ static boolean acceptsGzipEncoding(HttpServletRequest req) {
return acceptsGzipEncoding(req.getHeader(HDR_ACCEPT_ENCODING));
}
private final Filter[] filters;
- SmartServiceInfoRefs(final String service, final List<Filter> filters) {
+ SmartServiceInfoRefs(String service, List<Filter> filters) {
this.svc = service;
this.filters = filters.toArray(new Filter[filters.size()]);
}
private final String fileName;
- TextFileServlet(final String name) {
+ TextFileServlet(String name) {
this.fileName = name;
}
static class Binder extends ServletBinderImpl {
private final Pattern pattern;
- Binder(final String p) {
+ Binder(String p) {
pattern = Pattern.compile(p);
}
- Binder(final Pattern p) {
+ Binder(Pattern p) {
pattern = p;
}
}
@Override
- boolean match(final HttpServletRequest req) {
+ boolean match(HttpServletRequest req) {
final String pathInfo = req.getPathInfo();
return pathInfo != null && pattern.matcher(pathInfo).matches();
}
static class Binder extends ServletBinderImpl {
private final String suffix;
- Binder(final String suffix) {
+ Binder(String suffix) {
this.suffix = suffix;
}
}
@Override
- boolean match(final HttpServletRequest req) {
+ boolean match(HttpServletRequest req) {
final String pathInfo = req.getPathInfo();
return pathInfo != null && pathInfo.endsWith(suffix);
}
/** Instance that must generate the response; never null. */
private final HttpServlet servlet;
- UrlPipeline(final Filter[] filters, final HttpServlet servlet) {
+ UrlPipeline(Filter[] filters, HttpServlet servlet) {
this.filters = filters;
this.servlet = servlet;
}
* @throws ServletException
* a filter or servlet is unable to initialize.
*/
- void init(final ServletContext context, final Set<Object> inited)
+ void init(ServletContext context, Set<Object> inited)
throws ServletException {
for (Filter ref : filters)
initFilter(ref, context, inited);
* destroyed a second time. Filters and servlets that are first
* destroyed by this pipeline will be added to this set.
*/
- void destroy(final Set<Object> destroyed) {
+ void destroy(Set<Object> destroyed) {
for (Filter ref : filters)
destroyFilter(ref, destroyed);
destroyServlet(servlet, destroyed);
private int filterIdx;
- Chain(final Filter[] filters, final HttpServlet servlet) {
+ Chain(Filter[] filters, HttpServlet servlet) {
this.filters = filters;
this.servlet = servlet;
}
private static class ServiceConfig {
final boolean enabled;
- ServiceConfig(final Config cfg) {
+ ServiceConfig(Config cfg) {
enabled = cfg.getBoolean("http", "getanyfile", true);
}
}
final boolean enabled;
- ServiceConfig(final Config cfg) {
+ ServiceConfig(Config cfg) {
set = cfg.getString("http", null, "receivepack") != null;
enabled = cfg.getBoolean("http", "receivepack", false);
}
private static class ServiceConfig {
final boolean enabled;
- ServiceConfig(final Config cfg) {
+ ServiceConfig(Config cfg) {
enabled = cfg.getBoolean("http", "uploadpack", true);
}
}
private final String host;
- R(final String user, final String host) {
+ R(String user, String host) {
super(new Request(null, null) /* can't pass null, sigh */);
this.user = user;
this.host = host;
private final String host;
- R(final String user, final String host) {
+ R(String user, String host) {
super(new Request(null, null) /* can't pass null, sigh */);
this.user = user;
this.host = host;
private final String host;
- R(final String user, final String host) {
+ R(String user, String host) {
super(new Request(null, null) /* can't pass null, sigh */);
this.user = user;
this.host = host;
private final Map<String, String> responseHeaders;
- AccessEvent(final Request req, final Response rsp) {
+ AccessEvent(Request req, Response rsp) {
method = req.getMethod();
uri = req.getRequestURI();
requestHeaders = cloneHeaders(req);
public RevTree tree(DirCacheEntry... entries) throws Exception {
final DirCache dc = DirCache.newInCore();
final DirCacheBuilder b = dc.builder();
- for (final DirCacheEntry e : entries)
+ for (DirCacheEntry e : entries)
b.add(e);
b.finish();
ObjectId root;
public class BranchBuilder {
private final String ref;
- BranchBuilder(final String ref) {
+ BranchBuilder(String ref) {
this.ref = ref;
}
ExecutorService e = Executors.newFixedThreadPool(count);
try {
- for (final Path p : paths) {
+ for (Path p : paths) {
e.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
return r << (16 - n) * 4;
}
- static long mask(final int nibbles, final long word, final long v) {
+ static long mask(int nibbles, long word, long v) {
final long b = (word - 1) * 16;
if (b + 16 <= nibbles) {
// We have all of the bits required for this word.
private static final char[] hexchar = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
- static void formatHexChar(final char[] dst, final int p, long w) {
+ static void formatHexChar(char[] dst, int p, long w) {
int o = p + 15;
while (o >= p && w != 0) {
dst[o--] = hexchar[(int) (w & 0xf)];
}
@Override
- void init(final TextBuiltin cmd) throws IOException {
+ void init(TextBuiltin cmd) throws IOException {
cmd.outs = result.out;
cmd.errs = result.err;
super.init(cmd);
protected void showFetchResult(FetchResult r) throws IOException {
try (ObjectReader reader = db.newObjectReader()) {
boolean shownURI = false;
- for (final TrackingRefUpdate u : r.getTrackingRefUpdates()) {
+ for (TrackingRefUpdate u : r.getTrackingRefUpdates()) {
if (!verbose && u.getResult() == RefUpdate.Result.NO_CHANGE)
continue;
}
} else if ("ls".equals(op) || "list".equals(op)) { //$NON-NLS-1$//$NON-NLS-2$
- for (final String k : s3.list(bucket, key))
+ for (String k : s3.list(bucket, key))
outw.println(k);
} else if ("rm".equals(op) || "delete".equals(op)) { //$NON-NLS-1$ //$NON-NLS-2$
addRefs(refs, Constants.R_REMOTES);
try (ObjectReader reader = db.newObjectReader()) {
- for (final Entry<String, Ref> e : printRefs.entrySet()) {
+ for (Entry<String, Ref> e : printRefs.entrySet()) {
final Ref ref = e.getValue();
printHead(reader, e.getKey(),
current.equals(ref.getName()), ref);
}
private void addRefs(Collection<Ref> refs, String prefix) {
- for (final Ref ref : RefComparator.sort(refs)) {
+ for (Ref ref : RefComparator.sort(refs)) {
final String name = ref.getName();
if (name.startsWith(prefix))
addRef(name.substring(name.indexOf('/', 5) + 1), ref);
*/
public static CommandRef[] common() {
final ArrayList<CommandRef> common = new ArrayList<>();
- for (final CommandRef c : INSTANCE.commands.values())
+ for (CommandRef c : INSTANCE.commands.values())
if (c.isCommon())
common.add(c);
return toSortedArray(common);
boolean common;
- CommandRef(final Class<? extends TextBuiltin> clazz) {
+ CommandRef(Class<? extends TextBuiltin> clazz) {
this(clazz, guessName(clazz));
}
- CommandRef(final Class<? extends TextBuiltin> clazz, final Command cmd) {
+ CommandRef(Class<? extends TextBuiltin> clazz, Command cmd) {
this(clazz, cmd.name().length() > 0 ? cmd.name() : guessName(clazz));
usage = cmd.usage();
common = cmd.common();
s.append("debug-"); //$NON-NLS-1$
boolean lastWasDash = true;
- for (final char c : clazz.getSimpleName().toCharArray()) {
+ for (char c : clazz.getSimpleName().toCharArray()) {
if (Character.isUpperCase(c)) {
if (!lastWasDash)
s.append('-');
packConfig.setExecutor(Executors.newFixedThreadPool(threads));
final FileResolver<DaemonClient> resolver = new FileResolver<>();
- for (final File f : directory) {
+ for (File f : directory) {
outw.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath()));
resolver.exportDirectory(f);
}
if (0 <= timeout)
d.setTimeout(timeout);
- for (final String n : enable)
+ for (String n : enable)
service(d, n).setEnabled(true);
- for (final String n : disable)
+ for (String n : disable)
service(d, n).setEnabled(false);
- for (final String n : canOverride)
+ for (String n : canOverride)
service(d, n).setOverridable(true);
- for (final String n : forbidOverride)
+ for (String n : forbidOverride)
service(d, n).setOverridable(false);
if (ketchServerType == KetchServerType.LEADER) {
startKetchLeader(d);
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
- try (final TreeWalk walk = new TreeWalk(db)) {
+ try (TreeWalk walk = new TreeWalk(db)) {
walk.setRecursive(recursive);
- for (final AbstractTreeIterator i : trees)
+ for (AbstractTreeIterator i : trees)
walk.addTree(i);
walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, pathFilter));
outw.println();
final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
- for (final String s : lines) {
+ for (String s : lines) {
outw.print(" "); //$NON-NLS-1$
outw.print(s);
outw.println();
}
});
refs.addAll(command.call());
- for (final Ref r : refs) {
+ for (Ref r : refs) {
show(r.getObjectId(), r.getName());
if (r.getPeeledObjectId() != null)
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
- try (final TreeWalk walk = new TreeWalk(db)) {
+ try (TreeWalk walk = new TreeWalk(db)) {
walk.reset(); // drop the first empty tree, which we do not need here
if (paths.size() > 0)
walk.setFilter(PathFilterGroup.createFromStrings(paths));
writer.println(CLIText.get().mostCommonlyUsedCommandsAre);
final CommandRef[] common = CommandCatalog.common();
int width = 0;
- for (final CommandRef c : common) {
+ for (CommandRef c : common) {
width = Math.max(width, c.getName().length());
}
width += 2;
- for (final CommandRef c : common) {
+ for (CommandRef c : common) {
writer.print(' ');
writer.print(c.getName());
for (int i = c.getName().length(); i < width; i++) {
}
}
- void init(final TextBuiltin cmd) throws IOException {
+ void init(TextBuiltin cmd) throws IOException {
if (cmd.requiresRepository()) {
cmd.init(openGitDir(gitdir), null);
} else {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
- for (final RevCommit c : commits)
+ for (RevCommit c : commits)
argWalk.markStart(c);
argWalk.setRevFilter(RevFilter.MERGE_BASE);
int max = all ? Integer.MAX_VALUE : 1;
boolean everythingUpToDate = true;
// at first, print up-to-date ones...
- for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
+ for (RemoteRefUpdate rru : result.getRemoteUpdates()) {
if (rru.getStatus() == Status.UP_TO_DATE) {
if (verbose)
printRefUpdateResult(reader, uri, result, rru);
everythingUpToDate = false;
}
- for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
+ for (RemoteRefUpdate rru : result.getRemoteUpdates()) {
// ...then successful updates...
if (rru.getStatus() == Status.OK)
printRefUpdateResult(reader, uri, result, rru);
}
- for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
+ for (RemoteRefUpdate rru : result.getRemoteUpdates()) {
// ...finally, others (problematic)
if (rru.getStatus() != Status.OK
&& rru.getStatus() != Status.UP_TO_DATE)
CLIText.format(CLIText.get().needSingleRevision));
}
- for (final ObjectId o : commits) {
+ for (ObjectId o : commits) {
outw.println(o.name());
}
}
}
@Option(name = "--date-order")
- void enableDateOrder(final boolean on) {
+ void enableDateOrder(boolean on) {
enableRevSort(RevSort.COMMIT_TIME_DESC, on);
}
@Option(name = "--topo-order")
- void enableTopoOrder(final boolean on) {
+ void enableTopoOrder(boolean on) {
enableRevSort(RevSort.TOPO, on);
}
@Option(name = "--reverse")
- void enableReverse(final boolean on) {
+ void enableReverse(boolean on) {
enableRevSort(RevSort.REVERSE, on);
}
@Option(name = "--boundary")
- void enableBoundary(final boolean on) {
+ void enableBoundary(boolean on) {
enableRevSort(RevSort.BOUNDARY, on);
}
private final List<RevFilter> revLimiter = new ArrayList<>();
@Option(name = "--author")
- void addAuthorRevFilter(final String who) {
+ void addAuthorRevFilter(String who) {
revLimiter.add(AuthorRevFilter.create(who));
}
@Option(name = "--committer")
- void addCommitterRevFilter(final String who) {
+ void addCommitterRevFilter(String who) {
revLimiter.add(CommitterRevFilter.create(who));
}
@Option(name = "--grep")
- void addCMessageRevFilter(final String msg) {
+ void addCMessageRevFilter(String msg) {
revLimiter.add(MessageRevFilter.create(msg));
}
@Override
protected void run() throws Exception {
walk = createWalk();
- for (final RevSort s : sorting)
+ for (RevSort s : sorting)
walk.sort(s, true);
if (pathFilter == TreeFilter.ALL) {
throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD));
commits.add(walk.parseCommit(head));
}
- for (final RevCommit c : commits) {
+ for (RevCommit c : commits) {
final RevCommit real = argWalk == walk ? c : walk.parseCommit(c);
if (c.has(RevFlag.UNINTERESTING))
walk.markUninteresting(real);
*/
protected int walkLoop() throws Exception {
int n = 0;
- for (final RevCommit c : walk) {
+ for (RevCommit c : walk) {
if (++n > maxCount && maxCount >= 0)
break;
show(c);
outw.println();
final String[] lines = tag.getFullMessage().split("\n"); //$NON-NLS-1$
- for (final String s : lines) {
+ for (String s : lines) {
outw.print(" "); //$NON-NLS-1$
outw.print(s);
outw.println();
private void show(RevTree obj) throws MissingObjectException,
IncorrectObjectTypeException, CorruptObjectException, IOException {
- try (final TreeWalk walk = new TreeWalk(db)) {
+ try (TreeWalk walk = new TreeWalk(db)) {
walk.reset();
walk.addTree(obj);
outw.println();
final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
- for (final String s : lines) {
+ for (String s : lines) {
outw.print(" "); //$NON-NLS-1$
outw.print(s);
outw.println();
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
- for (final Ref r : getSortedRefs()) {
+ for (Ref r : getSortedRefs()) {
show(r.getObjectId(), r.getName());
if (r.getPeeledObjectId() != null)
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
/** RevWalk used during command line parsing, if it was required. */
protected RevWalk argWalk;
- final void setCommandName(final String name) {
+ final void setCommandName(String name) {
commandName = name;
}
return db;
}
- ObjectId resolve(final String s) throws IOException {
+ ObjectId resolve(String s) throws IOException {
final ObjectId r = db.resolve(s);
if (r == null)
throw die(MessageFormat.format(CLIText.get().notARevision, s));
ObjectId newId;
- ToRewrite(final ObjectId o, final long t, final ObjectId[] p) {
+ ToRewrite(ObjectId o, long t, ObjectId[] p) {
oldId = o;
commitTime = t;
oldParents = p;
final CommandRef[] list = CommandCatalog.all();
int width = 0;
- for (final CommandRef c : list)
+ for (CommandRef c : list)
width = Math.max(width, c.getName().length());
width += 2;
- for (final CommandRef c : list) {
+ for (CommandRef c : list) {
errw.print(c.isCommon() ? '*' : ' ');
errw.print(' ');
/** */
USAGE {
@Override
- void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
+ void print(ThrowingPrintWriter err, CommandRef c) throws IOException {
String usage = c.getUsage();
if (usage != null && usage.length() > 0)
err.print(CLIText.get().resourceBundle().getString(usage));
/** */
CLASSES {
@Override
- void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
+ void print(ThrowingPrintWriter err, CommandRef c) throws IOException {
err.print(c.getImplementationClassName());
}
},
/** */
URLS {
@Override
- void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
+ void print(ThrowingPrintWriter err, CommandRef c) throws IOException {
final ClassLoader ldr = c.getImplementationClassLoader();
String cn = c.getImplementationClassName();
int errors;
- PatchReader(final HashMap<String, HashMap<String, StatInfo>> s)
+ PatchReader(HashMap<String, HashMap<String, StatInfo>> s)
throws IOException {
super(new String[] { "-p" });
stats = s;
p.parse(buf, 0, buf.length - 1);
assertEquals("File count " + cid, files.size(), p.getFiles().size());
if (!p.getErrors().isEmpty()) {
- for (final FormatError e : p.getErrors()) {
+ for (FormatError e : p.getErrors()) {
System.out.println("error " + e.getMessage());
System.out.println(" at " + e.getLineText());
}
fail("Unexpected error in " + cid);
}
- for (final FileHeader fh : p.getFiles()) {
+ for (FileHeader fh : p.getFiles()) {
final String fileName;
if (fh.getChangeType() != FileHeader.ChangeType.DELETE)
fileName = fh.getNewPath();
final String nid = fileName + " in " + cid;
assertNotNull("No " + nid, s);
int added = 0, deleted = 0;
- for (final HunkHeader h : fh.getHunks()) {
+ for (HunkHeader h : fh.getHunks()) {
added += h.getOldImage().getLinesAdded();
deleted += h.getOldImage().getLinesDeleted();
}
static abstract class CommitReader {
private Process proc;
- CommitReader(final String[] args) throws IOException {
+ CommitReader(String[] args) throws IOException {
final String[] realArgs = new String[3 + args.length + 1];
realArgs[0] = "git";
realArgs[1] = "log";
return null;
}
- static private String getHead(final Git git, final String path)
+ static private String getHead(Git git, String path)
throws Exception {
try {
final Repository repo = git.getRepository();
final int expIdx = 2;
final DirCacheBuilder b = dc.builder();
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new DirCacheBuildIterator(b));
tw.setRecursive(true);
tw.setFilter(PathFilterGroup.createFromStrings(Collections
assertEquals(ls.size(), dc.getEntryCount());
{
final Iterator<CGitIndexRecord> rItr = ls.values().iterator();
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.setRecursive(true);
tw.addTree(new DirCacheIterator(dc));
while (rItr.hasNext()) {
assertEquals(cList.size(), jTree.getEntrySpan());
final ArrayList<CGitLsTreeRecord> subtrees = new ArrayList<>();
- for (final CGitLsTreeRecord r : cTree.values()) {
+ for (CGitLsTreeRecord r : cTree.values()) {
if (FileMode.TREE.equals(r.mode))
subtrees.add(r);
}
final String path;
- CGitIndexRecord(final String line) {
+ CGitIndexRecord(String line) {
final int tab = line.indexOf('\t');
final int sp1 = line.indexOf(' ');
final int sp2 = line.indexOf(' ', sp1 + 1);
final String path;
- CGitLsTreeRecord(final String line) {
+ CGitLsTreeRecord(String line) {
final int tab = line.indexOf('\t');
final int sp1 = line.indexOf(' ');
final int sp2 = line.indexOf(' ', sp1 + 1);
final DirCache dc = DirCache.newInCore();
assertEquals(0, dc.getEntryCount());
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new DirCacheIterator(dc));
assertFalse(tw.next());
}
b.finish();
final DirCacheIterator i = new DirCacheIterator(dc);
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(i);
int pathIdx = 0;
while (tw.next()) {
final int expPos[] = { 0, -1, 4 };
final DirCacheIterator i = new DirCacheIterator(dc);
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(i);
tw.setRecursive(false);
int pathIdx = 0;
b.finish();
final DirCacheIterator i = new DirCacheIterator(dc);
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(i);
tw.setRecursive(true);
int pathIdx = 0;
b.add(ents[i]);
b.finish();
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new DirCacheIterator(dc));
tw.setRecursive(true);
int pathIdx = 0;
b.add(ents[i]);
b.finish();
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
for (int victimIdx = 0; victimIdx < paths.length; victimIdx++) {
tw.reset();
tw.addTree(new DirCacheIterator(dc));
final DirCache dc = DirCache.read(path, FS.DETECTED);
assertEquals(2, dc.getEntryCount());
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.setRecursive(true);
tw.addTree(new DirCacheIterator(dc));
private File[] pack(Repository src, RevObject... list)
throws IOException {
try (PackWriter pw = new PackWriter(src)) {
- for (final RevObject o : list) {
+ for (RevObject o : list) {
pw.addObject(o);
}
private static void delete(File[] list) throws IOException {
final long begin = list[0].getParentFile().lastModified();
- for (final File f : list) {
+ for (File f : list) {
FileUtils.delete(f);
assertFalse(f + " was removed", f.exists());
}
ObjectId.fromString("902d5476fa249b7abc9d84c611577a81381f0327"),
ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") ,
ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259") };
- try (final RevWalk parser = new RevWalk(db)) {
+ try (RevWalk parser = new RevWalk(db)) {
final RevObject forcedOrderRevs[] = new RevObject[forcedOrder.length];
for (int i = 0; i < forcedOrder.length; i++)
forcedOrderRevs[i] = parser.parseAny(forcedOrder[i]);
// object (as it already exists in the pack).
//
final Repository newdb = createBareRepository();
- try (final ObjectInserter oi = newdb.newObjectInserter()) {
+ try (ObjectInserter oi = newdb.newObjectInserter()) {
final ObjectId treeId = oi.insert(new TreeFormatter());
assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904",
treeId.name());
@Test
public void test007_Open() throws IOException {
- try (final FileRepository db2 = new FileRepository(db.getDirectory())) {
+ try (FileRepository db2 = new FileRepository(db.getDirectory())) {
assertEquals(db.getDirectory(), db2.getDirectory());
assertEquals(db.getObjectDatabase().getDirectory(), db2
.getObjectDatabase().getDirectory());
@Test
public void test026_CreateCommitMultipleparents() throws IOException {
final ObjectId treeId;
- try (final ObjectInserter oi = db.newObjectInserter()) {
+ try (ObjectInserter oi = db.newObjectInserter()) {
final ObjectId blobId = oi.insert(Constants.OBJ_BLOB,
"and this is the data in me\n".getBytes(Constants.CHARSET
.name()));
}
private void doCacheTests() throws IOException {
- for (final TestObject o : toLoad) {
+ for (TestObject o : toLoad) {
final ObjectLoader or = db.open(o.id, o.type);
assertNotNull(or);
assertEquals(o.type, or.getType());
int type;
- void setType(final String typeStr) throws CorruptObjectException {
+ void setType(String typeStr) throws CorruptObjectException {
final byte[] typeRaw = Constants.encode(typeStr + " ");
final MutableInteger ptr = new MutableInteger();
type = Constants.decodeTypeString(id, typeRaw, (byte) ' ', ptr);
class XInputStream extends BufferedInputStream {
private final byte[] intbuf = new byte[8];
- XInputStream(final InputStream s) {
+ XInputStream(InputStream s) {
super(s);
}
return b;
}
- synchronized void readFully(final byte[] b, int o, int len)
+ synchronized void readFully(byte[] b, int o, int len)
throws IOException {
int r;
while (len > 0 && (r = read(b, o, len)) > 0) {
final RevCommit a2;
final RevCommit b2;
- try (final RevWalk rw2 = new RevWalk(db)) {
+ try (RevWalk rw2 = new RevWalk(db)) {
a2 = rw2.parseCommit(a1);
b2 = rw2.parseCommit(b1);
}
protected void check(RevCommit... order) throws Exception {
markStart(i);
final StringBuilder act = new StringBuilder();
- for (final RevCommit z : rw) {
+ for (RevCommit z : rw) {
final String name = byName.get(z);
assertNotNull(name);
act.append(name);
act.append(' ');
}
final StringBuilder exp = new StringBuilder();
- for (final RevCommit z : order) {
+ for (RevCommit z : order) {
final String name = byName.get(z);
assertNotNull(name);
exp.append(name);
PushConnection {
MockPushConnection() {
final Map<String, Ref> refsMap = new HashMap<>();
- for (final Ref r : advertisedRefs)
+ for (Ref r : advertisedRefs)
refsMap.put(r.getName(), r);
available(refsMap);
}
public void push(ProgressMonitor monitor,
Map<String, RemoteRefUpdate> refsToUpdate)
throws TransportException {
- for (final RemoteRefUpdate rru : refsToUpdate.values()) {
+ for (RemoteRefUpdate rru : refsToUpdate.values()) {
assertEquals(Status.NOT_ATTEMPTED, rru.getStatus());
rru.setStatus(connectionUpdateStatus);
}
try (TransportLocal t = new TransportLocal(src, uriOf(dst),
dst.getDirectory()) {
@Override
- ReceivePack createReceivePack(final Repository db) {
+ ReceivePack createReceivePack(Repository db) {
db.close();
dst.incrementOpen();
throws Exception {
return new TransportLocal(src, uriOf(dst), dst.getDirectory()) {
@Override
- ReceivePack createReceivePack(final Repository db) {
+ ReceivePack createReceivePack(Repository db) {
db.close();
dst.incrementOpen();
assertEquals(12, result.size());
boolean foundA = false;
boolean foundB = false;
- for (final RemoteRefUpdate rru : result) {
+ for (RemoteRefUpdate rru : result) {
if ("refs/heads/a".equals(rru.getSrcRef())
&& "refs/heads/test/a".equals(rru.getRemoteName()))
foundA = true;
assertEquals(2, result.size());
boolean foundA = false;
boolean foundC = false;
- for (final RemoteRefUpdate rru : result) {
+ for (RemoteRefUpdate rru : result) {
if ("refs/heads/a".equals(rru.getSrcRef())
&& "refs/heads/b".equals(rru.getRemoteName()))
foundA = true;
assertEquals(2, result.size());
boolean foundA = false;
boolean foundC = false;
- for (final RemoteRefUpdate rru : result) {
+ for (RemoteRefUpdate rru : result) {
if ("refs/heads/a".equals(rru.getSrcRef())
&& "refs/heads/b".equals(rru.getRemoteName())) {
foundA = true;
private static byte[] mktree(byte[]... data) throws Exception {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
- for (final byte[] e : data)
+ for (byte[] e : data)
out.write(e);
return out.toByteArray();
}
public class PostOrderTreeWalkTest extends RepositoryTestCase {
@Test
public void testInitialize_NoPostOrder() throws Exception {
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
assertFalse(tw.isPostOrderTraversal());
}
}
@Test
public void testInitialize_TogglePostOrder() throws Exception {
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
assertFalse(tw.isPostOrderTraversal());
tw.setPostOrderTraversal(true);
assertTrue(tw.isPostOrderTraversal());
@Test
public void testResetDoesNotAffectPostOrder() throws Exception {
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.setPostOrderTraversal(true);
assertTrue(tw.isPostOrderTraversal());
tw.reset();
b.finish();
assertEquals(4, tree.getEntryCount());
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.setPostOrderTraversal(false);
tw.addTree(new DirCacheIterator(tree));
b.finish();
assertEquals(4, tree.getEntryCount());
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.setPostOrderTraversal(true);
tw.addTree(new DirCacheIterator(tree));
b.finish();
assertEquals(4, tree.getEntryCount());
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.setPostOrderTraversal(true);
tw.addTree(new DirCacheIterator(tree));
}
}
- TreeWalk fakeWalk(final String path) throws IOException {
+ TreeWalk fakeWalk(String path) throws IOException {
DirCache dc = DirCache.newInCore();
DirCacheEditor dce = dc.editor();
dce.add(new DirCacheEditor.PathEdit(path) {
return ret;
}
- TreeWalk fakeWalkAtSubtree(final String path) throws IOException {
+ TreeWalk fakeWalkAtSubtree(String path) throws IOException {
DirCache dc = DirCache.newInCore();
DirCacheEditor dce = dc.editor();
dce.add(new DirCacheEditor.PathEdit(path + "/README") {
private List<String> getMatchingPaths(String suffixFilter,
final ObjectId treeId, boolean recursiveWalk) throws IOException {
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.setFilter(PathSuffixFilter.create(suffixFilter));
tw.setRecursive(recursiveWalk);
tw.addTree(treeId);
public class TreeFilterTest extends RepositoryTestCase {
@Test
public void testALL_IncludesAnything() throws Exception {
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new EmptyTreeIterator());
assertTrue(TreeFilter.ALL.include(tw));
}
@Test
public void testNotALL_IncludesNothing() throws Exception {
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new EmptyTreeIterator());
assertFalse(TreeFilter.ALL.negate().include(tw));
}
@Test
public void testANY_DIFF_IncludesSingleTreeCase() throws Exception {
- try (final TreeWalk tw = new TreeWalk(db)) {
+ try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new EmptyTreeIterator());
assertTrue(TreeFilter.ANY_DIFF.include(tw));
}
public void testInCoreInputStream() throws IOException {
final int cnt = 256;
final byte[] test = new TestRng(getName()).nextBytes(cnt);
- try (final TemporaryBuffer.Heap b = new TemporaryBuffer.Heap(cnt + 4)) {
+ try (TemporaryBuffer.Heap b = new TemporaryBuffer.Heap(cnt + 4)) {
b.write(test);
InputStream in = b.openInputStream();
byte[] act = new byte[cnt];
transient Graphics2D g;
- AWTPlotRenderer(final GraphCellRender c) {
+ AWTPlotRenderer(GraphCellRender c) {
cell = c;
}
- void paint(final Graphics in, final PlotCommit<SwingLane> commit) {
+ void paint(Graphics in, PlotCommit<SwingLane> commit) {
g = (Graphics2D) in.create();
try {
final int h = cell.getHeight();
return myLane != null ? myLane.color : Color.black;
}
- void paintTriangleDown(final int cx, final int y, final int h) {
+ void paintTriangleDown(int cx, int y, int h) {
final int tipX = cx;
final int tipY = y + h;
final int baseX1 = cx - 10 / 2;
}
}
- PersonIdent authorFor(final PlotCommit<SwingLane> c) {
+ PersonIdent authorFor(PlotCommit<SwingLane> c) {
if (c != lastCommit) {
lastCommit = c;
lastAuthor = c.getAuthorIdent();
strokeCache[i] = new BasicStroke(i);
}
- static Stroke stroke(final int width) {
+ static Stroke stroke(int width) {
if (width < strokeCache.length)
return strokeCache[width];
return new BasicStroke(width);
specs.add(wcrs);
else if (branchesToClone != null
&& branchesToClone.size() > 0) {
- for (final String selectedRef : branchesToClone)
+ for (String selectedRef : branchesToClone)
if (wcrs.matchSource(selectedRef))
specs.add(wcrs.expandFromSource(selectedRef));
}
}
Ref foundBranch = null;
- for (final Ref r : result.getAdvertisedRefs()) {
+ for (Ref r : result.getAdvertisedRefs()) {
final String n = r.getName();
if (!n.startsWith(Constants.R_HEADS))
continue;
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
final RevCommit commit;
- try (final RevWalk rw = new RevWalk(clonedRepo)) {
+ try (RevWalk rw = new RevWalk(clonedRepo)) {
commit = rw.parseCommit(ref.getObjectId());
}
return commit;
private void resetIndexForPaths(ObjectId commitTree) {
DirCache dc = null;
- try (final TreeWalk tw = new TreeWalk(repo)) {
+ try (TreeWalk tw = new TreeWalk(repo)) {
dc = repo.lockDirCache();
DirCacheBuilder builder = dc.builder();
DirCache dc = null;
List<String> actuallyDeletedFiles = new ArrayList<>();
- try (final TreeWalk tw = new TreeWalk(repo)) {
+ try (TreeWalk tw = new TreeWalk(repo)) {
dc = repo.lockDirCache();
DirCacheBuilder builder = dc.builder();
tw.reset(); // drop the first empty tree, which we do not need here
private RevCommit parseCommit(final ObjectReader reader,
final ObjectId headId) throws IOException {
- try (final RevWalk walk = new RevWalk(reader)) {
+ try (RevWalk walk = new RevWalk(reader)) {
return walk.parseCommit(headId);
}
}
return children.length;
}
- ReverseCommit getChild(final int nth) {
+ ReverseCommit getChild(int nth) {
return children[nth];
}
}
abstract int getLeft(int x);
abstract int getRight(int x);
abstract boolean isBetter(int left, int right);
- abstract void adjustMinMaxK(final int k, final int x);
+ abstract void adjustMinMaxK(int k, int x);
abstract boolean meets(int d, int k, int x, long snake);
final long newSnake(int k, int x) {
}
@Override
- final int getLeft(final int x) {
+ final int getLeft(int x) {
return x;
}
@Override
- final int getRight(final int x) {
+ final int getRight(int x) {
return x + 1;
}
@Override
- final boolean isBetter(final int left, final int right) {
+ final boolean isBetter(int left, int right) {
return left > right;
}
@Override
- final void adjustMinMaxK(final int k, final int x) {
+ final void adjustMinMaxK(int k, int x) {
if (x >= endA || k + x >= endB) {
if (k > backward.middleK)
maxK = k;
}
@Override
- final int getLeft(final int x) {
+ final int getLeft(int x) {
return x - 1;
}
@Override
- final int getRight(final int x) {
+ final int getRight(int x) {
return x;
}
@Override
- final boolean isBetter(final int left, final int right) {
+ final boolean isBetter(int left, int right) {
return left < right;
}
@Override
- final void adjustMinMaxK(final int k, final int x) {
+ final void adjustMinMaxK(int k, int x) {
if (x <= beginA || k + x <= beginB) {
if (k > forward.middleK)
maxK = k;
}
}
- void hash(byte[] raw, int ptr, final int end) throws TableFullException {
+ void hash(byte[] raw, int ptr, int end) throws TableFullException {
final boolean text = !RawText.isBinary(raw);
hashedCnt = 0;
while (ptr < end) {
}
};
- static int cmp(final DirCacheEntry a, final DirCacheEntry b) {
+ static int cmp(DirCacheEntry a, DirCacheEntry b) {
return cmp(a.path, a.path.length, b);
}
- static int cmp(final byte[] aPath, final int aLen, final DirCacheEntry b) {
+ static int cmp(byte[] aPath, int aLen, DirCacheEntry b) {
return cmp(aPath, aLen, b.path, b.path.length);
}
return new DirCacheEditor(this, entryCnt + 16);
}
- void replace(final DirCacheEntry[] e, final int cnt) {
+ void replace(DirCacheEntry[] e, int cnt) {
sortedEntries = e;
entryCnt = cnt;
tree = null;
}
}
- void writeTo(File dir, final OutputStream os) throws IOException {
+ void writeTo(File dir, OutputStream os) throws IOException {
final MessageDigest foot = Constants.newMessageDigest();
final DigestOutputStream dos = new DigestOutputStream(os, foot);
return nextIdx;
}
- int nextEntry(final byte[] p, final int pLen, int nextIdx) {
+ int nextEntry(byte[] p, int pLen, int nextIdx) {
while (nextIdx < entryCnt) {
final DirCacheEntry next = sortedEntries[nextIdx];
if (!DirCacheTree.peq(p, next.path, pLen))
System.arraycopy(src.info, src.infoOffset, info, 0, INFO_LEN);
}
- void write(final OutputStream os) throws IOException {
+ void write(OutputStream os) throws IOException {
final int len = isExtended() ? INFO_LEN_EXTENDED : INFO_LEN;
final int pathLen = path.length;
os.write(info, infoOffset, len);
* @param keepStage
* if true, the stage attribute will not be copied
*/
- void copyMetaData(final DirCacheEntry src, boolean keepStage) {
+ void copyMetaData(DirCacheEntry src, boolean keepStage) {
int origflags = NB.decodeUInt16(info, infoOffset + P_FLAGS);
int newflags = NB.decodeUInt16(src.info, src.infoOffset + P_FLAGS);
System.arraycopy(src.info, src.infoOffset, info, infoOffset, INFO_LEN);
}
}
- static String toString(final byte[] path) {
+ static String toString(byte[] path) {
return Constants.CHARSET.decode(ByteBuffer.wrap(path)).toString();
}
parseEntry();
}
- DirCacheIterator(final DirCacheIterator p, final DirCacheTree dct) {
+ DirCacheIterator(DirCacheIterator p, DirCacheTree dct) {
super(p, p.path, p.pathLen + 1);
cache = p.cache;
tree = dct;
childCnt = subcnt;
}
- void write(final byte[] tmp, final OutputStream os) throws IOException {
+ void write(byte[] tmp, OutputStream os) throws IOException {
int ptr = tmp.length;
tmp[--ptr] = '\n';
ptr = RawParseUtils.formatBase10(tmp, ptr, childCnt);
return encodedName.length;
}
- final boolean contains(final byte[] a, int aOff, final int aLen) {
+ final boolean contains(byte[] a, int aOff, int aLen) {
final byte[] e = encodedName;
final int eLen = e.length;
for (int eOff = 0; eOff < eLen && aOff < aLen; eOff++, aOff++)
children[n] = null;
}
- static boolean peq(final byte[] a, final byte[] b, int aLen) {
+ static boolean peq(byte[] a, byte[] b, int aLen) {
if (b.length < aLen)
return false;
for (aLen--; aLen >= 0; aLen--)
private static String format(Collection<Throwable> causes) {
final StringBuilder msg = new StringBuilder();
msg.append(JGitText.get().failureDueToOneOfTheFollowing);
- for (final Throwable c : causes) {
+ for (Throwable c : causes) {
msg.append(" "); //$NON-NLS-1$
msg.append(c.getMessage());
msg.append("\n"); //$NON-NLS-1$
private static String format(Map<ObjectId, String> missingCommits) {
final StringBuilder r = new StringBuilder();
r.append(JGitText.get().missingPrerequisiteCommits);
- for (final Map.Entry<ObjectId, String> e : missingCommits.entrySet()) {
+ for (Map.Entry<ObjectId, String> e : missingCommits.entrySet()) {
r.append("\n "); //$NON-NLS-1$
r.append(e.getKey().name());
if (e.getValue() != null)
private final boolean inverse;
- GroupHead(String pattern, final String wholePattern)
+ GroupHead(String pattern, String wholePattern)
throws InvalidPatternException {
super(false);
this.characterClasses = new ArrayList<>();
private static final class OneCharacterPattern implements CharacterPattern {
private char expectedCharacter;
- OneCharacterPattern(final char c) {
+ OneCharacterPattern(char c) {
this.expectedCharacter = c;
}
final class RestrictedWildCardHead extends AbstractHead {
private final char excludedCharacter;
- RestrictedWildCardHead(final char excludedCharacter, final boolean star) {
+ RestrictedWildCardHead(char excludedCharacter, boolean star) {
super(star);
this.excludedCharacter = excludedCharacter;
}
} while (!packList.compareAndSet(o, n));
}
- PackList scanPacks(final PackList original) throws IOException {
+ PackList scanPacks(PackList original) throws IOException {
PackList o, n;
synchronized (packList) {
do {
/** Length of the data section of the object. */
long length;
- DfsObjectToPack(AnyObjectId src, final int type) {
+ DfsObjectToPack(AnyObjectId src, int type) {
super(src, type);
}
final class ByteArrayWindow extends ByteWindow {
private final byte[] array;
- ByteArrayWindow(final PackFile pack, final long o, final byte[] b) {
+ ByteArrayWindow(PackFile pack, long o, byte[] b) {
super(pack, o, b.length);
array = b;
}
final class ByteBufferWindow extends ByteWindow {
private final ByteBuffer buffer;
- ByteBufferWindow(final PackFile pack, final long o, final ByteBuffer b) {
+ ByteBufferWindow(PackFile pack, long o, ByteBuffer b) {
super(pack, o, b.capacity());
buffer = b;
}
return (int) (end - start);
}
- final boolean contains(final PackFile neededFile, final long neededPos) {
+ final boolean contains(PackFile neededFile, long neededPos) {
return pack == neededFile && start <= neededPos && neededPos < end;
}
}
@Override
- ObjectLoader openObject(final WindowCursor curs, final AnyObjectId objectId)
+ ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId)
throws IOException {
return openObject(curs, objectId, null);
}
cache = new Slot[CACHE_SZ];
}
- Entry get(final PackFile pack, final long position) {
+ Entry get(PackFile pack, long position) {
Slot e = cache[hash(position)];
if (e == null)
return null;
final int type;
- Entry(final byte[] aData, final int aType) {
+ Entry(byte[] aData, int aType) {
data = aData;
type = aType;
}
}
List<ObjectIdSet> excluded = new LinkedList<>();
- for (final PackFile f : repo.getObjectDatabase().getPacks()) {
+ for (PackFile f : repo.getObjectDatabase().getPacks()) {
checkCancelled();
if (f.shouldBeKept())
excluded.add(f.getIndex());
/** Length of the data section of the object. */
long length;
- LocalObjectToPack(AnyObjectId src, final int type) {
+ LocalObjectToPack(AnyObjectId src, int type) {
super(src, type);
}
// Fully close all loaded alternates and clear the alternate list.
AlternateHandle[] alt = alternates.get();
if (alt != null && alternates.compareAndSet(alt, null)) {
- for(final AlternateHandle od : alt)
+ for(AlternateHandle od : alt)
od.close();
}
}
WindowCursor curs, Set<AlternateHandle.Id> skips) throws IOException {
PackList pList = packList.get();
SEARCH: for (;;) {
- for (final PackFile p : pList.packs) {
+ for (PackFile p : pList.packs) {
try {
LocalObjectRepresentation rep = p.representation(curs, otp);
p.resetTransientErrorCount();
final Set<String> names = listPackDirectory();
final List<PackFile> list = new ArrayList<>(names.size() >> 2);
boolean foundNew = false;
- for (final String indexName : names) {
+ for (String indexName : names) {
// Must match "pack-[0-9a-f]{40}.idx" to be an index.
//
if (indexName.length() != 49 || !indexName.endsWith(".idx")) //$NON-NLS-1$
return old;
}
- for (final PackFile p : forReuse.values()) {
+ for (PackFile p : forReuse.values()) {
p.close();
}
private static Map<String, PackFile> reuseMap(PackList old) {
final Map<String, PackFile> forReuse = new HashMap<>();
- for (final PackFile p : old.packs) {
+ for (PackFile p : old.packs) {
if (p.invalid()) {
// The pack instance is corrupted, and cannot be safely used
// again. Do not include it in our reuse map.
if (nameList == null)
return Collections.emptySet();
final Set<String> nameSet = new HashSet<>(nameList.length << 1);
- for (final String name : nameList) {
+ for (String name : nameList) {
if (name.startsWith("pack-")) //$NON-NLS-1$
nameSet.add(name);
}
/** All known packs, sorted by {@link PackFile#SORT}. */
final PackFile[] packs;
- PackList(final FileSnapshot monitor, final PackFile[] packs) {
+ PackList(FileSnapshot monitor, PackFile[] packs) {
this.snapshot = monitor;
this.packs = packs;
}
private Deflater deflate;
- ObjectDirectoryInserter(final FileObjectDatabase dest, final Config cfg) {
+ ObjectDirectoryInserter(FileObjectDatabase dest, Config cfg) {
db = dest;
config = cfg.get(WriteConfig.KEY);
}
}
}
- void writeHeader(OutputStream out, final int type, long len)
+ void writeHeader(OutputStream out, int type, long len)
throws IOException {
out.write(Constants.encodedTypeString(type));
out.write((byte) ' ');
return File.createTempFile("noz", null, db.getDirectory()); //$NON-NLS-1$
}
- DeflaterOutputStream compress(final OutputStream out) {
+ DeflaterOutputStream compress(OutputStream out) {
if (deflate == null)
deflate = new Deflater(config.getCompression());
else
* @throws IOException
* the pack file or the index could not be read.
*/
- ObjectLoader get(final WindowCursor curs, final AnyObjectId id)
+ ObjectLoader get(WindowCursor curs, AnyObjectId id)
throws IOException {
final long offset = idx().findOffset(id);
return 0 < offset && !isCorrupt(offset) ? load(curs, offset) : null;
* @throws IOException
* the index file cannot be loaded into memory.
*/
- ObjectId findObjectForOffset(final long offset) throws IOException {
+ ObjectId findObjectForOffset(long offset) throws IOException {
return getReverseIdx().findObject(offset);
}
}
}
- ByteArrayWindow read(final long pos, int size) throws IOException {
+ ByteArrayWindow read(long pos, int size) throws IOException {
synchronized (readLock) {
if (length < pos + size)
size = (int) (length - pos);
}
}
- ByteWindow mmap(final long pos, int size) throws IOException {
+ ByteWindow mmap(long pos, int size) throws IOException {
synchronized (readLock) {
if (length < pos + size)
size = (int) (length - pos);
}
}
- ObjectLoader load(final WindowCursor curs, long pos)
+ ObjectLoader load(WindowCursor curs, long pos)
throws IOException, LargeObjectException {
try {
final byte[] ib = curs.tempId;
return hdr;
}
- int getObjectType(final WindowCursor curs, long pos) throws IOException {
+ int getObjectType(WindowCursor curs, long pos) throws IOException {
final byte[] ib = curs.tempId;
for (;;) {
readFully(pos, ib, 0, 20, curs);
}
}
- long getObjectSize(final WindowCursor curs, final AnyObjectId id)
+ long getObjectSize(WindowCursor curs, AnyObjectId id)
throws IOException {
final long offset = idx().findOffset(id);
return 0 < offset ? getObjectSize(curs, offset) : -1;
}
- long getObjectSize(final WindowCursor curs, final long pos)
+ long getObjectSize(WindowCursor curs, long pos)
throws IOException {
final byte[] ib = curs.tempId;
readFully(pos, ib, 0, 20, curs);
@Override
public long getOffset64Count() {
long n64 = 0;
- for (final MutableEntry e : this) {
+ for (MutableEntry e : this) {
if (e.getOffset() >= Integer.MAX_VALUE)
n64++;
}
*/
public static int oldestPossibleFormat(
final List<? extends PackedObjectInfo> objs) {
- for (final PackedObjectInfo oe : objs) {
+ for (PackedObjectInfo oe : objs) {
if (!PackIndexWriterV1.canStore(oe))
return 2;
}
*/
protected void writeFanOutTable() throws IOException {
final int[] fanout = new int[256];
- for (final PackedObjectInfo po : entries)
+ for (PackedObjectInfo po : entries)
fanout[po.getFirstByte() & 0xff]++;
for (int i = 1; i < 256; i++)
fanout[i] += fanout[i - 1];
- for (final int n : fanout) {
+ for (int n : fanout) {
NB.encodeInt32(tmp, 0, n);
out.write(tmp, 0, 4);
}
* @see PackIndexV1
*/
class PackIndexWriterV1 extends PackIndexWriter {
- static boolean canStore(final PackedObjectInfo oe) {
+ static boolean canStore(PackedObjectInfo oe) {
// We are limited to 4 GB per pack as offset is 32 bit unsigned int.
//
return oe.getOffset() >>> 1 < Integer.MAX_VALUE;
protected void writeImpl() throws IOException {
writeFanOutTable();
- for (final PackedObjectInfo oe : entries) {
+ for (PackedObjectInfo oe : entries) {
if (!canStore(oe))
throw new IOException(JGitText.get().packTooLargeForIndexVersion1);
NB.encodeInt32(tmp, 0, (int) oe.getOffset());
}
private void writeObjectNames() throws IOException {
- for (final PackedObjectInfo oe : entries)
+ for (PackedObjectInfo oe : entries)
oe.copyRawTo(out);
}
private void writeCRCs() throws IOException {
- for (final PackedObjectInfo oe : entries) {
+ for (PackedObjectInfo oe : entries) {
NB.encodeInt32(tmp, 0, oe.getCRC());
out.write(tmp, 0, 4);
}
private void writeOffset32() throws IOException {
int o64 = 0;
- for (final PackedObjectInfo oe : entries) {
+ for (PackedObjectInfo oe : entries) {
final long o = oe.getOffset();
if (o <= MAX_OFFSET_32)
NB.encodeInt32(tmp, 0, (int) o);
}
private void writeOffset64() throws IOException {
- for (final PackedObjectInfo oe : entries) {
+ for (PackedObjectInfo oe : entries) {
final long o = oe.getOffset();
if (MAX_OFFSET_32 < o) {
NB.encodeInt64(tmp, 0, o);
long maxOffset = 0;
int ith = 0;
- for (final MutableEntry me : index) {
+ for (MutableEntry me : index) {
final long o = me.getOffset();
offsetsBySha1[ith++] = o;
if (o > maxOffset)
private List<Integer> retrySleepMs = RETRY_SLEEP_MS;
- RefDirectory(final FileRepository db) {
+ RefDirectory(FileRepository db) {
final FS fs = db.getFS();
parent = db;
gitDir = db.getDirectory();
RefList.Builder<LooseRef> newLoose;
- LooseScanner(final RefList<LooseRef> curLoose) {
+ LooseScanner(RefList<LooseRef> curLoose) {
this.curLoose = curLoose;
}
return new File(gitDir, name);
}
- static int levelsIn(final String name) {
+ static int levelsIn(String name) {
int count = 0;
for (int p = name.indexOf('/'); p >= 0; p = name.indexOf('/', p + 1))
count++;
return count;
}
- static void delete(final File file, final int depth) throws IOException {
+ static void delete(File file, int depth) throws IOException {
delete(file, depth, null);
}
objId = source.getOldObjectId();
updateHEAD = needToUpdateHEAD();
tmp = refdb.newTemporaryUpdate();
- try (final RevWalk rw = new RevWalk(refdb.getRepository())) {
+ try (RevWalk rw = new RevWalk(refdb.getRepository())) {
// First backup the source so its never unreachable.
tmp.setNewObjectId(objId);
tmp.setForceUpdate(true);
private boolean shouldDeref;
private LockFile lock;
- RefDirectoryUpdate(final RefDirectory r, final Ref ref) {
+ RefDirectoryUpdate(RefDirectory r, Ref ref) {
super(ref);
database = r;
}
}
}
- static boolean isStandardFormat(final byte[] hdr) {
+ static boolean isStandardFormat(byte[] hdr) {
/*
* We must determine if the buffer contains the standard
* zlib-deflated stream or the experimental format based
return cache;
}
- static final ByteWindow get(final PackFile pack, final long offset)
+ static final ByteWindow get(PackFile pack, long offset)
throws IOException {
final WindowCache c = cache;
final ByteWindow r = c.getOrLoad(pack, c.toStart(offset));
return r;
}
- static final void purge(final PackFile pack) {
+ static final void purge(PackFile pack) {
cache.removeAll(pack);
}
*/
volatile boolean dead;
- Entry(final Entry n, final Ref r) {
+ Entry(Entry n, Ref r) {
next = n;
ref = r;
}
inf.reset();
}
- void pin(final PackFile pack, final long position)
+ void pin(PackFile pack, long position)
throws IOException {
final ByteWindow w = window;
if (w == null || !w.contains(pack, position)) {
// The caller gave us an executor, but it might not do
// asynchronous execution. Wrap everything and hope it
// can schedule these for us.
- for (final DeltaTask task : taskBlock.tasks) {
+ for (DeltaTask task : taskBlock.tasks) {
executor.execute(new Runnable() {
@Override
public void run() {
return r << (8 - n) * 4;
}
- static int mask(final int nibbles, final int word, final int v) {
+ static int mask(int nibbles, int word, int v) {
final int b = (word - 1) * 8;
if (b + 8 <= nibbles) {
// We have all of the bits required for this word.
private static final char[] hexchar = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
- static void formatHexChar(final char[] dst, final int p, int w) {
+ static void formatHexChar(char[] dst, int p, int w) {
int o = p + 7;
while (o >= p && w != 0) {
dst[o--] = hexchar[w & 0xf];
*/
public String toText() {
final StringBuilder out = new StringBuilder();
- for (final ConfigLine e : state.get().entryList) {
+ for (ConfigLine e : state.get().entryList) {
if (e.prefix != null)
out.append(e.prefix);
if (e.section != null && e.name == null) {
private int pos;
- StringReader(final String in) {
+ StringReader(String in) {
buf = in.toCharArray();
}
/** The text content after entry. */
String suffix;
- ConfigLine forValue(final String newValue) {
+ ConfigLine forValue(String newValue) {
final ConfigLine e = new ConfigLine();
e.prefix = prefix;
e.section = section;
&& eqIgnoreCase(name, aKey);
}
- boolean match(final String aSection, final String aSubsection) {
+ boolean match(String aSection, String aSubsection) {
return eqIgnoreCase(section, aSection)
&& eqSameCase(subsection, aSubsection);
}
}
private static boolean match(String a, String... cases) {
- for (final String b : cases) {
+ for (String b : cases) {
if (b != null && b.equalsIgnoreCase(a)) {
return true;
}
* the object store cannot be accessed.
*/
public boolean has(AnyObjectId objectId) throws IOException {
- try (final ObjectReader or = newReader()) {
+ try (ObjectReader or = newReader()) {
return or.has(objectId);
}
}
public ObjectLoader open(AnyObjectId objectId, int typeHint)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
- try (final ObjectReader or = newReader()) {
+ try (ObjectReader or = newReader()) {
return or.open(objectId, typeHint);
}
}
public void writeInfoRefs() throws IOException {
final StringWriter w = new StringWriter();
final char[] tmp = new char[Constants.OBJECT_ID_STRING_LENGTH];
- for (final Ref r : refs) {
+ for (Ref r : refs) {
if (Constants.HEAD.equals(r.getName())) {
// Historically HEAD has never been published through
// the INFO_REFS file. This is a mistake, but its the
*/
public void writePackedRefs() throws IOException {
boolean peeled = false;
- for (final Ref r : refs) {
+ for (Ref r : refs) {
if (r.getStorage().isPacked() && r.isPeeled()) {
peeled = true;
break;
}
final char[] tmp = new char[Constants.OBJECT_ID_STRING_LENGTH];
- for (final Ref r : refs) {
+ for (Ref r : refs) {
if (r.getStorage() != Ref.Storage.PACKED)
continue;
private ObjectId resultTree;
- InCoreMerger(final Repository local) {
+ InCoreMerger(Repository local) {
super(local);
tw = new NameConflictTreeWalk(local, reader);
cache = DirCache.newInCore();
}
- InCoreMerger(final ObjectInserter inserter) {
+ InCoreMerger(ObjectInserter inserter) {
super(inserter);
tw = new NameConflictTreeWalk(null, reader);
cache = DirCache.newInCore();
/** Inflated length of the data. */
private int length;
- BinaryHunk(final FileHeader fh, final int offset) {
+ BinaryHunk(FileHeader fh, int offset) {
file = fh;
startOffset = offset;
}
return length;
}
- int parseHunk(int ptr, final int end) {
+ int parseHunk(int ptr, int end) {
final byte[] buf = file.buf;
if (match(buf, ptr, LITERAL) >= 0) {
private FileMode[] oldModes;
- CombinedFileHeader(final byte[] b, final int offset) {
+ CombinedFileHeader(byte[] b, int offset) {
super(b, offset);
}
}
@Override
- int parseGitHeaders(int ptr, final int end) {
+ int parseGitHeaders(int ptr, int end) {
while (ptr < end) {
final int eol = nextLF(buf, ptr);
if (isHunkHdr(buf, ptr, end) >= 1) {
}
@Override
- HunkHeader newHunkHeader(final int offset) {
+ HunkHeader newHunkHeader(int offset) {
return new CombinedHunkHeader(this, offset);
}
private CombinedOldImage[] old;
- CombinedHunkHeader(final CombinedFileHeader fh, final int offset) {
+ CombinedHunkHeader(CombinedFileHeader fh, int offset) {
super(fh, offset, null);
old = new CombinedOldImage[fh.getParentCount()];
for (int i = 0; i < old.length; i++) {
}
@Override
- int parseBody(final Patch script, final int end) {
+ int parseBody(Patch script, int end) {
final byte[] buf = file.buf;
int c = nextLF(buf, startOffset);
- for (final CombinedOldImage o : old) {
+ for (CombinedOldImage o : old) {
o.nDeleted = 0;
o.nAdded = 0;
o.nContext = 0;
}
@Override
- void extractFileLines(final OutputStream[] out) throws IOException {
+ void extractFileLines(OutputStream[] out) throws IOException {
final byte[] buf = file.buf;
int ptr = startOffset;
int eol = nextLF(buf, ptr);
addHunk(new HunkHeader(this, edits));
}
- FileHeader(final byte[] b, final int offset) {
+ FileHeader(byte[] b, int offset) {
buf = b;
startOffset = offset;
changeType = ChangeType.MODIFY; // unless otherwise designated
final String[] files = extractFileLines(charsetGuess);
final int[] offsets = new int[files.length];
- for (final HunkHeader h : getHunks())
+ for (HunkHeader h : getHunks())
h.extractFileLines(r, files, offsets);
return r.toString();
}
try {
for (int i = 0; i < tmp.length; i++)
tmp[i] = new TemporaryBuffer.Heap(Integer.MAX_VALUE);
- for (final HunkHeader h : getHunks())
+ for (HunkHeader h : getHunks())
h.extractFileLines(tmp);
final String[] r = new String[tmp.length];
return hunks;
}
- void addHunk(final HunkHeader h) {
+ void addHunk(HunkHeader h) {
if (h.getFileHeader() != this)
throw new IllegalArgumentException(JGitText.get().hunkBelongsToAnotherFile);
if (hunks == null)
hunks.add(h);
}
- HunkHeader newHunkHeader(final int offset) {
+ HunkHeader newHunkHeader(int offset) {
return new HunkHeader(this, offset);
}
*/
public EditList toEditList() {
final EditList r = new EditList();
- for (final HunkHeader hunk : hunks)
+ for (HunkHeader hunk : hunks)
r.addAll(hunk.toEditList());
return r;
}
* one past the last position to parse.
* @return first character after the LF at the end of the line; -1 on error.
*/
- int parseGitFileName(int ptr, final int end) {
+ int parseGitFileName(int ptr, int end) {
final int eol = nextLF(buf, ptr);
final int bol = ptr;
if (eol >= end) {
return eol;
}
- int parseGitHeaders(int ptr, final int end) {
+ int parseGitHeaders(int ptr, int end) {
while (ptr < end) {
final int eol = nextLF(buf, ptr);
if (isHunkHdr(buf, ptr, eol) >= 1) {
return ptr;
}
- void parseOldName(int ptr, final int eol) {
+ void parseOldName(int ptr, int eol) {
oldPath = p1(parseName(oldPath, ptr + OLD_NAME.length, eol));
if (oldPath == DEV_NULL)
changeType = ChangeType.ADD;
}
- void parseNewName(int ptr, final int eol) {
+ void parseNewName(int ptr, int eol) {
newPath = p1(parseName(newPath, ptr + NEW_NAME.length, eol));
if (newPath == DEV_NULL)
changeType = ChangeType.DELETE;
}
- void parseNewFileMode(int ptr, final int eol) {
+ void parseNewFileMode(int ptr, int eol) {
oldMode = FileMode.MISSING;
newMode = parseFileMode(ptr + NEW_FILE_MODE.length, eol);
changeType = ChangeType.ADD;
}
- int parseTraditionalHeaders(int ptr, final int end) {
+ int parseTraditionalHeaders(int ptr, int end) {
while (ptr < end) {
final int eol = nextLF(buf, ptr);
if (isHunkHdr(buf, ptr, eol) >= 1) {
return s > 0 ? r.substring(s + 1) : r;
}
- FileMode parseFileMode(int ptr, final int end) {
+ FileMode parseFileMode(int ptr, int end) {
int tmp = 0;
while (ptr < end - 1) {
tmp <<= 3;
return FileMode.fromBits(tmp);
}
- void parseIndexLine(int ptr, final int end) {
+ void parseIndexLine(int ptr, int end) {
// "index $asha1..$bsha1[ $mode]" where $asha1 and $bsha1
// can be unique abbreviations
//
* for a 3 way-merge returns 3. If this is not a hunk header, 0 is
* returned instead.
*/
- static int isHunkHdr(final byte[] buf, final int start, final int end) {
+ static int isHunkHdr(byte[] buf, int start, int end) {
int ptr = start;
while (ptr < end && buf[ptr] == '@')
ptr++;
private EditList editList;
- HunkHeader(final FileHeader fh, final int offset) {
+ HunkHeader(FileHeader fh, int offset) {
this(fh, offset, new OldImage() {
@Override
public AbbreviatedObjectId getId() {
});
}
- HunkHeader(final FileHeader fh, final int offset, final OldImage oi) {
+ HunkHeader(FileHeader fh, int offset, OldImage oi) {
file = fh;
startOffset = offset;
old = oi;
}
- HunkHeader(final FileHeader fh, final EditList editList) {
+ HunkHeader(FileHeader fh, EditList editList) {
this(fh, fh.buf.length);
this.editList = editList;
endOffset = startOffset;
newLineCount = 1;
}
- int parseBody(final Patch script, final int end) {
+ int parseBody(Patch script, int end) {
final byte[] buf = file.buf;
int c = nextLF(buf, startOffset), last = c;
return c;
}
- void extractFileLines(final OutputStream[] out) throws IOException {
+ void extractFileLines(OutputStream[] out) throws IOException {
final byte[] buf = file.buf;
int ptr = startOffset;
int eol = nextLF(buf, ptr);
return c;
}
- void warn(final byte[] buf, final int ptr, final String msg) {
+ void warn(byte[] buf, int ptr, String msg) {
addError(new FormatError(buf, ptr, FormatError.Severity.WARNING, msg));
}
- void error(final byte[] buf, final int ptr, final String msg) {
+ void error(byte[] buf, int ptr, String msg) {
addError(new FormatError(buf, ptr, FormatError.Severity.ERROR, msg));
}
private static boolean matchAny(final byte[] buf, final int c,
final byte[][] srcs) {
- for (final byte[] s : srcs) {
+ for (byte[] s : srcs) {
if (match(buf, c, s) >= 0)
return true;
}
final TColor myColor = laneColor(myLane);
int maxCenter = myLaneX;
- for (final TLane passingLane : (TLane[]) commit.passingLanes) {
+ for (TLane passingLane : (TLane[]) commit.passingLanes) {
final int cx = laneC(passingLane);
final TColor c = laneColor(passingLane);
drawLine(c, cx, 0, cx, h, LINE_WIDTH);
refs = NO_REFS;
}
- void addForkingOffLane(final PlotLane f) {
+ void addForkingOffLane(PlotLane f) {
forkingOffLanes = addLane(f, forkingOffLanes);
}
- void addPassingLane(final PlotLane c) {
+ void addPassingLane(PlotLane c) {
passingLanes = addLane(c, passingLanes);
}
- void addMergingLane(final PlotLane m) {
+ void addMergingLane(PlotLane m) {
mergingLanes = addLane(m, mergingLanes);
}
return lanes;
}
- void addChild(final PlotCommit c) {
+ void addChild(PlotCommit c) {
final int cnt = children.length;
if (cnt == 0)
children = new PlotCommit[] { c };
* @return true if the given commit built on top of this commit.
*/
public final boolean isChild(PlotCommit c) {
- for (final PlotCommit a : children)
+ for (PlotCommit a : children)
if (a == c)
return true;
return false;
@SuppressWarnings("unchecked")
public void findPassingThrough(final PlotCommit<L> currCommit,
final Collection<L> result) {
- for (final PlotLane p : currCommit.passingLanes)
+ for (PlotLane p : currCommit.passingLanes)
result.add((L) p);
}
free = new BlockFreeList();
}
- void add(final RevObject c) {
+ void add(RevObject c) {
Block b = tail;
if (b == null) {
b = free.newBlock();
return b;
}
- void freeBlock(final Block b) {
+ void freeBlock(Block b) {
b.next = next;
next = b;
}
return headIndex == tailIndex;
}
- void add(final RevObject c) {
+ void add(RevObject c) {
objects[tailIndex++] = c;
}
free = new BlockFreeList();
}
- BlockRevQueue(final Generator s) throws MissingObjectException,
+ BlockRevQueue(Generator s) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
free = new BlockFreeList();
outputType = s.outputType();
return b;
}
- void freeBlock(final Block b) {
+ void freeBlock(Block b) {
b.next = next;
next = b;
}
return headIndex > 0;
}
- void add(final RevCommit c) {
+ void add(RevCommit c) {
commits[tailIndex++] = c;
}
- void unpop(final RevCommit c) {
+ void unpop(RevCommit c) {
commits[--headIndex] = c;
}
Generator g;
- BoundaryGenerator(final RevWalk w, final Generator s) {
+ BoundaryGenerator(RevWalk w, Generator s) {
g = new InitialGenerator(w, s);
}
}
@Override
- void shareFreeList(final BlockRevQueue q) {
+ void shareFreeList(BlockRevQueue q) {
g.shareFreeList(q);
}
private final Generator source;
- InitialGenerator(final RevWalk w, final Generator s) {
+ InitialGenerator(RevWalk w, Generator s) {
walk = w;
held = new FIFORevQueue();
source = s;
}
@Override
- void shareFreeList(final BlockRevQueue q) {
+ void shareFreeList(BlockRevQueue q) {
q.shareFreeList(held);
}
IncorrectObjectTypeException, IOException {
RevCommit c = source.next();
if (c != null) {
- for (final RevCommit p : c.parents)
+ for (RevCommit p : c.parents)
if ((p.flags & UNINTERESTING) != 0)
held.add(p);
return c;
super();
}
- DateRevQueue(final Generator s) throws MissingObjectException,
+ DateRevQueue(Generator s) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
for (;;) {
final RevCommit c = s.next();
}
@Override
- boolean everbodyHasFlag(final int f) {
+ boolean everbodyHasFlag(int f) {
for (Entry q = head; q != null; q = q.next) {
if ((q.commit.flags & f) == 0)
return false;
}
@Override
- boolean anybodyHasFlag(final int f) {
+ boolean anybodyHasFlag(int f) {
for (Entry q = head; q != null; q = q.next) {
if ((q.commit.flags & f) != 0)
return true;
private int size;
- DelayRevQueue(final Generator g) {
+ DelayRevQueue(Generator g) {
pending = g;
delay = new FIFORevQueue();
}
}
@Override
- void shareFreeList(final BlockRevQueue q) {
+ void shareFreeList(BlockRevQueue q) {
pending.shareFreeList(q);
}
int newDepth = c.depth + 1;
- for (final RevCommit p : c.parents) {
+ for (RevCommit p : c.parents) {
DepthWalk.Commit dp = (DepthWalk.Commit) p;
// If no depth has been assigned to this commit, assign
super();
}
- FIFORevQueue(final Generator s) throws MissingObjectException,
+ FIFORevQueue(Generator s) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
super(s);
}
}
@Override
- boolean everbodyHasFlag(final int f) {
+ boolean everbodyHasFlag(int f) {
for (Block b = head; b != null; b = b.next) {
for (int i = b.headIndex; i < b.tailIndex; i++)
if ((b.commits[i].flags & f) == 0)
}
@Override
- boolean anybodyHasFlag(final int f) {
+ boolean anybodyHasFlag(int f) {
for (Block b = head; b != null; b = b.next) {
for (int i = b.headIndex; i < b.tailIndex; i++)
if ((b.commits[i].flags & f) != 0)
return false;
}
- void removeFlag(final int f) {
+ void removeFlag(int f) {
final int not_f = ~f;
for (Block b = head; b != null; b = b.next) {
for (int i = b.headIndex; i < b.tailIndex; i++)
final class FixUninterestingGenerator extends Generator {
private final Generator pending;
- FixUninterestingGenerator(final Generator g) {
+ FixUninterestingGenerator(Generator g) {
pending = g;
}
private RenameCallback renameCallback;
- FollowFilter(final PathFilter path, final DiffConfig cfg) {
+ FollowFilter(PathFilter path, DiffConfig cfg) {
this.path = path;
this.cfg = cfg;
}
* @param q
* another FIFO queue that wants to share our queue's free list.
*/
- void shareFreeList(final BlockRevQueue q) {
+ void shareFreeList(BlockRevQueue q) {
// Do nothing by default.
}
super();
}
- LIFORevQueue(final Generator s) throws MissingObjectException,
+ LIFORevQueue(Generator s) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
super(s);
}
}
@Override
- boolean everbodyHasFlag(final int f) {
+ boolean everbodyHasFlag(int f) {
for (Block b = head; b != null; b = b.next) {
for (int i = b.headIndex; i < b.tailIndex; i++)
if ((b.commits[i].flags & f) == 0)
}
@Override
- boolean anybodyHasFlag(final int f) {
+ boolean anybodyHasFlag(int f) {
for (Block b = head; b != null; b = b.next) {
for (int i = b.headIndex; i < b.tailIndex; i++)
if ((b.commits[i].flags & f) != 0)
private CarryStack stack;
- MergeBaseGenerator(final RevWalk w) {
+ MergeBaseGenerator(RevWalk w) {
walker = w;
pending = new DateRevQueue();
}
- void init(final AbstractRevQueue p) throws IOException {
+ void init(AbstractRevQueue p) throws IOException {
try {
for (;;) {
final RevCommit c = p.next();
return null;
}
- for (final RevCommit p : c.parents) {
+ for (RevCommit p : c.parents) {
if ((p.flags & IN_PENDING) != 0)
continue;
if ((p.flags & PARSED) == 0)
produce = filter.include(walker, c);
}
- for (final RevCommit p : c.parents) {
+ for (RevCommit p : c.parents) {
if ((p.flags & SEEN) != 0)
continue;
if ((p.flags & PARSED) == 0)
}
@Override
- void parseHeaders(final RevWalk walk) throws MissingObjectException,
+ void parseHeaders(RevWalk walk) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
parseCanonical(walk, walk.getCachedBytes(this));
}
@Override
- void parseBody(final RevWalk walk) throws MissingObjectException,
+ void parseBody(RevWalk walk) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
if (buffer == null) {
buffer = walk.getCachedBytes(this);
}
}
- void parseCanonical(final RevWalk walk, final byte[] raw)
+ void parseCanonical(RevWalk walk, byte[] raw)
throws IOException {
if (!walk.shallowCommitsInitialized)
walk.initializeShallowCommits();
return str;
}
- static boolean hasLF(final byte[] r, int b, final int e) {
+ static boolean hasLF(byte[] r, int b, int e) {
while (b < e)
if (r[b++] == '\n')
return true;
if (src.isEmpty())
return Collections.emptyList();
final ArrayList<String> r = new ArrayList<>(src.size());
- for (final FooterLine f : src) {
+ for (FooterLine f : src) {
if (f.matches(keyName))
r.add(f.getValue());
}
final int mask;
- RevFlag(final RevWalk w, final String n, final int m) {
+ RevFlag(RevWalk w, String n, int m) {
walker = w;
name = n;
mask = m;
}
static class StaticRevFlag extends RevFlag {
- StaticRevFlag(final String n, final int m) {
+ StaticRevFlag(String n, int m) {
super(null, n, m);
}
int flags;
- RevObject(final AnyObjectId name) {
+ RevObject(AnyObjectId name) {
super(name);
}
final int shift;
- Block(final int s) {
+ Block(int s) {
shift = s;
}
}
}
@Override
- void parseHeaders(final RevWalk walk) throws MissingObjectException,
+ void parseHeaders(RevWalk walk) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
parseCanonical(walk, walk.getCachedBytes(this));
}
@Override
- void parseBody(final RevWalk walk) throws MissingObjectException,
+ void parseBody(RevWalk walk) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
if (buffer == null) {
buffer = walk.getCachedBytes(this);
}
}
- void parseCanonical(final RevWalk walk, final byte[] rawTag)
+ void parseCanonical(RevWalk walk, byte[] rawTag)
throws CorruptObjectException {
final MutableInteger pos = new MutableInteger();
final int oType;
public void markStart(Collection<RevCommit> list)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
- for (final RevCommit c : list)
+ for (RevCommit c : list)
markStart(c);
}
* the flags to carry onto parents, if set on a descendant.
*/
public void carry(Collection<RevFlag> set) {
- for (final RevFlag flag : set)
+ for (RevFlag flag : set)
carry(flag);
}
freeFlag(flag.mask);
}
- void freeFlag(final int mask) {
+ void freeFlag(int mask) {
retainOnReset &= ~mask;
if (isNotStarted()) {
freeFlags |= mask;
*/
public final void resetRetain(RevFlag... retainFlags) {
int mask = 0;
- for (final RevFlag flag : retainFlags)
+ for (RevFlag flag : retainFlags)
mask |= flag.mask;
reset(mask);
}
final int clearFlags = ~retainFlags;
final FIFORevQueue q = new FIFORevQueue();
- for (final RevCommit c : roots) {
+ for (RevCommit c : roots) {
if ((c.flags & clearFlags) == 0)
continue;
c.flags &= retainFlags;
break;
if (c.parents == null)
continue;
- for (final RevCommit p : c.parents) {
+ for (RevCommit p : c.parents) {
if ((p.flags & clearFlags) == 0)
continue;
p.flags &= retainFlags;
return new RevCommit(id);
}
- void carryFlagsImpl(final RevCommit c) {
+ void carryFlagsImpl(RevCommit c) {
final int carry = c.flags & carryFlags;
if (carry != 0)
RevCommit.carryFlags(c, carry);
private final Generator source;
- RewriteGenerator(final Generator s) {
+ RewriteGenerator(Generator s) {
source = s;
}
@Override
- void shareFreeList(final BlockRevQueue q) {
+ void shareFreeList(BlockRevQueue q) {
source.shareFreeList(q);
}
}
if (newCnt == oldList.length) {
- for (final RevCommit p : oldList)
+ for (RevCommit p : oldList)
p.flags &= ~DUPLICATE;
return oldList;
}
final RevCommit[] newList = new RevCommit[newCnt];
newCnt = 0;
- for (final RevCommit p : oldList) {
+ for (RevCommit p : oldList) {
if (p != null) {
newList[newCnt++] = p;
p.flags &= ~DUPLICATE;
class StartGenerator extends Generator {
private final RevWalk walker;
- StartGenerator(final RevWalk w) {
+ StartGenerator(RevWalk w) {
walker = w;
}
* @throws IncorrectObjectTypeException
* @throws IOException
*/
- TopoSortGenerator(final Generator s) throws MissingObjectException,
+ TopoSortGenerator(Generator s) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
pending = new FIFORevQueue();
outputType = s.outputType() | SORT_TOPO;
final RevCommit c = s.next();
if (c == null)
break;
- for (final RevCommit p : c.parents)
+ for (RevCommit p : c.parents)
p.inDegree++;
pending.add(c);
}
}
@Override
- void shareFreeList(final BlockRevQueue q) {
+ void shareFreeList(BlockRevQueue q) {
q.shareFreeList(pending);
}
// All of our children have already produced,
// so it is OK for us to produce now as well.
//
- for (final RevCommit p : c.parents) {
+ for (RevCommit p : c.parents) {
if (--p.inDegree == 0 && (p.flags & TOPO_DELAY) != 0) {
// This parent tried to come before us, but we are
// his last child. unpop the parent so it goes right
private final boolean requiresCommitBody;
- Binary(final RevFilter one, final RevFilter two) {
+ Binary(RevFilter one, RevFilter two) {
a = one;
b = two;
requiresCommitBody = a.requiresCommitBody()
private final boolean requiresCommitBody;
- List(final RevFilter[] list) {
+ List(RevFilter[] list) {
subfilters = list;
boolean rcb = false;
public boolean include(RevWalk walker, RevCommit c)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
- for (final RevFilter f : subfilters) {
+ for (RevFilter f : subfilters) {
if (!f.include(walker, c))
return false;
}
// Don't permit us to be created.
}
- static RawCharSequence textFor(final RevCommit cmit) {
+ static RawCharSequence textFor(RevCommit cmit) {
final byte[] raw = cmit.getRawBuffer();
final int b = RawParseUtils.author(raw, 0);
if (b < 0)
}
private static class PatternSearch extends PatternMatchRevFilter {
- PatternSearch(final String patternText) {
+ PatternSearch(String patternText) {
super(patternText, true, true, Pattern.CASE_INSENSITIVE);
}
}
private static class SubStringSearch extends SubStringRevFilter {
- SubStringSearch(final String patternText) {
+ SubStringSearch(String patternText) {
super(patternText);
}
final int when;
- CommitTimeRevFilter(final long ts) {
+ CommitTimeRevFilter(long ts) {
when = (int) (ts / 1000);
}
}
private static class Before extends CommitTimeRevFilter {
- Before(final long ts) {
+ Before(long ts) {
super(ts);
}
}
private static class After extends CommitTimeRevFilter {
- After(final long ts) {
+ After(long ts) {
super(ts);
}
private static class Between extends CommitTimeRevFilter {
private final int until;
- Between(final long since, final long until) {
+ Between(long since, long until) {
super(since);
this.until = (int) (until / 1000);
}
// Don't permit us to be created.
}
- static RawCharSequence textFor(final RevCommit cmit) {
+ static RawCharSequence textFor(RevCommit cmit) {
final byte[] raw = cmit.getRawBuffer();
final int b = RawParseUtils.committer(raw, 0);
if (b < 0)
}
private static class PatternSearch extends PatternMatchRevFilter {
- PatternSearch(final String patternText) {
+ PatternSearch(String patternText) {
super(patternText, true, true, Pattern.CASE_INSENSITIVE);
}
}
private static class SubStringSearch extends SubStringRevFilter {
- SubStringSearch(final String patternText) {
+ SubStringSearch(String patternText) {
super(patternText);
}
// Don't permit us to be created.
}
- static RawCharSequence textFor(final RevCommit cmit) {
+ static RawCharSequence textFor(RevCommit cmit) {
final byte[] raw = cmit.getRawBuffer();
final int b = RawParseUtils.commitMessage(raw, 0);
if (b < 0)
}
private static class PatternSearch extends PatternMatchRevFilter {
- PatternSearch(final String patternText) {
+ PatternSearch(String patternText) {
super(patternText, true, true, Pattern.CASE_INSENSITIVE
| Pattern.DOTALL);
}
}
private static class SubStringSearch extends SubStringRevFilter {
- SubStringSearch(final String patternText) {
+ SubStringSearch(String patternText) {
super(patternText);
}
private final boolean requiresCommitBody;
- Binary(final RevFilter one, final RevFilter two) {
+ Binary(RevFilter one, RevFilter two) {
a = one;
b = two;
requiresCommitBody = a.requiresCommitBody()
private final boolean requiresCommitBody;
- List(final RevFilter[] list) {
+ List(RevFilter[] list) {
subfilters = list;
boolean rcb = false;
public boolean include(RevWalk walker, RevCommit c)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
- for (final RevFilter f : subfilters) {
+ for (RevFilter f : subfilters) {
if (f.include(walker, c))
return true;
}
*/
public static RevFilter hasAll(RevFlag... a) {
final RevFlagSet set = new RevFlagSet();
- for (final RevFlag flag : a)
+ for (RevFlag flag : a)
set.add(flag);
return new HasAll(set);
}
*/
public static RevFilter hasAny(RevFlag... a) {
final RevFlagSet set = new RevFlagSet();
- for (final RevFlag flag : a)
+ for (RevFlag flag : a)
set.add(flag);
return new HasAny(set);
}
final RevFlagSet flags;
- RevFlagFilter(final RevFlagSet m) {
+ RevFlagFilter(RevFlagSet m) {
flags = m;
}
}
private static class HasAll extends RevFlagFilter {
- HasAll(final RevFlagSet m) {
+ HasAll(RevFlagSet m) {
super(m);
}
}
private static class HasAny extends RevFlagFilter {
- HasAny(final RevFlagSet m) {
+ HasAny(RevFlagSet m) {
super(m);
}
private static String toCleanString(List<String> list) {
final StringBuilder s = new StringBuilder();
- for (final String v : list) {
+ for (String v : list) {
if (s.length() > 0)
s.append(',');
s.append(v.replaceAll("\n", "").trim()); //$NON-NLS-1$ //$NON-NLS-2$
return err;
}
- IOException maxAttempts(final String action, final String key) {
+ IOException maxAttempts(String action, String key) {
return new IOException(MessageFormat.format(
JGitText.get().amazonS3ActionFailedGivingUp, action, key,
Integer.valueOf(maxAttempts)));
return c;
}
- void authorize(final HttpURLConnection c) throws IOException {
+ void authorize(HttpURLConnection c) throws IOException {
final Map<String, List<String>> reqHdr = c.getRequestProperties();
final SortedMap<String, String> sigHdr = new TreeMap<>();
- for (final Map.Entry<String, List<String>> entry : reqHdr.entrySet()) {
+ for (Map.Entry<String, List<String>> entry : reqHdr.entrySet()) {
final String hdr = entry.getKey();
if (isSignedHeader(hdr))
sigHdr.put(StringUtils.toLowerCase(hdr), toCleanString(entry.getValue()));
s.append(remove(sigHdr, "date")); //$NON-NLS-1$
s.append('\n');
- for (final Map.Entry<String, String> e : sigHdr.entrySet()) {
+ for (Map.Entry<String, String> e : sigHdr.entrySet()) {
s.append(e.getKey());
s.append(':');
s.append(e.getValue());
c.setRequestProperty("Authorization", "AWS " + publicKey + ":" + sec); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- static Properties properties(final File authFile)
+ static Properties properties(File authFile)
throws FileNotFoundException, IOException {
final Properties p = new Properties();
try (FileInputStream in = new FileInputStream(authFile)) {
private StringBuilder data;
- ListParser(final String bn, final String p) {
+ ListParser(String bn, String p) {
bucket = bn;
prefix = p;
}
/** Extra objects the remote has, but which aren't offered as refs. */
protected final Set<ObjectId> additionalHaves = new HashSet<>();
- BasePackConnection(final PackTransport packTransport) {
+ BasePackConnection(PackTransport packTransport) {
transport = (Transport) packTransport;
local = transport.local;
uri = transport.uri;
final boolean minimalNegotiation;
- FetchConfig(final Config c) {
+ FetchConfig(Config c) {
allowOfsDelta = c.getBoolean("repack", "usedeltabaseoffset", true); //$NON-NLS-1$ //$NON-NLS-2$
minimalNegotiation = c.getBoolean("fetch", "useminimalnegotiation", //$NON-NLS-1$ //$NON-NLS-2$
false);
private int maxTimeWanted(Collection<Ref> wants) {
int maxTime = 0;
- for (final Ref r : wants) {
+ for (Ref r : wants) {
try {
final RevObject obj = walk.parseAny(r.getObjectId());
if (obj instanceof RevCommit) {
private boolean sendWants(Collection<Ref> want) throws IOException {
final PacketLineOut p = statelessRPC ? pckState : pckOut;
boolean first = true;
- for (final Ref r : want) {
+ for (Ref r : want) {
ObjectId objectId = r.getObjectId();
if (objectId == null) {
continue;
}
private void markRefsAdvertised() {
- for (final Ref r : getRefs()) {
+ for (Ref r : getRefs()) {
markAdvertised(r.getObjectId());
if (r.getPeeledObjectId() != null)
markAdvertised(r.getPeeledObjectId());
pushOptions.toString()));
}
- for (final RemoteRefUpdate rru : refUpdates) {
+ for (RemoteRefUpdate rru : refUpdates) {
if (!capableDeleteRefs && rru.isDelete()) {
rru.setStatus(Status.REJECTED_NODELETE);
continue;
}
private void transmitOptions() throws IOException {
- for (final String pushOption : pushOptions) {
+ for (String pushOption : pushOptions) {
pckOut.writeString(pushOption);
}
Set<ObjectId> remoteObjects = new HashSet<>();
Set<ObjectId> newObjects = new HashSet<>();
- try (final PackWriter writer = new PackWriter(transport.getPackConfig(),
+ try (PackWriter writer = new PackWriter(transport.getPackConfig(),
local.newObjectReader())) {
- for (final Ref r : getRefs()) {
+ for (Ref r : getRefs()) {
// only add objects that we actually have
ObjectId oid = r.getObjectId();
if (local.hasObject(oid))
remoteObjects.add(oid);
}
remoteObjects.addAll(additionalHaves);
- for (final RemoteRefUpdate r : refUpdates.values()) {
+ for (RemoteRefUpdate r : refUpdates.values()) {
if (!ObjectId.zeroId().equals(r.getNewObjectId()))
newObjects.add(r.getNewObjectId());
}
rru.setMessage(message);
}
}
- for (final RemoteRefUpdate rru : refUpdates.values()) {
+ for (RemoteRefUpdate rru : refUpdates.values()) {
if (rru.getStatus() == Status.AWAITING_REPORT)
throw new PackProtocolException(MessageFormat.format(
JGitText.get().expectedReportForRefNotReceived , uri, rru.getRemoteName()));
final long maxDiscardBytes;
final SignedPushConfig signedPush;
- ReceiveConfig(final Config config) {
+ ReceiveConfig(Config config) {
allowCreates = true;
allowDeletes = !config.getBoolean("receive", "denydeletes", false); //$NON-NLS-1$ //$NON-NLS-2$
allowNonFastForwards = !config.getBoolean("receive", //$NON-NLS-1$
* @return {@code true} if a pack is expected based on the list of commands.
*/
protected boolean needPack() {
- for (final ReceiveCommand cmd : commands) {
+ for (ReceiveCommand cmd : commands) {
if (cmd.getType() != ReceiveCommand.Type.DELETE)
return true;
}
}
parser = null;
- try (final ObjectWalk ow = new ObjectWalk(db)) {
+ try (ObjectWalk ow = new ObjectWalk(db)) {
if (baseObjects != null) {
ow.sort(RevSort.TOPO);
if (!baseObjects.isEmpty())
ow.sort(RevSort.BOUNDARY, true);
}
- for (final ReceiveCommand cmd : commands) {
+ for (ReceiveCommand cmd : commands) {
if (cmd.getResult() != Result.NOT_ATTEMPTED)
continue;
if (cmd.getType() == ReceiveCommand.Type.DELETE)
continue;
ow.markStart(ow.parseAny(cmd.getNewId()));
}
- for (final ObjectId have : advertisedHaves) {
+ for (ObjectId have : advertisedHaves) {
RevObject o = ow.parseAny(have);
ow.markUninteresting(o);
* Validate the command list.
*/
protected void validateCommands() {
- for (final ReceiveCommand cmd : commands) {
+ for (ReceiveCommand cmd : commands) {
final Ref ref = cmd.getRef();
if (cmd.getResult() != Result.NOT_ATTEMPTED)
continue;
if (unpackError != null) {
out.sendString("unpack error " + unpackError.getMessage()); //$NON-NLS-1$
if (forClient) {
- for (final ReceiveCommand cmd : commands) {
+ for (ReceiveCommand cmd : commands) {
out.sendString("ng " + cmd.getRefName() //$NON-NLS-1$
+ " n/a (unpacker error)"); //$NON-NLS-1$
}
if (forClient)
out.sendString("unpack ok"); //$NON-NLS-1$
- for (final ReceiveCommand cmd : commands) {
+ for (ReceiveCommand cmd : commands) {
if (cmd.getResult() == Result.OK) {
if (forClient)
out.sendString("ok " + cmd.getRefName()); //$NON-NLS-1$
private PackLock packLock;
- BundleFetchConnection(Transport transportBundle, final InputStream src) throws TransportException {
+ BundleFetchConnection(Transport transportBundle, InputStream src) throws TransportException {
transport = transportBundle;
bin = new BufferedInputStream(src);
try {
if (prereqs.isEmpty())
return;
- try (final RevWalk rw = new RevWalk(transport.local)) {
+ try (RevWalk rw = new RevWalk(transport.local)) {
final RevFlag PREREQ = rw.newFlag("PREREQ"); //$NON-NLS-1$
final RevFlag SEEN = rw.newFlag("SEEN"); //$NON-NLS-1$
final Map<ObjectId, String> missing = new HashMap<>();
final List<RevObject> commits = new ArrayList<>();
- for (final Map.Entry<ObjectId, String> e : prereqs.entrySet()) {
+ for (Map.Entry<ObjectId, String> e : prereqs.entrySet()) {
ObjectId p = e.getKey();
try {
final RevCommit c = rw.parseCommit(p);
} catch (IOException e) {
throw new TransportException(transport.uri, e.getMessage(), e);
}
- for (final Ref r : localRefs) {
+ for (Ref r : localRefs) {
try {
rw.markStart(rw.parseCommit(r.getObjectId()));
} catch (IOException readError) {
}
if (remaining > 0) {
- for (final RevObject o : commits) {
+ for (RevObject o : commits) {
if (!o.has(SEEN))
missing.put(o, prereqs.get(o));
}
final HashSet<ObjectId> inc = new HashSet<>();
final HashSet<ObjectId> exc = new HashSet<>();
inc.addAll(include.values());
- for (final RevCommit r : assume)
+ for (RevCommit r : assume)
exc.add(r.getId());
packWriter.setIndexDisabled(true);
packWriter.setDeltaBaseAsOffset(true);
w.write('\n');
final char[] tmp = new char[Constants.OBJECT_ID_STRING_LENGTH];
- for (final RevCommit a : assume) {
+ for (RevCommit a : assume) {
w.write('-');
a.copyTo(tmp, w);
if (a.getRawBuffer() != null) {
}
w.write('\n');
}
- for (final Map.Entry<String, ObjectId> e : include.entrySet()) {
+ for (Map.Entry<String, ObjectId> e : include.entrySet()) {
e.getValue().copyTo(tmp, w);
w.write(' ');
w.write(e.getKey());
public synchronized DaemonService getService(String name) {
if (!name.startsWith("git-")) //$NON-NLS-1$
name = "git-" + name; //$NON-NLS-1$
- for (final DaemonService s : services) {
+ for (DaemonService s : services) {
if (s.getCommandName().equals(name))
return s;
}
}
}
- void startClient(final Socket s) {
+ void startClient(Socket s) {
final DaemonClient dc = new DaemonClient(this);
final SocketAddress peer = s.getRemoteSocketAddress();
}.start();
}
- synchronized DaemonService matchService(final String cmd) {
- for (final DaemonService d : services) {
+ synchronized DaemonService matchService(String cmd) {
+ for (DaemonService d : services) {
if (d.handles(cmd))
return d;
}
private OutputStream rawOut;
- DaemonClient(final Daemon d) {
+ DaemonClient(Daemon d) {
daemon = d;
}
- void setRemoteAddress(final InetAddress ia) {
+ void setRemoteAddress(InetAddress ia) {
peer = ia;
}
return rawOut;
}
- void execute(final Socket sock) throws IOException,
+ void execute(Socket sock) throws IOException,
ServiceNotEnabledException, ServiceNotAuthorizedException {
rawIn = new BufferedInputStream(sock.getInputStream());
rawOut = new BufferedOutputStream(sock.getOutputStream());
private boolean overridable;
- DaemonService(final String cmdName, final String cfgName) {
+ DaemonService(String cmdName, String cfgName) {
command = cmdName.startsWith("git-") ? cmdName : "git-" + cmdName; //$NON-NLS-1$ //$NON-NLS-2$
configKey = cfg -> new ServiceConfig(DaemonService.this, cfg, cfgName);
overridable = true;
URIish sourceURI;
- void write(final Writer pw) throws IOException {
+ void write(Writer pw) throws IOException {
final String type;
final String name;
if (sourceName.startsWith(R_HEADS)) {
private Map<String, Ref> localRefs;
- FetchProcess(final Transport t, final Collection<RefSpec> f) {
+ FetchProcess(Transport t, Collection<RefSpec> f) {
transport = t;
toFetch = f;
}
- void execute(final ProgressMonitor monitor, final FetchResult result)
+ void execute(ProgressMonitor monitor, FetchResult result)
throws NotSupportedException, TransportException {
askFor.clear();
localUpdates.clear();
executeImp(monitor, result);
} finally {
try {
- for (final PackLock lock : packLocks)
+ for (PackLock lock : packLocks)
lock.unlock();
} catch (IOException e) {
throw new TransportException(e.getMessage(), e);
result.setAdvertisedRefs(transport.getURI(), conn.getRefsMap());
result.peerUserAgent = conn.getPeerUserAgent();
final Set<Ref> matched = new HashSet<>();
- for (final RefSpec spec : toFetch) {
+ for (RefSpec spec : toFetch) {
if (spec.getSource() == null)
throw new TransportException(MessageFormat.format(
JGitText.get().sourceRefNotSpecifiedForRefspec, spec));
//
have.addAll(askFor.keySet());
askFor.clear();
- for (final Ref r : additionalTags) {
+ for (Ref r : additionalTags) {
ObjectId id = r.getPeeledObjectId();
if (id == null)
id = r.getObjectId();
.newBatchUpdate()
.setAllowNonFastForwards(true)
.setRefLogMessage("fetch", true); //$NON-NLS-1$
- try (final RevWalk walk = new RevWalk(transport.local)) {
+ try (RevWalk walk = new RevWalk(transport.local)) {
if (monitor instanceof BatchingProgressMonitor) {
((BatchingProgressMonitor) monitor).setDelayStart(
250, TimeUnit.MILLISECONDS);
// new connection has offered to us.
//
final HashMap<ObjectId, Ref> avail = new HashMap<>();
- for (final Ref r : conn.getRefs())
+ for (Ref r : conn.getRefs())
avail.put(r.getObjectId(), r);
final Collection<Ref> wants = new ArrayList<>(askFor.values());
askFor.clear();
- for (final Ref want : wants) {
+ for (Ref want : wants) {
final Ref newRef = avail.get(want.getObjectId());
if (newRef != null) {
askFor.put(newRef.getObjectId(), newRef);
if (lock.lock()) {
try (Writer w = new OutputStreamWriter(
lock.getOutputStream())) {
- for (final FetchHeadRecord h : fetchHeadUpdates) {
+ for (FetchHeadRecord h : fetchHeadUpdates) {
h.write(w);
result.add(h);
}
private boolean askForIsComplete() throws TransportException {
try {
- try (final ObjectWalk ow = new ObjectWalk(transport.local)) {
- for (final ObjectId want : askFor.keySet())
+ try (ObjectWalk ow = new ObjectWalk(transport.local)) {
+ for (ObjectId want : askFor.keySet())
ow.markStart(ow.parseAny(want));
- for (final Ref ref : localRefs().values())
+ for (Ref ref : localRefs().values())
ow.markUninteresting(ow.parseAny(ref.getObjectId()));
ow.checkConnectivity();
}
private void expandWildcard(RefSpec spec, Set<Ref> matched)
throws TransportException {
- for (final Ref src : conn.getRefs()) {
+ for (Ref src : conn.getRefs()) {
if (spec.matchSource(src) && matched.add(src))
want(src, spec.expandFromSource(src));
}
private Collection<Ref> expandAutoFollowTags() throws TransportException {
final Collection<Ref> additionalTags = new ArrayList<>();
final Map<String, Ref> haveRefs = localRefs();
- for (final Ref r : conn.getRefs()) {
+ for (Ref r : conn.getRefs()) {
if (!isTag(r))
continue;
private void expandFetchTags() throws TransportException {
final Map<String, Ref> haveRefs = localRefs();
- for (final Ref r : conn.getRefs()) {
+ for (Ref r : conn.getRefs()) {
if (!isTag(r)) {
continue;
}
private void deleteStaleTrackingRefs(FetchResult result,
BatchRefUpdate batch) throws IOException {
- for (final Ref ref : localRefs().values()) {
+ for (Ref ref : localRefs().values()) {
final String refname = ref.getName();
- for (final RefSpec spec : toFetch) {
+ for (RefSpec spec : toFetch) {
if (spec.matchDestination(refname)) {
final RefSpec s = spec.expandFromDestination(refname);
if (result.getAdvertisedRef(s.getSource()) == null) {
submodules = new HashMap<>();
}
- void add(final FetchHeadRecord r) {
+ void add(FetchHeadRecord r) {
if (!r.notForMerge)
forMerge.add(r);
}
final Map<String, List<String>> headers = conn.getHeaderFields();
HttpAuthMethod authentication = Type.NONE.method(EMPTY_STRING);
- for (final Entry<String, List<String>> entry : headers.entrySet()) {
+ for (Entry<String, List<String>> entry : headers.entrySet()) {
if (HDR_WWW_AUTHENTICATE.equalsIgnoreCase(entry.getKey())) {
if (entry.getValue() != null) {
- for (final String value : entry.getValue()) {
+ for (String value : entry.getValue()) {
if (value != null && value.length() != 0) {
final String[] valuePart = value.split(
SCHEMA_NAME_SEPARATOR, 2);
}
@Override
- void authorize(final String username, final String password) {
+ void authorize(String username, String password) {
this.user = username;
this.pass = password;
}
@Override
- void configureRequest(final HttpConnection conn) throws IOException {
+ void configureRequest(HttpConnection conn) throws IOException {
String ident = user + ":" + pass; //$NON-NLS-1$
String enc = Base64.encodeBytes(ident.getBytes(CHARSET));
conn.setRequestProperty(HDR_AUTHORIZATION, type.getSchemeName()
}
@Override
- void authorize(final String username, final String password) {
+ void authorize(String username, String password) {
this.user = username;
this.pass = password;
}
@SuppressWarnings("boxing")
@Override
- void configureRequest(final HttpConnection conn) throws IOException {
+ void configureRequest(HttpConnection conn) throws IOException {
final Map<String, String> r = new LinkedHashMap<>();
final String realm = params.get("realm"); //$NON-NLS-1$
* @throws IOException
* on problems opening streams
*/
- JschProcess(final String commandName, int tms)
+ JschProcess(String commandName, int tms)
throws TransportException, IOException {
timeout = tms;
try {
/** State read from the config file, plus {@link Host}s created from it. */
private State state;
- OpenSshConfig(final File h, final File cfg) {
+ OpenSshConfig(File h, File cfg) {
home = h;
configFile = cfg;
state = new State();
// Initialize with default entries at the top of the file, before the
// first Host block.
fullConfig.merge(cache.entries.get(HostEntry.DEFAULT_NAME));
- for (final Map.Entry<String, HostEntry> e : cache.entries.entrySet()) {
+ for (Map.Entry<String, HostEntry> e : cache.entries.entrySet()) {
String key = e.getKey();
if (isHostMatch(key, hostName)) {
fullConfig.merge(e.getValue());
return updates.get(localName);
}
- void setAdvertisedRefs(final URIish u, final Map<String, Ref> ar) {
+ void setAdvertisedRefs(URIish u, Map<String, Ref> ar) {
uri = u;
advertisedRefs = ar;
}
- void add(final TrackingRefUpdate u) {
+ void add(TrackingRefUpdate u) {
updates.put(u.getLocalName(), u);
}
return messageBuffer != null ? messageBuffer.toString() : ""; //$NON-NLS-1$
}
- void addMessages(final String msg) {
+ void addMessages(String msg) {
if (msg != null && msg.length() > 0) {
if (messageBuffer == null)
messageBuffer = new StringBuilder();
baseObjectIds = new ObjectIdSubclassMap<>();
final List<DeltaChain> missing = new ArrayList<>(64);
- for (final DeltaChain baseId : baseById) {
+ for (DeltaChain baseId : baseById) {
if (baseId.head == null)
continue;
JGitText.get().downloadCancelledDuringIndexing);
}
- for (final DeltaChain base : missing) {
+ for (DeltaChain base : missing) {
if (base.head != null)
throw new MissingObjectException(base, "delta base"); //$NON-NLS-1$
}
}
// Consume cnt bytes from the buffer.
- void use(final int cnt) {
+ void use(int cnt) {
bOffset += cnt;
bAvail -= cnt;
}
// Ensure at least need bytes are available in in {@link #buf}.
- int fill(final Source src, final int need) throws IOException {
+ int fill(Source src, int need) throws IOException {
while (bAvail < need) {
int next = bOffset + bAvail;
int free = buf.length - next;
private static class DeltaChain extends ObjectIdOwnerMap.Entry {
UnresolvedDelta head;
- DeltaChain(final AnyObjectId id) {
+ DeltaChain(AnyObjectId id) {
super(id);
}
return r;
}
- void add(final UnresolvedDelta d) {
+ void add(UnresolvedDelta d) {
d.next = head;
head = d;
}
this.limit = limit;
}
- AckNackResult readACK(final MutableObjectId returnedId) throws IOException {
+ AckNackResult readACK(MutableObjectId returnedId) throws IOException {
final String line = readString();
if (line.length() == 0)
throw new PackProtocolException(JGitText.get().expectedACKNAKFoundEOF);
this.toPush = new LinkedHashMap<>();
this.out = out;
this.pushOptions = transport.getPushOptions();
- for (final RemoteRefUpdate rru : toPush) {
+ for (RemoteRefUpdate rru : toPush) {
if (this.toPush.put(rru.getRemoteName(), rru) != null)
throw new TransportException(MessageFormat.format(
JGitText.get().duplicateRemoteRefUpdateIsIllegal, rru.getRemoteName()));
* when some error occurred during operation, like I/O, protocol
* error, or local database consistency error.
*/
- PushResult execute(final ProgressMonitor monitor)
+ PushResult execute(ProgressMonitor monitor)
throws NotSupportedException, TransportException {
try {
monitor.beginTask(PROGRESS_OPENING_CONNECTION,
}
if (!transport.isDryRun())
updateTrackingRefs();
- for (final RemoteRefUpdate rru : toPush.values()) {
+ for (RemoteRefUpdate rru : toPush.values()) {
final TrackingRefUpdate tru = rru.getTrackingRefUpdate();
if (tru != null)
res.add(tru);
throws TransportException {
boolean atomic = transport.isPushAtomic();
final Map<String, RemoteRefUpdate> result = new LinkedHashMap<>();
- for (final RemoteRefUpdate rru : toPush.values()) {
+ for (RemoteRefUpdate rru : toPush.values()) {
final Ref advertisedRef = connection.getRef(rru.getRemoteName());
ObjectId advertisedOld = null;
if (advertisedRef != null) {
}
private void modifyUpdatesForDryRun() {
- for (final RemoteRefUpdate rru : toPush.values())
+ for (RemoteRefUpdate rru : toPush.values())
if (rru.getStatus() == Status.NOT_ATTEMPTED)
rru.setStatus(Status.OK);
}
private void updateTrackingRefs() {
- for (final RemoteRefUpdate rru : toPush.values()) {
+ for (RemoteRefUpdate rru : toPush.values()) {
final Status status = rru.getStatus();
if (rru.hasTrackingRefUpdate()
&& (status == Status.UP_TO_DATE || status == Status.OK)) {
}
}
- void setRef(final Ref r) {
+ void setRef(Ref r) {
ref = r;
}
- void setType(final Type t) {
+ void setType(Type t) {
type = t;
}
if (echoCommandFailures && msgOut != null) {
sendStatusReport(false, unpackError, new Reporter() {
@Override
- void sendString(final String s) throws IOException {
+ void sendString(String s) throws IOException {
msgOut.write(Constants.encode(s + "\n")); //$NON-NLS-1$
}
});
}
sendStatusReport(true, unpackError, new Reporter() {
@Override
- void sendString(final String s) throws IOException {
+ void sendString(String s) throws IOException {
pckOut.writeString(s + "\n"); //$NON-NLS-1$
}
});
} else if (msgOut != null) {
sendStatusReport(false, unpackError, new Reporter() {
@Override
- void sendString(final String s) throws IOException {
+ void sendString(String s) throws IOException {
msgOut.write(Constants.encode(s + "\n")); //$NON-NLS-1$
}
});
first = false;
if (!capablities.isEmpty()) {
tmpLine.append('\0');
- for (final String capName : capablities) {
+ for (String capName : capablities) {
tmpLine.append(' ');
tmpLine.append(capName);
}
final List<RemoteConfig> result = new ArrayList<>(names
.size());
- for (final String name : names)
+ for (String name : names)
result.add(new RemoteConfig(rc, name));
return result;
}
vlst = rc.getStringList(SECTION, name, KEY_URL);
Map<String, String> insteadOf = getReplacements(rc, KEY_INSTEADOF);
uris = new ArrayList<>(vlst.length);
- for (final String s : vlst) {
+ for (String s : vlst) {
uris.add(new URIish(replaceUri(s, insteadOf)));
}
String[] plst = rc.getStringList(SECTION, name, KEY_PUSHURL);
pushURIs = new ArrayList<>(plst.length);
- for (final String s : plst) {
+ for (String s : plst) {
pushURIs.add(new URIish(s));
}
if (pushURIs.isEmpty()) {
final List<String> vlst = new ArrayList<>();
vlst.clear();
- for (final URIish u : getURIs())
+ for (URIish u : getURIs())
vlst.add(u.toPrivateString());
rc.setStringList(SECTION, getName(), KEY_URL, vlst);
vlst.clear();
- for (final URIish u : getPushURIs())
+ for (URIish u : getPushURIs())
vlst.add(u.toPrivateString());
rc.setStringList(SECTION, getName(), KEY_PUSHURL, vlst);
vlst.clear();
- for (final RefSpec u : getFetchRefSpecs())
+ for (RefSpec u : getFetchRefSpecs())
vlst.add(u.toString());
rc.setStringList(SECTION, getName(), KEY_FETCH, vlst);
vlst.clear();
- for (final RefSpec u : getPushRefSpecs())
+ for (RefSpec u : getPushRefSpecs())
vlst.add(u.toString());
rc.setStringList(SECTION, getName(), KEY_PUSH, vlst);
expectedOldObjectId = id;
}
- void setStatus(final Status status) {
+ void setStatus(Status status) {
this.status = status;
}
this.fastForward = fastForward;
}
- void setMessage(final String message) {
+ void setMessage(String message) {
this.message = message;
}
private boolean write;
- SideBandProgressMonitor(final OutputStream os) {
+ SideBandProgressMonitor(OutputStream os) {
out = os;
write = true;
}
public static TagOpt fromOption(String o) {
if (o == null || o.length() == 0)
return AUTO_FOLLOW;
- for (final TagOpt tagopt : values()) {
+ for (TagOpt tagopt : values()) {
if (tagopt.option().equals(o))
return tagopt;
}
final @Nullable ProtocolVersion protocolVersion;
final String[] hideRefs;
- TransferConfig(final Repository db) {
+ TransferConfig(Repository db) {
this(db.getConfig());
}
@SuppressWarnings("nls")
- TransferConfig(final Config rc) {
+ TransferConfig(Config rc) {
boolean fsck = rc.getBoolean("transfer", "fsckobjects", false);
fetchFsck = rc.getBoolean("fetch", "fsckobjects", fsck);
receiveFsck = rc.getBoolean("receive", "fsckobjects", fsck);
throws NotSupportedException, TransportException {
final List<URIish> uris = getURIs(cfg, op);
final List<Transport> transports = new ArrayList<>(uris.size());
- for (final URIish uri : uris) {
+ for (URIish uri : uris) {
final Transport tn = open(local, uri, cfg.getName());
tn.applyConfig(cfg);
transports.add(tn);
final List<RemoteRefUpdate> result = new LinkedList<>();
final Collection<RefSpec> procRefs = expandPushWildcardsFor(db, specs);
- for (final RefSpec spec : procRefs) {
+ for (RefSpec spec : procRefs) {
String srcSpec = spec.getSource();
final Ref srcRef = db.findRef(srcSpec);
if (srcRef != null)
final List<Ref> localRefs = db.getRefDatabase().getRefs();
final Collection<RefSpec> procRefs = new LinkedHashSet<>();
- for (final RefSpec spec : specs) {
+ for (RefSpec spec : specs) {
if (spec.isWildcard()) {
- for (final Ref localRef : localRefs) {
+ for (Ref localRef : localRefs) {
if (spec.matchSource(localRef))
procRefs.add(spec.expandFromSource(localRef));
}
private static String findTrackingRefName(final String remoteName,
final Collection<RefSpec> fetchSpecs) {
// try to find matching tracking refs
- for (final RefSpec fetchSpec : fetchSpecs) {
+ for (RefSpec fetchSpec : fetchSpecs) {
if (fetchSpec.matchSource(remoteName)) {
if (fetchSpec.isWildcard())
return fetchSpec.expandFromSource(remoteName)
// object transfer overheads.
//
final Collection<RefSpec> tmp = new ArrayList<>(toFetch);
- for (final RefSpec requested : toFetch) {
+ for (RefSpec requested : toFetch) {
final String reqSrc = requested.getSource();
- for (final RefSpec configured : fetch) {
+ for (RefSpec configured : fetch) {
final String cfgSrc = configured.getSource();
final String cfgDst = configured.getDestination();
if (cfgSrc.equals(reqSrc) && cfgDst != null) {
}
@Override
- WalkRemoteObjectDatabase openAlternate(final String location)
+ WalkRemoteObjectDatabase openAlternate(String location)
throws IOException {
return new DatabaseS3(bucketName, resolveKey(location));
}
have.addAll(s3.list(bucket, resolveKey("pack"))); //$NON-NLS-1$
final Collection<String> packs = new ArrayList<>();
- for (final String n : have) {
+ for (String n : have) {
if (!n.startsWith("pack-") || !n.endsWith(".pack")) //$NON-NLS-1$ //$NON-NLS-2$
continue;
}
@Override
- FileStream open(final String path) throws IOException {
+ FileStream open(String path) throws IOException {
final URLConnection c = s3.get(bucket, resolveKey(path));
final InputStream raw = c.getInputStream();
final InputStream in = s3.decrypt(c);
}
@Override
- void deleteFile(final String path) throws IOException {
+ void deleteFile(String path) throws IOException {
s3.delete(bucket, resolveKey(path));
}
}
@Override
- void writeFile(final String path, final byte[] data) throws IOException {
+ void writeFile(String path, byte[] data) throws IOException {
s3.put(bucket, resolveKey(path), data);
}
}
};
- TransportGitAnon(final Repository local, final URIish uri) {
+ TransportGitAnon(Repository local, URIish uri) {
super(local, uri);
}
- TransportGitAnon(final URIish uri) {
+ TransportGitAnon(URIish uri) {
super(uri);
}
return s;
}
- void service(final String name, final PacketLineOut pckOut)
+ void service(String name, PacketLineOut pckOut)
throws IOException {
final StringBuilder cmd = new StringBuilder();
cmd.append(name);
}
};
- TransportGitSsh(final Repository local, final URIish uri) {
+ TransportGitSsh(Repository local, URIish uri) {
super(local, uri);
initSshSessionFactory();
}
- TransportGitSsh(final URIish uri) {
+ TransportGitSsh(URIish uri) {
super(uri);
initSshSessionFactory();
}
return new SshPushConnection();
}
- String commandFor(final String exe) {
+ String commandFor(String exe) {
String path = uri.getPath();
if (uri.getScheme() != null && uri.getPath().startsWith("/~")) //$NON-NLS-1$
path = (uri.getPath().substring(1));
private boolean sslFailure = false;
- TransportHttp(final Repository local, final URIish uri)
+ TransportHttp(Repository local, URIish uri)
throws NotSupportedException {
super(local, uri);
setURI(uri);
* @param uri
* @throws NotSupportedException
*/
- TransportHttp(final URIish uri) throws NotSupportedException {
+ TransportHttp(URIish uri) throws NotSupportedException {
super(uri);
setURI(uri);
http = new HttpConfig(uri);
class HttpObjectDB extends WalkRemoteObjectDatabase {
private final URL httpObjectsUrl;
- HttpObjectDB(final URL b) {
+ HttpObjectDB(URL b) {
httpObjectsUrl = b;
}
}
@Override
- WalkRemoteObjectDatabase openAlternate(final String location)
+ WalkRemoteObjectDatabase openAlternate(String location)
throws IOException {
return new HttpObjectDB(new URL(httpObjectsUrl, location));
}
}
@Override
- FileStream open(final String path) throws IOException {
+ FileStream open(String path) throws IOException {
return open(path, AcceptEncoding.UNSPECIFIED);
}
class SmartHttpFetchConnection extends BasePackFetchConnection {
private MultiRequestService svc;
- SmartHttpFetchConnection(final InputStream advertisement)
+ SmartHttpFetchConnection(InputStream advertisement)
throws TransportException {
super(TransportHttp.this);
statelessRPC = true;
}
class SmartHttpPushConnection extends BasePackPushConnection {
- SmartHttpPushConnection(final InputStream advertisement)
+ SmartHttpPushConnection(InputStream advertisement)
throws TransportException {
super(TransportHttp.this);
statelessRPC = true;
class MultiRequestService extends Service {
boolean finalRequest;
- MultiRequestService(final String serviceName) {
+ MultiRequestService(String serviceName) {
super(serviceName);
}
remoteGitDir = gitDir;
}
- UploadPack createUploadPack(final Repository dst) {
+ UploadPack createUploadPack(Repository dst) {
return new UploadPack(dst);
}
- ReceivePack createReceivePack(final Repository dst) {
+ ReceivePack createReceivePack(Repository dst) {
return new ReceivePack(dst);
}
}
};
- TransportSftp(final Repository local, final URIish uri) {
+ TransportSftp(Repository local, URIish uri) {
super(local, uri);
}
}
}
- SftpObjectDB(final SftpObjectDB parent, final String p)
+ SftpObjectDB(SftpObjectDB parent, String p)
throws TransportException {
try {
ftp = newSftp();
}
@Override
- WalkRemoteObjectDatabase openAlternate(final String location)
+ WalkRemoteObjectDatabase openAlternate(String location)
throws IOException {
return new SftpObjectDB(this, location);
}
files = new HashMap<>();
mtimes = new HashMap<>();
- for (final ChannelSftp.LsEntry ent : list)
+ for (ChannelSftp.LsEntry ent : list)
files.put(ent.getFilename(), ent);
- for (final ChannelSftp.LsEntry ent : list) {
+ for (ChannelSftp.LsEntry ent : list) {
final String n = ent.getFilename();
if (!n.startsWith("pack-") || !n.endsWith(".pack")) //$NON-NLS-1$ //$NON-NLS-2$
continue;
}
@Override
- FileStream open(final String path) throws IOException {
+ FileStream open(String path) throws IOException {
try {
final SftpATTRS a = ftp.lstat(path);
return new FileStream(ftp.get(path), a.getSize());
}
@Override
- void deleteFile(final String path) throws IOException {
+ void deleteFile(String path) throws IOException {
try {
ftp.rm(path);
} catch (SftpException je) {
}
@Override
- void writeFile(final String path, final byte[] data) throws IOException {
+ void writeFile(String path, byte[] data) throws IOException {
final String lock = path + ".lock"; //$NON-NLS-1$
try {
super.writeFile(lock, data);
je.getMessage()), je);
}
- for (final ChannelSftp.LsEntry ent : list) {
+ for (ChannelSftp.LsEntry ent : list) {
final String n = ent.getFilename();
if (".".equals(n) || "..".equals(n)) //$NON-NLS-1$ //$NON-NLS-2$
continue;
throw new IOException(MessageFormat.format(JGitText.get().unsupportedEncryptionAlgorithm, v));
}
- IOException error(final Throwable why) {
+ IOException error(Throwable why) {
return new IOException(MessageFormat
.format(JGitText.get().encryptionError,
why.getMessage()), why);
}
@Override
- void validate(final HttpURLConnection u, final String prefix)
+ void validate(HttpURLConnection u, String prefix)
throws IOException {
validateImpl(u, prefix, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@Override
- void request(final HttpURLConnection u, final String prefix) {
+ void request(HttpURLConnection u, String prefix) {
u.setRequestProperty(prefix + JETS3T_CRYPTO_VER, CRYPTO_VER);
u.setRequestProperty(prefix + JETS3T_CRYPTO_ALG, cryptoAlg);
}
@Override
- void validate(final HttpURLConnection u, final String prefix)
+ void validate(HttpURLConnection u, String prefix)
throws IOException {
validateImpl(u, prefix, CRYPTO_VER, cryptoAlg);
}
@Override
- OutputStream encrypt(final OutputStream os) throws IOException {
+ OutputStream encrypt(OutputStream os) throws IOException {
try {
final Cipher cipher = InsecureCipherFactory.create(cryptoAlg);
cipher.init(Cipher.ENCRYPT_MODE, secretKey, paramSpec);
}
@Override
- InputStream decrypt(final InputStream in) throws IOException {
+ InputStream decrypt(InputStream in) throws IOException {
try {
final Cipher cipher = InsecureCipherFactory.create(cryptoAlg);
cipher.init(Cipher.DECRYPT_MODE, secretKey, paramSpec);
/** Inserter to read objects from {@link #local}. */
private final ObjectReader reader;
- WalkFetchConnection(final WalkTransport t, final WalkRemoteObjectDatabase w) {
+ WalkFetchConnection(WalkTransport t, WalkRemoteObjectDatabase w) {
Transport wt = (Transport)t;
local = wt.local;
objCheck = wt.getObjectChecker();
public void close() {
inserter.close();
reader.close();
- for (final RemotePack p : unfetchedPacks) {
+ for (RemotePack p : unfetchedPacks) {
if (p.tmpIdx != null)
p.tmpIdx.delete();
}
- for (final WalkRemoteObjectDatabase r : remotes)
+ for (WalkRemoteObjectDatabase r : remotes)
r.close();
}
private void queueWants(Collection<Ref> want)
throws TransportException {
final HashSet<ObjectId> inWorkQueue = new HashSet<>();
- for (final Ref r : want) {
+ for (Ref r : want) {
final ObjectId id = r.getObjectId();
if (id == null) {
throw new NullPointerException(MessageFormat.format(
final RevCommit commit = (RevCommit) obj;
markLocalCommitsComplete(commit.getCommitTime());
needs(commit.getTree());
- for (final RevCommit p : commit.getParents())
+ for (RevCommit p : commit.getParents())
needs(p);
obj.add(COMPLETE);
}
if (packNameList == null || packNameList.isEmpty())
continue;
- for (final String packName : packNameList) {
+ for (String packName : packNameList) {
if (packsConsidered.add(packName))
unfetchedPacks.add(new RemotePack(wrr, packName));
}
//
Collection<WalkRemoteObjectDatabase> al = expandOneAlternate(id, pm);
if (al != null && !al.isEmpty()) {
- for (final WalkRemoteObjectDatabase alt : al) {
+ for (WalkRemoteObjectDatabase alt : al) {
remotes.add(alt);
noPacksYet.add(alt);
noAlternatesYet.add(alt);
} catch (IOException e) {
throw new TransportException(e.getMessage(), e);
}
- for (final Ref r : refs) {
+ for (Ref r : refs) {
try {
markLocalObjComplete(revWalk.parseAny(r.getObjectId()));
} catch (IOException readError) {
throw new TransportException(MessageFormat.format(JGitText.get().localRefIsMissingObjects, r.getName()), readError);
}
}
- for (final ObjectId id : have) {
+ for (ObjectId id : have) {
try {
markLocalObjComplete(revWalk.parseAny(id));
} catch (IOException readError) {
localCommitQueue.next();
markTreeComplete(c.getTree());
- for (final RevCommit p : c.getParents())
+ for (RevCommit p : c.getParents())
pushLocalCommit(p);
}
} catch (IOException err) {
PackIndex index;
- RemotePack(final WalkRemoteObjectDatabase c, final String pn) {
+ RemotePack(WalkRemoteObjectDatabase c, String pn) {
connection = c;
packName = pn;
idxName = packName.substring(0, packName.length() - 5) + ".idx"; //$NON-NLS-1$
}
}
- void openIndex(final ProgressMonitor pm) throws IOException {
+ void openIndex(ProgressMonitor pm) throws IOException {
if (index != null)
return;
if (tmpIdx == null)
pm.beginTask("Get " + idxName.substring(0, 12) + "..idx", //$NON-NLS-1$ //$NON-NLS-2$
s.length < 0 ? ProgressMonitor.UNKNOWN
: (int) (s.length / 1024));
- try (final FileOutputStream fos = new FileOutputStream(tmpIdx)) {
+ try (FileOutputStream fos = new FileOutputStream(tmpIdx)) {
final byte[] buf = new byte[2048];
int cnt;
while (!pm.isCancelled() && (cnt = s.in.read(buf)) >= 0) {
}
}
- void downloadPack(final ProgressMonitor monitor) throws IOException {
+ void downloadPack(ProgressMonitor monitor) throws IOException {
String name = "pack/" + packName; //$NON-NLS-1$
WalkRemoteObjectDatabase.FileStream s = connection.open(name);
try {
// ref using the directory name being created.
//
final List<RemoteRefUpdate> updates = new ArrayList<>();
- for (final RemoteRefUpdate u : refUpdates.values()) {
+ for (RemoteRefUpdate u : refUpdates.values()) {
final String n = u.getRemoteName();
if (!n.startsWith("refs/") || !Repository.isValidRefName(n)) { //$NON-NLS-1$
u.setStatus(Status.REJECTED_OTHER_REASON);
//
if (!updates.isEmpty())
sendpack(updates, monitor);
- for (final RemoteRefUpdate u : updates)
+ for (RemoteRefUpdate u : updates)
updateCommand(u);
// Is this a new repository? If so we should create additional
if (!packedRefUpdates.isEmpty()) {
try {
refWriter.writePackedRefs();
- for (final RemoteRefUpdate u : packedRefUpdates)
+ for (RemoteRefUpdate u : packedRefUpdates)
u.setStatus(Status.OK);
} catch (IOException err) {
- for (final RemoteRefUpdate u : packedRefUpdates) {
+ for (RemoteRefUpdate u : packedRefUpdates) {
u.setStatus(Status.REJECTED_OTHER_REASON);
u.setMessage(err.getMessage());
}
String pathPack = null;
String pathIdx = null;
- try (final PackWriter writer = new PackWriter(transport.getPackConfig(),
+ try (PackWriter writer = new PackWriter(transport.getPackConfig(),
local.newObjectReader())) {
final Set<ObjectId> need = new HashSet<>();
final Set<ObjectId> have = new HashSet<>();
- for (final RemoteRefUpdate r : updates)
+ for (RemoteRefUpdate r : updates)
need.add(r.getNewObjectId());
- for (final Ref r : getRefs()) {
+ for (Ref r : getRefs()) {
have.add(r.getObjectId());
if (r.getPeeledObjectId() != null)
have.add(r.getPeeledObjectId());
return;
packNames = new LinkedHashMap<>();
- for (final String n : dest.getPackNames())
+ for (String n : dest.getPackNames())
packNames.put(n, n);
final String base = "pack-" + writer.computeName().name(); //$NON-NLS-1$
// default branch and is likely what they want to remain as
// the default on the new remote.
//
- for (final RemoteRefUpdate u : updates) {
+ for (RemoteRefUpdate u : updates) {
final String n = u.getRemoteName();
if (n.equals(Constants.R_HEADS + Constants.MASTER))
return n;
// Pick any branch, under the assumption the user pushed only
// one to the remote side.
//
- for (final RemoteRefUpdate u : updates) {
+ for (RemoteRefUpdate u : updates) {
final String n = u.getRemoteName();
if (n.startsWith(Constants.R_HEADS))
return n;
* @throws IOException
* deletion is not supported, or deletion failed.
*/
- void deleteFile(final String path) throws IOException {
+ void deleteFile(String path) throws IOException {
throw new IOException(MessageFormat.format(JGitText.get().deletingNotSupported, path));
}
* writing is not supported, or attempting to write the file
* failed, possibly due to permissions or remote disk full, etc.
*/
- void writeFile(final String path, final byte[] data) throws IOException {
+ void writeFile(String path, byte[] data) throws IOException {
try (OutputStream os = writeFile(path, null, null)) {
os.write(data);
}
* @throws IOException
* deletion is not supported, or deletion failed.
*/
- void deleteRef(final String name) throws IOException {
+ void deleteRef(String name) throws IOException {
deleteFile(ROOT_DIR + name);
}
* @throws IOException
* deletion is not supported, or deletion failed.
*/
- void deleteRefLog(final String name) throws IOException {
+ void deleteRefLog(String name) throws IOException {
deleteFile(ROOT_DIR + Constants.LOGS + "/" + name); //$NON-NLS-1$
}
* writing is not supported, or attempting to write the file
* failed, possibly due to permissions or remote disk full, etc.
*/
- void writeRef(final String name, final ObjectId value) throws IOException {
+ void writeRef(String name, ObjectId value) throws IOException {
final ByteArrayOutputStream b;
b = new ByteArrayOutputStream(Constants.OBJECT_ID_STRING_LENGTH + 1);
* writing is not supported, or attempting to write the file
* failed, possibly due to permissions or remote disk full, etc.
*/
- void writeInfoPacks(final Collection<String> packNames) throws IOException {
+ void writeInfoPacks(Collection<String> packNames) throws IOException {
final StringBuilder w = new StringBuilder();
- for (final String n : packNames) {
+ for (String n : packNames) {
w.append("P "); //$NON-NLS-1$
w.append(n);
w.append('\n');
* exists, or after it was determined to exist but before the
* stream could be created.
*/
- BufferedReader openReader(final String path) throws IOException {
+ BufferedReader openReader(String path) throws IOException {
final InputStream is = open(path).in;
return new BufferedReader(new InputStreamReader(is, Constants.CHARSET));
}
* stream containing the file data. This stream will be
* closed by the caller when reading is complete.
*/
- FileStream(final InputStream i) {
+ FileStream(InputStream i) {
in = i;
length = -1;
}
* total number of bytes available for reading through
* <code>i</code>.
*/
- FileStream(final InputStream i, final long n) {
+ FileStream(InputStream i, long n) {
in = i;
length = n;
}
return pathCompare(p, p.mode);
}
- int pathCompare(final AbstractTreeIterator p, final int pMode) {
+ int pathCompare(AbstractTreeIterator p, int pMode) {
// Its common when we are a subtree for both parents to match;
// when this happens everything in path[0..cPos] is known to
// be equal and does not require evaluation again.
// Create a root empty tree.
}
- EmptyTreeIterator(final AbstractTreeIterator p) {
+ EmptyTreeIterator(AbstractTreeIterator p) {
super(p);
pathLen = pathOffset;
}
if (isTree(minRef)) {
if (skipEntry(minRef)) {
- for (final AbstractTreeIterator t : trees) {
+ for (AbstractTreeIterator t : trees) {
if (t.matches == minRef) {
t.next(1);
t.matches = null;
// A tree D/F may have been handled earlier. We need to
// not report this path if it has already been reported.
//
- for (final AbstractTreeIterator t : trees) {
+ for (AbstractTreeIterator t : trees) {
if (t.matches == minRef || t.first())
continue;
// such entries match this entry.
//
AbstractTreeIterator treeMatch = null;
- for (final AbstractTreeIterator t : trees) {
+ for (AbstractTreeIterator t : trees) {
if (t.matches == minRef || t.eof())
continue;
// matching iterators instead of the file iterator.
// This way isSubtree is true and isRecursive works.
//
- for (final AbstractTreeIterator t : trees)
+ for (AbstractTreeIterator t : trees)
if (t.matches == minRef)
t.matches = treeMatch;
trees[i] = trees[i].parent;
AbstractTreeIterator minRef = null;
- for (final AbstractTreeIterator t : trees) {
+ for (AbstractTreeIterator t : trees) {
if (t.matches != t)
continue;
if (minRef == null || t.pathCompare(minRef) < 0)
return p;
}
- static String pathOf(final AbstractTreeIterator t) {
+ static String pathOf(AbstractTreeIterator t) {
return RawParseUtils.decode(Constants.CHARSET, t.path, 0, t.pathLen);
}
- static String pathOf(final byte[] buf, int pos, int end) {
+ static String pathOf(byte[] buf, int pos, int end) {
return RawParseUtils.decode(Constants.CHARSET, buf, pos, end);
}
int encodedNameLen;
- void encodeName(final CharsetEncoder enc) {
+ void encodeName(CharsetEncoder enc) {
final ByteBuffer b;
try {
b = enc.encode(CharBuffer.wrap(getName()));
private final TreeFilter b;
- Binary(final TreeFilter one, final TreeFilter two) {
+ Binary(TreeFilter one, TreeFilter two) {
a = one;
b = two;
}
private static class List extends AndTreeFilter {
private final TreeFilter[] subfilters;
- List(final TreeFilter[] list) {
+ List(TreeFilter[] list) {
subfilters = list;
}
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
int m = 0;
- for (final TreeFilter f : subfilters) {
+ for (TreeFilter f : subfilters) {
int r = f.matchFilter(walker);
if (r == 1) {
return 1;
@Override
public boolean shouldBeRecursive() {
- for (final TreeFilter f : subfilters)
+ for (TreeFilter f : subfilters)
if (f.shouldBeRecursive())
return true;
return false;
* pre-computed hash of toFind
* @return true if the mapping exists for this byte array; false otherwise.
*/
- boolean contains(final byte[] toFind, int length, int hash) {
+ boolean contains(byte[] toFind, int length, int hash) {
return get(toFind, length, hash) != null;
}
private final TreeFilter b;
- Binary(final TreeFilter one, final TreeFilter two) {
+ Binary(TreeFilter one, TreeFilter two) {
a = one;
b = two;
}
private static class List extends OrTreeFilter {
private final TreeFilter[] subfilters;
- List(final TreeFilter[] list) {
+ List(TreeFilter[] list) {
subfilters = list;
}
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
int m = 1;
- for (final TreeFilter f : subfilters) {
+ for (TreeFilter f : subfilters) {
int r = f.matchFilter(walker);
if (r == 0) {
return 0;
@Override
public boolean shouldBeRecursive() {
- for (final TreeFilter f : subfilters)
+ for (TreeFilter f : subfilters)
if (f.shouldBeRecursive())
return true;
return false;
/** {@inheritDoc} */
@Override
public boolean shouldBeRecursive() {
- for (final byte b : pathRaw)
+ for (byte b : pathRaw)
if (b == '/')
return true;
return false;
JGitText.get().atLeastOnePathIsRequired);
final PathFilter[] p = new PathFilter[paths.size()];
int i = 0;
- for (final String s : paths)
+ for (String s : paths)
p[i++] = PathFilter.create(s);
return create(p);
}
protected final PasswordAuthentication getPasswordAuthentication() {
final String host = getRequestingHost();
final int port = getRequestingPort();
- for (final CachedAuthentication ca : cached) {
+ for (CachedAuthentication ca : cached) {
if (ca.host.equals(host) && ca.port == port)
return ca.toPasswordAuthentication();
}
if (path == null)
return null;
- for (final String p : path.split(File.pathSeparator)) {
+ for (String p : path.split(File.pathSeparator)) {
for (String command : lookFor) {
final File e = new File(p, command);
if (e.isFile())
V value;
Node<V> next;
- Node(final long k, final V v) {
+ Node(long k, V v) {
key = k;
value = v;
}
throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize);
final byte[] out = new byte[(int) len];
int outPtr = 0;
- for (final Block b : blocks) {
+ for (Block b : blocks) {
System.arraycopy(b.buffer, 0, out, outPtr, b.count);
outPtr += b.count;
}
JGitText.get().lengthExceedsMaximumArraySize);
final byte[] out = new byte[(int) len];
int outPtr = 0;
- for (final Block b : blocks) {
+ for (Block b : blocks) {
System.arraycopy(b.buffer, 0, out, outPtr, b.count);
outPtr += b.count;
}
throws IOException {
if (pm == null)
pm = NullProgressMonitor.INSTANCE;
- for (final Block b : blocks) {
+ for (Block b : blocks) {
os.write(b.buffer, 0, b.count);
pm.update(b.count / 1024);
}
overflow = overflow();
final Block last = blocks.remove(blocks.size() - 1);
- for (final Block b : blocks)
+ for (Block b : blocks)
overflow.write(b.buffer, 0, b.count);
blocks = null;
}
static final class AlarmThread extends Thread {
- AlarmThread(final String name, final AlarmState q) {
+ AlarmThread(String name, AlarmState q) {
super(q);
setName(name);
setDaemon(true);
private static final class AutoKiller {
private final AlarmState state;
- AutoKiller(final AlarmState s) {
+ AutoKiller(AlarmState s) {
state = s;
}
}
}
- synchronized void begin(final int timeout) {
+ synchronized void begin(int timeout) {
if (terminated)
throw new IllegalStateException(JGitText.get().timerAlreadyTerminated);
callingThread = Thread.currentThread();