Remove further unnecessary 'final' keywords
Remove it from * package private functions. * try blocks * for loops this was done with the following python script: $ cat f.py import sys import re import os def replaceFinal(m): return m.group(1) + "(" + m.group(2).replace('final ', '') + ")" methodDecl = re.compile(r"^([\t ]*[a-zA-Z_ ]+)\(([^)]*)\)") def subst(fn): input = open(fn) os.rename(fn, fn + "~") dest = open(fn, 'w') for l in input: l = methodDecl.sub(replaceFinal, l) dest.write(l) dest.close() for root, dirs, files in os.walk(".", topdown=False): for f in files: if not f.endswith('.java'): continue full = os.path.join(root, f) print full subst(full) Change-Id: If533a75a417594fc893e7c669d2c1f0f6caeb7ca Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
This commit is contained in:
parent
667e30678a
commit
f3ec7cf3f0
|
@ -66,7 +66,7 @@
|
||||||
class AsIsFileFilter implements Filter {
|
class AsIsFileFilter implements Filter {
|
||||||
private final AsIsFileService asIs;
|
private final AsIsFileService asIs;
|
||||||
|
|
||||||
AsIsFileFilter(final AsIsFileService getAnyFile) {
|
AsIsFileFilter(AsIsFileService getAnyFile) {
|
||||||
this.asIs = getAnyFile;
|
this.asIs = getAnyFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ final class FileSender {
|
||||||
|
|
||||||
private long end;
|
private long end;
|
||||||
|
|
||||||
FileSender(final File path) throws FileNotFoundException {
|
FileSender(File path) throws FileNotFoundException {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.source = new RandomAccessFile(path, "r");
|
this.source = new RandomAccessFile(path, "r");
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ static class Loose extends ObjectFileServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String etag(final FileSender sender) throws IOException {
|
String etag(FileSender sender) throws IOException {
|
||||||
return Long.toHexString(sender.getLastModified());
|
return Long.toHexString(sender.getLastModified());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ private static abstract class PackData extends ObjectFileServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String etag(final FileSender sender) throws IOException {
|
String etag(FileSender sender) throws IOException {
|
||||||
return sender.getTailChecksum();
|
return sender.getTailChecksum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ static class PackIdx extends PackData {
|
||||||
|
|
||||||
private final String contentType;
|
private final String contentType;
|
||||||
|
|
||||||
ObjectFileServlet(final String contentType) {
|
ObjectFileServlet(String contentType) {
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ private static byte[] sendInit(byte[] content,
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean acceptsGzipEncoding(final HttpServletRequest req) {
|
static boolean acceptsGzipEncoding(HttpServletRequest req) {
|
||||||
return acceptsGzipEncoding(req.getHeader(HDR_ACCEPT_ENCODING));
|
return acceptsGzipEncoding(req.getHeader(HDR_ACCEPT_ENCODING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ abstract class SmartServiceInfoRefs implements Filter {
|
||||||
|
|
||||||
private final Filter[] filters;
|
private final Filter[] filters;
|
||||||
|
|
||||||
SmartServiceInfoRefs(final String service, final List<Filter> filters) {
|
SmartServiceInfoRefs(String service, List<Filter> filters) {
|
||||||
this.svc = service;
|
this.svc = service;
|
||||||
this.filters = filters.toArray(new Filter[filters.size()]);
|
this.filters = filters.toArray(new Filter[filters.size()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class TextFileServlet extends HttpServlet {
|
||||||
|
|
||||||
private final String fileName;
|
private final String fileName;
|
||||||
|
|
||||||
TextFileServlet(final String name) {
|
TextFileServlet(String name) {
|
||||||
this.fileName = name;
|
this.fileName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,11 +87,11 @@ class RegexPipeline extends UrlPipeline {
|
||||||
static class Binder extends ServletBinderImpl {
|
static class Binder extends ServletBinderImpl {
|
||||||
private final Pattern pattern;
|
private final Pattern pattern;
|
||||||
|
|
||||||
Binder(final String p) {
|
Binder(String p) {
|
||||||
pattern = Pattern.compile(p);
|
pattern = Pattern.compile(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
Binder(final Pattern p) {
|
Binder(Pattern p) {
|
||||||
pattern = p;
|
pattern = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ UrlPipeline create() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean match(final HttpServletRequest req) {
|
boolean match(HttpServletRequest req) {
|
||||||
final String pathInfo = req.getPathInfo();
|
final String pathInfo = req.getPathInfo();
|
||||||
return pathInfo != null && pattern.matcher(pathInfo).matches();
|
return pathInfo != null && pattern.matcher(pathInfo).matches();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ class SuffixPipeline extends UrlPipeline {
|
||||||
static class Binder extends ServletBinderImpl {
|
static class Binder extends ServletBinderImpl {
|
||||||
private final String suffix;
|
private final String suffix;
|
||||||
|
|
||||||
Binder(final String suffix) {
|
Binder(String suffix) {
|
||||||
this.suffix = suffix;
|
this.suffix = suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ UrlPipeline create() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean match(final HttpServletRequest req) {
|
boolean match(HttpServletRequest req) {
|
||||||
final String pathInfo = req.getPathInfo();
|
final String pathInfo = req.getPathInfo();
|
||||||
return pathInfo != null && pathInfo.endsWith(suffix);
|
return pathInfo != null && pathInfo.endsWith(suffix);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ abstract class UrlPipeline {
|
||||||
/** Instance that must generate the response; never null. */
|
/** Instance that must generate the response; never null. */
|
||||||
private final HttpServlet servlet;
|
private final HttpServlet servlet;
|
||||||
|
|
||||||
UrlPipeline(final Filter[] filters, final HttpServlet servlet) {
|
UrlPipeline(Filter[] filters, HttpServlet servlet) {
|
||||||
this.filters = filters;
|
this.filters = filters;
|
||||||
this.servlet = servlet;
|
this.servlet = servlet;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ abstract class UrlPipeline {
|
||||||
* @throws ServletException
|
* @throws ServletException
|
||||||
* a filter or servlet is unable to initialize.
|
* 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 {
|
throws ServletException {
|
||||||
for (Filter ref : filters)
|
for (Filter ref : filters)
|
||||||
initFilter(ref, context, inited);
|
initFilter(ref, context, inited);
|
||||||
|
@ -165,7 +165,7 @@ public String getServletName() {
|
||||||
* destroyed a second time. Filters and servlets that are first
|
* destroyed a second time. Filters and servlets that are first
|
||||||
* destroyed by this pipeline will be added to this set.
|
* 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)
|
for (Filter ref : filters)
|
||||||
destroyFilter(ref, destroyed);
|
destroyFilter(ref, destroyed);
|
||||||
destroyServlet(servlet, destroyed);
|
destroyServlet(servlet, destroyed);
|
||||||
|
@ -230,7 +230,7 @@ private static class Chain implements FilterChain {
|
||||||
|
|
||||||
private int filterIdx;
|
private int filterIdx;
|
||||||
|
|
||||||
Chain(final Filter[] filters, final HttpServlet servlet) {
|
Chain(Filter[] filters, HttpServlet servlet) {
|
||||||
this.filters = filters;
|
this.filters = filters;
|
||||||
this.servlet = servlet;
|
this.servlet = servlet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public void access(HttpServletRequest req, Repository db)
|
||||||
private static class ServiceConfig {
|
private static class ServiceConfig {
|
||||||
final boolean enabled;
|
final boolean enabled;
|
||||||
|
|
||||||
ServiceConfig(final Config cfg) {
|
ServiceConfig(Config cfg) {
|
||||||
enabled = cfg.getBoolean("http", "getanyfile", true);
|
enabled = cfg.getBoolean("http", "getanyfile", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ private static class ServiceConfig {
|
||||||
|
|
||||||
final boolean enabled;
|
final boolean enabled;
|
||||||
|
|
||||||
ServiceConfig(final Config cfg) {
|
ServiceConfig(Config cfg) {
|
||||||
set = cfg.getString("http", null, "receivepack") != null;
|
set = cfg.getString("http", null, "receivepack") != null;
|
||||||
enabled = cfg.getBoolean("http", "receivepack", false);
|
enabled = cfg.getBoolean("http", "receivepack", false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class DefaultUploadPackFactory implements
|
||||||
private static class ServiceConfig {
|
private static class ServiceConfig {
|
||||||
final boolean enabled;
|
final boolean enabled;
|
||||||
|
|
||||||
ServiceConfig(final Config cfg) {
|
ServiceConfig(Config cfg) {
|
||||||
enabled = cfg.getBoolean("http", "uploadpack", true);
|
enabled = cfg.getBoolean("http", "uploadpack", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ private static final class R extends HttpServletRequestWrapper {
|
||||||
|
|
||||||
private final String 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 */);
|
super(new Request(null, null) /* can't pass null, sigh */);
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
|
|
@ -205,7 +205,7 @@ private static final class R extends HttpServletRequestWrapper {
|
||||||
|
|
||||||
private final String 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 */);
|
super(new Request(null, null) /* can't pass null, sigh */);
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
|
|
@ -161,7 +161,7 @@ private static final class R extends HttpServletRequestWrapper {
|
||||||
|
|
||||||
private final String 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 */);
|
super(new Request(null, null) /* can't pass null, sigh */);
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class AccessEvent {
|
||||||
|
|
||||||
private final Map<String, String> responseHeaders;
|
private final Map<String, String> responseHeaders;
|
||||||
|
|
||||||
AccessEvent(final Request req, final Response rsp) {
|
AccessEvent(Request req, Response rsp) {
|
||||||
method = req.getMethod();
|
method = req.getMethod();
|
||||||
uri = req.getRequestURI();
|
uri = req.getRequestURI();
|
||||||
requestHeaders = cloneHeaders(req);
|
requestHeaders = cloneHeaders(req);
|
||||||
|
|
|
@ -318,7 +318,7 @@ public DirCacheEntry file(String path, RevBlob blob)
|
||||||
public RevTree tree(DirCacheEntry... entries) throws Exception {
|
public RevTree tree(DirCacheEntry... entries) throws Exception {
|
||||||
final DirCache dc = DirCache.newInCore();
|
final DirCache dc = DirCache.newInCore();
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (final DirCacheEntry e : entries)
|
for (DirCacheEntry e : entries)
|
||||||
b.add(e);
|
b.add(e);
|
||||||
b.finish();
|
b.finish();
|
||||||
ObjectId root;
|
ObjectId root;
|
||||||
|
@ -962,7 +962,7 @@ private void writeFile(File p, byte[] bin) throws IOException,
|
||||||
public class BranchBuilder {
|
public class BranchBuilder {
|
||||||
private final String ref;
|
private final String ref;
|
||||||
|
|
||||||
BranchBuilder(final String ref) {
|
BranchBuilder(String ref) {
|
||||||
this.ref = ref;
|
this.ref = ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ public void testParallelUploads() throws Exception {
|
||||||
|
|
||||||
ExecutorService e = Executors.newFixedThreadPool(count);
|
ExecutorService e = Executors.newFixedThreadPool(count);
|
||||||
try {
|
try {
|
||||||
for (final Path p : paths) {
|
for (Path p : paths) {
|
||||||
e.submit(new Callable<Void>() {
|
e.submit(new Callable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
|
|
|
@ -173,7 +173,7 @@ private static final long hexUInt64(final byte[] bs, int p, final int end) {
|
||||||
return r << (16 - n) * 4;
|
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;
|
final long b = (word - 1) * 16;
|
||||||
if (b + 16 <= nibbles) {
|
if (b + 16 <= nibbles) {
|
||||||
// We have all of the bits required for this word.
|
// We have all of the bits required for this word.
|
||||||
|
|
|
@ -476,7 +476,7 @@ private void toHexCharArray(char[] dst) {
|
||||||
private static final char[] hexchar = { '0', '1', '2', '3', '4', '5', '6',
|
private static final char[] hexchar = { '0', '1', '2', '3', '4', '5', '6',
|
||||||
'7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
'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;
|
int o = p + 15;
|
||||||
while (o >= p && w != 0) {
|
while (o >= p && w != 0) {
|
||||||
dst[o--] = hexchar[(int) (w & 0xf)];
|
dst[o--] = hexchar[(int) (w & 0xf)];
|
||||||
|
|
|
@ -157,7 +157,7 @@ PrintWriter createErrorWriter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void init(final TextBuiltin cmd) throws IOException {
|
void init(TextBuiltin cmd) throws IOException {
|
||||||
cmd.outs = result.out;
|
cmd.outs = result.out;
|
||||||
cmd.errs = result.err;
|
cmd.errs = result.err;
|
||||||
super.init(cmd);
|
super.init(cmd);
|
||||||
|
|
|
@ -77,7 +77,7 @@ abstract class AbstractFetchCommand extends TextBuiltin {
|
||||||
protected void showFetchResult(FetchResult r) throws IOException {
|
protected void showFetchResult(FetchResult r) throws IOException {
|
||||||
try (ObjectReader reader = db.newObjectReader()) {
|
try (ObjectReader reader = db.newObjectReader()) {
|
||||||
boolean shownURI = false;
|
boolean shownURI = false;
|
||||||
for (final TrackingRefUpdate u : r.getTrackingRefUpdates()) {
|
for (TrackingRefUpdate u : r.getTrackingRefUpdates()) {
|
||||||
if (!verbose && u.getResult() == RefUpdate.Result.NO_CHANGE)
|
if (!verbose && u.getResult() == RefUpdate.Result.NO_CHANGE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ protected void run() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ("ls".equals(op) || "list".equals(op)) { //$NON-NLS-1$//$NON-NLS-2$
|
} 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);
|
outw.println(k);
|
||||||
|
|
||||||
} else if ("rm".equals(op) || "delete".equals(op)) { //$NON-NLS-1$ //$NON-NLS-2$
|
} else if ("rm".equals(op) || "delete".equals(op)) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
|
@ -292,7 +292,7 @@ else if (remote)
|
||||||
addRefs(refs, Constants.R_REMOTES);
|
addRefs(refs, Constants.R_REMOTES);
|
||||||
|
|
||||||
try (ObjectReader reader = db.newObjectReader()) {
|
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();
|
final Ref ref = e.getValue();
|
||||||
printHead(reader, e.getKey(),
|
printHead(reader, e.getKey(),
|
||||||
current.equals(ref.getName()), ref);
|
current.equals(ref.getName()), ref);
|
||||||
|
@ -303,7 +303,7 @@ else if (remote)
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRefs(Collection<Ref> refs, String prefix) {
|
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();
|
final String name = ref.getName();
|
||||||
if (name.startsWith(prefix))
|
if (name.startsWith(prefix))
|
||||||
addRef(name.substring(name.indexOf('/', 5) + 1), ref);
|
addRef(name.substring(name.indexOf('/', 5) + 1), ref);
|
||||||
|
|
|
@ -107,7 +107,7 @@ public static CommandRef[] all() {
|
||||||
*/
|
*/
|
||||||
public static CommandRef[] common() {
|
public static CommandRef[] common() {
|
||||||
final ArrayList<CommandRef> common = new ArrayList<>();
|
final ArrayList<CommandRef> common = new ArrayList<>();
|
||||||
for (final CommandRef c : INSTANCE.commands.values())
|
for (CommandRef c : INSTANCE.commands.values())
|
||||||
if (c.isCommon())
|
if (c.isCommon())
|
||||||
common.add(c);
|
common.add(c);
|
||||||
return toSortedArray(common);
|
return toSortedArray(common);
|
||||||
|
|
|
@ -66,11 +66,11 @@ public class CommandRef {
|
||||||
|
|
||||||
boolean common;
|
boolean common;
|
||||||
|
|
||||||
CommandRef(final Class<? extends TextBuiltin> clazz) {
|
CommandRef(Class<? extends TextBuiltin> clazz) {
|
||||||
this(clazz, guessName(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));
|
this(clazz, cmd.name().length() > 0 ? cmd.name() : guessName(clazz));
|
||||||
usage = cmd.usage();
|
usage = cmd.usage();
|
||||||
common = cmd.common();
|
common = cmd.common();
|
||||||
|
@ -88,7 +88,7 @@ private static String guessName(Class<? extends TextBuiltin> clazz) {
|
||||||
s.append("debug-"); //$NON-NLS-1$
|
s.append("debug-"); //$NON-NLS-1$
|
||||||
|
|
||||||
boolean lastWasDash = true;
|
boolean lastWasDash = true;
|
||||||
for (final char c : clazz.getSimpleName().toCharArray()) {
|
for (char c : clazz.getSimpleName().toCharArray()) {
|
||||||
if (Character.isUpperCase(c)) {
|
if (Character.isUpperCase(c)) {
|
||||||
if (!lastWasDash)
|
if (!lastWasDash)
|
||||||
s.append('-');
|
s.append('-');
|
||||||
|
|
|
@ -142,7 +142,7 @@ protected void run() throws Exception {
|
||||||
packConfig.setExecutor(Executors.newFixedThreadPool(threads));
|
packConfig.setExecutor(Executors.newFixedThreadPool(threads));
|
||||||
|
|
||||||
final FileResolver<DaemonClient> resolver = new FileResolver<>();
|
final FileResolver<DaemonClient> resolver = new FileResolver<>();
|
||||||
for (final File f : directory) {
|
for (File f : directory) {
|
||||||
outw.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath()));
|
outw.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath()));
|
||||||
resolver.exportDirectory(f);
|
resolver.exportDirectory(f);
|
||||||
}
|
}
|
||||||
|
@ -157,14 +157,14 @@ protected void run() throws Exception {
|
||||||
if (0 <= timeout)
|
if (0 <= timeout)
|
||||||
d.setTimeout(timeout);
|
d.setTimeout(timeout);
|
||||||
|
|
||||||
for (final String n : enable)
|
for (String n : enable)
|
||||||
service(d, n).setEnabled(true);
|
service(d, n).setEnabled(true);
|
||||||
for (final String n : disable)
|
for (String n : disable)
|
||||||
service(d, n).setEnabled(false);
|
service(d, n).setEnabled(false);
|
||||||
|
|
||||||
for (final String n : canOverride)
|
for (String n : canOverride)
|
||||||
service(d, n).setOverridable(true);
|
service(d, n).setOverridable(true);
|
||||||
for (final String n : forbidOverride)
|
for (String n : forbidOverride)
|
||||||
service(d, n).setOverridable(false);
|
service(d, n).setOverridable(false);
|
||||||
if (ketchServerType == KetchServerType.LEADER) {
|
if (ketchServerType == KetchServerType.LEADER) {
|
||||||
startKetchLeader(d);
|
startKetchLeader(d);
|
||||||
|
|
|
@ -75,9 +75,9 @@ void tree_0(final AbstractTreeIterator c) {
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
protected void run() throws Exception {
|
||||||
try (final TreeWalk walk = new TreeWalk(db)) {
|
try (TreeWalk walk = new TreeWalk(db)) {
|
||||||
walk.setRecursive(recursive);
|
walk.setRecursive(recursive);
|
||||||
for (final AbstractTreeIterator i : trees)
|
for (AbstractTreeIterator i : trees)
|
||||||
walk.addTree(i);
|
walk.addTree(i);
|
||||||
walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, pathFilter));
|
walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, pathFilter));
|
||||||
|
|
||||||
|
|
|
@ -266,7 +266,7 @@ protected void show(RevCommit c) throws Exception {
|
||||||
|
|
||||||
outw.println();
|
outw.println();
|
||||||
final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
|
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(" "); //$NON-NLS-1$
|
||||||
outw.print(s);
|
outw.print(s);
|
||||||
outw.println();
|
outw.println();
|
||||||
|
|
|
@ -83,7 +83,7 @@ public int compare(Ref r1, Ref r2) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
refs.addAll(command.call());
|
refs.addAll(command.call());
|
||||||
for (final Ref r : refs) {
|
for (Ref r : refs) {
|
||||||
show(r.getObjectId(), r.getName());
|
show(r.getObjectId(), r.getName());
|
||||||
if (r.getPeeledObjectId() != null)
|
if (r.getPeeledObjectId() != null)
|
||||||
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
|
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
|
||||||
|
|
|
@ -73,7 +73,7 @@ class LsTree extends TextBuiltin {
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
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
|
walk.reset(); // drop the first empty tree, which we do not need here
|
||||||
if (paths.size() > 0)
|
if (paths.size() > 0)
|
||||||
walk.setFilter(PathFilterGroup.createFromStrings(paths));
|
walk.setFilter(PathFilterGroup.createFromStrings(paths));
|
||||||
|
|
|
@ -256,12 +256,12 @@ private void execute(String[] argv) throws Exception {
|
||||||
writer.println(CLIText.get().mostCommonlyUsedCommandsAre);
|
writer.println(CLIText.get().mostCommonlyUsedCommandsAre);
|
||||||
final CommandRef[] common = CommandCatalog.common();
|
final CommandRef[] common = CommandCatalog.common();
|
||||||
int width = 0;
|
int width = 0;
|
||||||
for (final CommandRef c : common) {
|
for (CommandRef c : common) {
|
||||||
width = Math.max(width, c.getName().length());
|
width = Math.max(width, c.getName().length());
|
||||||
}
|
}
|
||||||
width += 2;
|
width += 2;
|
||||||
|
|
||||||
for (final CommandRef c : common) {
|
for (CommandRef c : common) {
|
||||||
writer.print(' ');
|
writer.print(' ');
|
||||||
writer.print(c.getName());
|
writer.print(c.getName());
|
||||||
for (int i = c.getName().length(); i < width; i++) {
|
for (int i = c.getName().length(); i < width; i++) {
|
||||||
|
@ -296,7 +296,7 @@ private void execute(String[] argv) throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(final TextBuiltin cmd) throws IOException {
|
void init(TextBuiltin cmd) throws IOException {
|
||||||
if (cmd.requiresRepository()) {
|
if (cmd.requiresRepository()) {
|
||||||
cmd.init(openGitDir(gitdir), null);
|
cmd.init(openGitDir(gitdir), null);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -68,7 +68,7 @@ void commit_0(final RevCommit c) {
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
protected void run() throws Exception {
|
||||||
for (final RevCommit c : commits)
|
for (RevCommit c : commits)
|
||||||
argWalk.markStart(c);
|
argWalk.markStart(c);
|
||||||
argWalk.setRevFilter(RevFilter.MERGE_BASE);
|
argWalk.setRevFilter(RevFilter.MERGE_BASE);
|
||||||
int max = all ? Integer.MAX_VALUE : 1;
|
int max = all ? Integer.MAX_VALUE : 1;
|
||||||
|
|
|
@ -149,7 +149,7 @@ private void printPushResult(final ObjectReader reader, final URIish uri,
|
||||||
boolean everythingUpToDate = true;
|
boolean everythingUpToDate = true;
|
||||||
|
|
||||||
// at first, print up-to-date ones...
|
// 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 (rru.getStatus() == Status.UP_TO_DATE) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printRefUpdateResult(reader, uri, result, rru);
|
printRefUpdateResult(reader, uri, result, rru);
|
||||||
|
@ -157,13 +157,13 @@ private void printPushResult(final ObjectReader reader, final URIish uri,
|
||||||
everythingUpToDate = false;
|
everythingUpToDate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
|
for (RemoteRefUpdate rru : result.getRemoteUpdates()) {
|
||||||
// ...then successful updates...
|
// ...then successful updates...
|
||||||
if (rru.getStatus() == Status.OK)
|
if (rru.getStatus() == Status.OK)
|
||||||
printRefUpdateResult(reader, uri, result, rru);
|
printRefUpdateResult(reader, uri, result, rru);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
|
for (RemoteRefUpdate rru : result.getRemoteUpdates()) {
|
||||||
// ...finally, others (problematic)
|
// ...finally, others (problematic)
|
||||||
if (rru.getStatus() != Status.OK
|
if (rru.getStatus() != Status.OK
|
||||||
&& rru.getStatus() != Status.UP_TO_DATE)
|
&& rru.getStatus() != Status.UP_TO_DATE)
|
||||||
|
|
|
@ -87,7 +87,7 @@ protected void run() throws Exception {
|
||||||
CLIText.format(CLIText.get().needSingleRevision));
|
CLIText.format(CLIText.get().needSingleRevision));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final ObjectId o : commits) {
|
for (ObjectId o : commits) {
|
||||||
outw.println(o.name());
|
outw.println(o.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,22 +99,22 @@ private void enableRevSort(RevSort type, boolean on) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Option(name = "--date-order")
|
@Option(name = "--date-order")
|
||||||
void enableDateOrder(final boolean on) {
|
void enableDateOrder(boolean on) {
|
||||||
enableRevSort(RevSort.COMMIT_TIME_DESC, on);
|
enableRevSort(RevSort.COMMIT_TIME_DESC, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Option(name = "--topo-order")
|
@Option(name = "--topo-order")
|
||||||
void enableTopoOrder(final boolean on) {
|
void enableTopoOrder(boolean on) {
|
||||||
enableRevSort(RevSort.TOPO, on);
|
enableRevSort(RevSort.TOPO, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Option(name = "--reverse")
|
@Option(name = "--reverse")
|
||||||
void enableReverse(final boolean on) {
|
void enableReverse(boolean on) {
|
||||||
enableRevSort(RevSort.REVERSE, on);
|
enableRevSort(RevSort.REVERSE, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Option(name = "--boundary")
|
@Option(name = "--boundary")
|
||||||
void enableBoundary(final boolean on) {
|
void enableBoundary(boolean on) {
|
||||||
enableRevSort(RevSort.BOUNDARY, on);
|
enableRevSort(RevSort.BOUNDARY, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,17 +130,17 @@ void enableBoundary(final boolean on) {
|
||||||
private final List<RevFilter> revLimiter = new ArrayList<>();
|
private final List<RevFilter> revLimiter = new ArrayList<>();
|
||||||
|
|
||||||
@Option(name = "--author")
|
@Option(name = "--author")
|
||||||
void addAuthorRevFilter(final String who) {
|
void addAuthorRevFilter(String who) {
|
||||||
revLimiter.add(AuthorRevFilter.create(who));
|
revLimiter.add(AuthorRevFilter.create(who));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Option(name = "--committer")
|
@Option(name = "--committer")
|
||||||
void addCommitterRevFilter(final String who) {
|
void addCommitterRevFilter(String who) {
|
||||||
revLimiter.add(CommitterRevFilter.create(who));
|
revLimiter.add(CommitterRevFilter.create(who));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Option(name = "--grep")
|
@Option(name = "--grep")
|
||||||
void addCMessageRevFilter(final String msg) {
|
void addCMessageRevFilter(String msg) {
|
||||||
revLimiter.add(MessageRevFilter.create(msg));
|
revLimiter.add(MessageRevFilter.create(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ void addCMessageRevFilter(final String msg) {
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
protected void run() throws Exception {
|
||||||
walk = createWalk();
|
walk = createWalk();
|
||||||
for (final RevSort s : sorting)
|
for (RevSort s : sorting)
|
||||||
walk.sort(s, true);
|
walk.sort(s, true);
|
||||||
|
|
||||||
if (pathFilter == TreeFilter.ALL) {
|
if (pathFilter == TreeFilter.ALL) {
|
||||||
|
@ -187,7 +187,7 @@ else if (revLimiter.size() > 1)
|
||||||
throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD));
|
throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD));
|
||||||
commits.add(walk.parseCommit(head));
|
commits.add(walk.parseCommit(head));
|
||||||
}
|
}
|
||||||
for (final RevCommit c : commits) {
|
for (RevCommit c : commits) {
|
||||||
final RevCommit real = argWalk == walk ? c : walk.parseCommit(c);
|
final RevCommit real = argWalk == walk ? c : walk.parseCommit(c);
|
||||||
if (c.has(RevFlag.UNINTERESTING))
|
if (c.has(RevFlag.UNINTERESTING))
|
||||||
walk.markUninteresting(real);
|
walk.markUninteresting(real);
|
||||||
|
@ -233,7 +233,7 @@ else if (argWalk != null)
|
||||||
*/
|
*/
|
||||||
protected int walkLoop() throws Exception {
|
protected int walkLoop() throws Exception {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (final RevCommit c : walk) {
|
for (RevCommit c : walk) {
|
||||||
if (++n > maxCount && maxCount >= 0)
|
if (++n > maxCount && maxCount >= 0)
|
||||||
break;
|
break;
|
||||||
show(c);
|
show(c);
|
||||||
|
|
|
@ -248,7 +248,7 @@ private void show(RevTag tag) throws IOException {
|
||||||
|
|
||||||
outw.println();
|
outw.println();
|
||||||
final String[] lines = tag.getFullMessage().split("\n"); //$NON-NLS-1$
|
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(" "); //$NON-NLS-1$
|
||||||
outw.print(s);
|
outw.print(s);
|
||||||
outw.println();
|
outw.println();
|
||||||
|
@ -259,7 +259,7 @@ private void show(RevTag tag) throws IOException {
|
||||||
|
|
||||||
private void show(RevTree obj) throws MissingObjectException,
|
private void show(RevTree obj) throws MissingObjectException,
|
||||||
IncorrectObjectTypeException, CorruptObjectException, IOException {
|
IncorrectObjectTypeException, CorruptObjectException, IOException {
|
||||||
try (final TreeWalk walk = new TreeWalk(db)) {
|
try (TreeWalk walk = new TreeWalk(db)) {
|
||||||
walk.reset();
|
walk.reset();
|
||||||
walk.addTree(obj);
|
walk.addTree(obj);
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ private void show(RevWalk rw, RevCommit c) throws Exception {
|
||||||
|
|
||||||
outw.println();
|
outw.println();
|
||||||
final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
|
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(" "); //$NON-NLS-1$
|
||||||
outw.print(s);
|
outw.print(s);
|
||||||
outw.println();
|
outw.println();
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ShowRef extends TextBuiltin {
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
protected void run() throws Exception {
|
||||||
for (final Ref r : getSortedRefs()) {
|
for (Ref r : getSortedRefs()) {
|
||||||
show(r.getObjectId(), r.getName());
|
show(r.getObjectId(), r.getName());
|
||||||
if (r.getPeeledObjectId() != null)
|
if (r.getPeeledObjectId() != null)
|
||||||
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
|
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
|
||||||
|
|
|
@ -129,7 +129,7 @@ public abstract class TextBuiltin {
|
||||||
/** RevWalk used during command line parsing, if it was required. */
|
/** RevWalk used during command line parsing, if it was required. */
|
||||||
protected RevWalk argWalk;
|
protected RevWalk argWalk;
|
||||||
|
|
||||||
final void setCommandName(final String name) {
|
final void setCommandName(String name) {
|
||||||
commandName = name;
|
commandName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ public Repository getRepository() {
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectId resolve(final String s) throws IOException {
|
ObjectId resolve(String s) throws IOException {
|
||||||
final ObjectId r = db.resolve(s);
|
final ObjectId r = db.resolve(s);
|
||||||
if (r == null)
|
if (r == null)
|
||||||
throw die(MessageFormat.format(CLIText.get().notARevision, s));
|
throw die(MessageFormat.format(CLIText.get().notARevision, s));
|
||||||
|
|
|
@ -222,7 +222,7 @@ private static class ToRewrite {
|
||||||
|
|
||||||
ObjectId newId;
|
ObjectId newId;
|
||||||
|
|
||||||
ToRewrite(final ObjectId o, final long t, final ObjectId[] p) {
|
ToRewrite(ObjectId o, long t, ObjectId[] p) {
|
||||||
oldId = o;
|
oldId = o;
|
||||||
commitTime = t;
|
commitTime = t;
|
||||||
oldParents = p;
|
oldParents = p;
|
||||||
|
|
|
@ -65,11 +65,11 @@ protected void run() throws Exception {
|
||||||
final CommandRef[] list = CommandCatalog.all();
|
final CommandRef[] list = CommandCatalog.all();
|
||||||
|
|
||||||
int width = 0;
|
int width = 0;
|
||||||
for (final CommandRef c : list)
|
for (CommandRef c : list)
|
||||||
width = Math.max(width, c.getName().length());
|
width = Math.max(width, c.getName().length());
|
||||||
width += 2;
|
width += 2;
|
||||||
|
|
||||||
for (final CommandRef c : list) {
|
for (CommandRef c : list) {
|
||||||
errw.print(c.isCommon() ? '*' : ' ');
|
errw.print(c.isCommon() ? '*' : ' ');
|
||||||
errw.print(' ');
|
errw.print(' ');
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ static enum Format {
|
||||||
/** */
|
/** */
|
||||||
USAGE {
|
USAGE {
|
||||||
@Override
|
@Override
|
||||||
void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
|
void print(ThrowingPrintWriter err, CommandRef c) throws IOException {
|
||||||
String usage = c.getUsage();
|
String usage = c.getUsage();
|
||||||
if (usage != null && usage.length() > 0)
|
if (usage != null && usage.length() > 0)
|
||||||
err.print(CLIText.get().resourceBundle().getString(usage));
|
err.print(CLIText.get().resourceBundle().getString(usage));
|
||||||
|
@ -97,7 +97,7 @@ void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
|
||||||
/** */
|
/** */
|
||||||
CLASSES {
|
CLASSES {
|
||||||
@Override
|
@Override
|
||||||
void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
|
void print(ThrowingPrintWriter err, CommandRef c) throws IOException {
|
||||||
err.print(c.getImplementationClassName());
|
err.print(c.getImplementationClassName());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -105,7 +105,7 @@ void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
|
||||||
/** */
|
/** */
|
||||||
URLS {
|
URLS {
|
||||||
@Override
|
@Override
|
||||||
void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
|
void print(ThrowingPrintWriter err, CommandRef c) throws IOException {
|
||||||
final ClassLoader ldr = c.getImplementationClassLoader();
|
final ClassLoader ldr = c.getImplementationClassLoader();
|
||||||
|
|
||||||
String cn = c.getImplementationClassName();
|
String cn = c.getImplementationClassName();
|
||||||
|
|
|
@ -85,7 +85,7 @@ static class PatchReader extends CommitReader {
|
||||||
|
|
||||||
int errors;
|
int errors;
|
||||||
|
|
||||||
PatchReader(final HashMap<String, HashMap<String, StatInfo>> s)
|
PatchReader(HashMap<String, HashMap<String, StatInfo>> s)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
super(new String[] { "-p" });
|
super(new String[] { "-p" });
|
||||||
stats = s;
|
stats = s;
|
||||||
|
@ -103,7 +103,7 @@ void onCommit(String cid, byte[] buf) {
|
||||||
p.parse(buf, 0, buf.length - 1);
|
p.parse(buf, 0, buf.length - 1);
|
||||||
assertEquals("File count " + cid, files.size(), p.getFiles().size());
|
assertEquals("File count " + cid, files.size(), p.getFiles().size());
|
||||||
if (!p.getErrors().isEmpty()) {
|
if (!p.getErrors().isEmpty()) {
|
||||||
for (final FormatError e : p.getErrors()) {
|
for (FormatError e : p.getErrors()) {
|
||||||
System.out.println("error " + e.getMessage());
|
System.out.println("error " + e.getMessage());
|
||||||
System.out.println(" at " + e.getLineText());
|
System.out.println(" at " + e.getLineText());
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ void onCommit(String cid, byte[] buf) {
|
||||||
fail("Unexpected error in " + cid);
|
fail("Unexpected error in " + cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final FileHeader fh : p.getFiles()) {
|
for (FileHeader fh : p.getFiles()) {
|
||||||
final String fileName;
|
final String fileName;
|
||||||
if (fh.getChangeType() != FileHeader.ChangeType.DELETE)
|
if (fh.getChangeType() != FileHeader.ChangeType.DELETE)
|
||||||
fileName = fh.getNewPath();
|
fileName = fh.getNewPath();
|
||||||
|
@ -121,7 +121,7 @@ void onCommit(String cid, byte[] buf) {
|
||||||
final String nid = fileName + " in " + cid;
|
final String nid = fileName + " in " + cid;
|
||||||
assertNotNull("No " + nid, s);
|
assertNotNull("No " + nid, s);
|
||||||
int added = 0, deleted = 0;
|
int added = 0, deleted = 0;
|
||||||
for (final HunkHeader h : fh.getHunks()) {
|
for (HunkHeader h : fh.getHunks()) {
|
||||||
added += h.getOldImage().getLinesAdded();
|
added += h.getOldImage().getLinesAdded();
|
||||||
deleted += h.getOldImage().getLinesDeleted();
|
deleted += h.getOldImage().getLinesDeleted();
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ void onCommit(String commitId, byte[] buf) {
|
||||||
static abstract class CommitReader {
|
static abstract class CommitReader {
|
||||||
private Process proc;
|
private Process proc;
|
||||||
|
|
||||||
CommitReader(final String[] args) throws IOException {
|
CommitReader(String[] args) throws IOException {
|
||||||
final String[] realArgs = new String[3 + args.length + 1];
|
final String[] realArgs = new String[3 + args.length + 1];
|
||||||
realArgs[0] = "git";
|
realArgs[0] = "git";
|
||||||
realArgs[1] = "log";
|
realArgs[1] = "log";
|
||||||
|
|
|
@ -1289,7 +1289,7 @@ private static String expected_f3_idx(final int state) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private String getHead(final Git git, final String path)
|
static private String getHead(Git git, String path)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
try {
|
try {
|
||||||
final Repository repo = git.getRepository();
|
final Repository repo = git.getRepository();
|
||||||
|
|
|
@ -78,7 +78,7 @@ public void testPathFilterGroup_DoesNotSkipTail() throws Exception {
|
||||||
|
|
||||||
final int expIdx = 2;
|
final int expIdx = 2;
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.addTree(new DirCacheBuildIterator(b));
|
tw.addTree(new DirCacheBuildIterator(b));
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
tw.setFilter(PathFilterGroup.createFromStrings(Collections
|
tw.setFilter(PathFilterGroup.createFromStrings(Collections
|
||||||
|
|
|
@ -99,7 +99,7 @@ public void testTreeWalk_LsFiles() throws Exception {
|
||||||
assertEquals(ls.size(), dc.getEntryCount());
|
assertEquals(ls.size(), dc.getEntryCount());
|
||||||
{
|
{
|
||||||
final Iterator<CGitIndexRecord> rItr = ls.values().iterator();
|
final Iterator<CGitIndexRecord> rItr = ls.values().iterator();
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
tw.addTree(new DirCacheIterator(dc));
|
tw.addTree(new DirCacheIterator(dc));
|
||||||
while (rItr.hasNext()) {
|
while (rItr.hasNext()) {
|
||||||
|
@ -180,7 +180,7 @@ public void testReadIndex_DirCacheTree() throws Exception {
|
||||||
assertEquals(cList.size(), jTree.getEntrySpan());
|
assertEquals(cList.size(), jTree.getEntrySpan());
|
||||||
|
|
||||||
final ArrayList<CGitLsTreeRecord> subtrees = new ArrayList<>();
|
final ArrayList<CGitLsTreeRecord> subtrees = new ArrayList<>();
|
||||||
for (final CGitLsTreeRecord r : cTree.values()) {
|
for (CGitLsTreeRecord r : cTree.values()) {
|
||||||
if (FileMode.TREE.equals(r.mode))
|
if (FileMode.TREE.equals(r.mode))
|
||||||
subtrees.add(r);
|
subtrees.add(r);
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ private static class CGitIndexRecord {
|
||||||
|
|
||||||
final String path;
|
final String path;
|
||||||
|
|
||||||
CGitIndexRecord(final String line) {
|
CGitIndexRecord(String line) {
|
||||||
final int tab = line.indexOf('\t');
|
final int tab = line.indexOf('\t');
|
||||||
final int sp1 = line.indexOf(' ');
|
final int sp1 = line.indexOf(' ');
|
||||||
final int sp2 = line.indexOf(' ', sp1 + 1);
|
final int sp2 = line.indexOf(' ', sp1 + 1);
|
||||||
|
@ -286,7 +286,7 @@ private static class CGitLsTreeRecord {
|
||||||
|
|
||||||
final String path;
|
final String path;
|
||||||
|
|
||||||
CGitLsTreeRecord(final String line) {
|
CGitLsTreeRecord(String line) {
|
||||||
final int tab = line.indexOf('\t');
|
final int tab = line.indexOf('\t');
|
||||||
final int sp1 = line.indexOf(' ');
|
final int sp1 = line.indexOf(' ');
|
||||||
final int sp2 = line.indexOf(' ', sp1 + 1);
|
final int sp2 = line.indexOf(' ', sp1 + 1);
|
||||||
|
|
|
@ -76,7 +76,7 @@ public void testEmptyTree_WithTreeWalk() throws Exception {
|
||||||
final DirCache dc = DirCache.newInCore();
|
final DirCache dc = DirCache.newInCore();
|
||||||
assertEquals(0, dc.getEntryCount());
|
assertEquals(0, dc.getEntryCount());
|
||||||
|
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.addTree(new DirCacheIterator(dc));
|
tw.addTree(new DirCacheIterator(dc));
|
||||||
assertFalse(tw.next());
|
assertFalse(tw.next());
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ public void testNoSubtree_WithTreeWalk() throws Exception {
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
final DirCacheIterator i = new DirCacheIterator(dc);
|
final DirCacheIterator i = new DirCacheIterator(dc);
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.addTree(i);
|
tw.addTree(i);
|
||||||
int pathIdx = 0;
|
int pathIdx = 0;
|
||||||
while (tw.next()) {
|
while (tw.next()) {
|
||||||
|
@ -164,7 +164,7 @@ public void testSingleSubtree_NoRecursion() throws Exception {
|
||||||
final int expPos[] = { 0, -1, 4 };
|
final int expPos[] = { 0, -1, 4 };
|
||||||
|
|
||||||
final DirCacheIterator i = new DirCacheIterator(dc);
|
final DirCacheIterator i = new DirCacheIterator(dc);
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.addTree(i);
|
tw.addTree(i);
|
||||||
tw.setRecursive(false);
|
tw.setRecursive(false);
|
||||||
int pathIdx = 0;
|
int pathIdx = 0;
|
||||||
|
@ -205,7 +205,7 @@ public void testSingleSubtree_Recursive() throws Exception {
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
final DirCacheIterator i = new DirCacheIterator(dc);
|
final DirCacheIterator i = new DirCacheIterator(dc);
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.addTree(i);
|
tw.addTree(i);
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
int pathIdx = 0;
|
int pathIdx = 0;
|
||||||
|
@ -240,7 +240,7 @@ public void testTwoLevelSubtree_Recursive() throws Exception {
|
||||||
b.add(ents[i]);
|
b.add(ents[i]);
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.addTree(new DirCacheIterator(dc));
|
tw.addTree(new DirCacheIterator(dc));
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
int pathIdx = 0;
|
int pathIdx = 0;
|
||||||
|
@ -402,7 +402,7 @@ public void testTwoLevelSubtree_FilterPath() throws Exception {
|
||||||
b.add(ents[i]);
|
b.add(ents[i]);
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
for (int victimIdx = 0; victimIdx < paths.length; victimIdx++) {
|
for (int victimIdx = 0; victimIdx < paths.length; victimIdx++) {
|
||||||
tw.reset();
|
tw.reset();
|
||||||
tw.addTree(new DirCacheIterator(dc));
|
tw.addTree(new DirCacheIterator(dc));
|
||||||
|
@ -430,7 +430,7 @@ public void testRemovedSubtree() throws Exception {
|
||||||
final DirCache dc = DirCache.read(path, FS.DETECTED);
|
final DirCache dc = DirCache.read(path, FS.DETECTED);
|
||||||
assertEquals(2, dc.getEntryCount());
|
assertEquals(2, dc.getEntryCount());
|
||||||
|
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
tw.addTree(new DirCacheIterator(dc));
|
tw.addTree(new DirCacheIterator(dc));
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ private RevObject parse(AnyObjectId id)
|
||||||
private File[] pack(Repository src, RevObject... list)
|
private File[] pack(Repository src, RevObject... list)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try (PackWriter pw = new PackWriter(src)) {
|
try (PackWriter pw = new PackWriter(src)) {
|
||||||
for (final RevObject o : list) {
|
for (RevObject o : list) {
|
||||||
pw.addObject(o);
|
pw.addObject(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ private static void write(File[] files, PackWriter pw)
|
||||||
|
|
||||||
private static void delete(File[] list) throws IOException {
|
private static void delete(File[] list) throws IOException {
|
||||||
final long begin = list[0].getParentFile().lastModified();
|
final long begin = list[0].getParentFile().lastModified();
|
||||||
for (final File f : list) {
|
for (File f : list) {
|
||||||
FileUtils.delete(f);
|
FileUtils.delete(f);
|
||||||
assertFalse(f + " was removed", f.exists());
|
assertFalse(f + " was removed", f.exists());
|
||||||
}
|
}
|
||||||
|
|
|
@ -368,7 +368,7 @@ public void testWritePack3() throws MissingObjectException, IOException {
|
||||||
ObjectId.fromString("902d5476fa249b7abc9d84c611577a81381f0327"),
|
ObjectId.fromString("902d5476fa249b7abc9d84c611577a81381f0327"),
|
||||||
ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") ,
|
ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") ,
|
||||||
ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259") };
|
ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259") };
|
||||||
try (final RevWalk parser = new RevWalk(db)) {
|
try (RevWalk parser = new RevWalk(db)) {
|
||||||
final RevObject forcedOrderRevs[] = new RevObject[forcedOrder.length];
|
final RevObject forcedOrderRevs[] = new RevObject[forcedOrder.length];
|
||||||
for (int i = 0; i < forcedOrder.length; i++)
|
for (int i = 0; i < forcedOrder.length; i++)
|
||||||
forcedOrderRevs[i] = parser.parseAny(forcedOrder[i]);
|
forcedOrderRevs[i] = parser.parseAny(forcedOrder[i]);
|
||||||
|
|
|
@ -305,7 +305,7 @@ public void test002_WriteEmptyTree() throws IOException {
|
||||||
// object (as it already exists in the pack).
|
// object (as it already exists in the pack).
|
||||||
//
|
//
|
||||||
final Repository newdb = createBareRepository();
|
final Repository newdb = createBareRepository();
|
||||||
try (final ObjectInserter oi = newdb.newObjectInserter()) {
|
try (ObjectInserter oi = newdb.newObjectInserter()) {
|
||||||
final ObjectId treeId = oi.insert(new TreeFormatter());
|
final ObjectId treeId = oi.insert(new TreeFormatter());
|
||||||
assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904",
|
assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904",
|
||||||
treeId.name());
|
treeId.name());
|
||||||
|
@ -373,7 +373,7 @@ public void test006_ReadUglyConfig() throws IOException,
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test007_Open() throws IOException {
|
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.getDirectory(), db2.getDirectory());
|
||||||
assertEquals(db.getObjectDatabase().getDirectory(), db2
|
assertEquals(db.getObjectDatabase().getDirectory(), db2
|
||||||
.getObjectDatabase().getDirectory());
|
.getObjectDatabase().getDirectory());
|
||||||
|
@ -557,7 +557,7 @@ public void test025_computeSha1NoStore() {
|
||||||
@Test
|
@Test
|
||||||
public void test026_CreateCommitMultipleparents() throws IOException {
|
public void test026_CreateCommitMultipleparents() throws IOException {
|
||||||
final ObjectId treeId;
|
final ObjectId treeId;
|
||||||
try (final ObjectInserter oi = db.newObjectInserter()) {
|
try (ObjectInserter oi = db.newObjectInserter()) {
|
||||||
final ObjectId blobId = oi.insert(Constants.OBJ_BLOB,
|
final ObjectId blobId = oi.insert(Constants.OBJ_BLOB,
|
||||||
"and this is the data in me\n".getBytes(Constants.CHARSET
|
"and this is the data in me\n".getBytes(Constants.CHARSET
|
||||||
.name()));
|
.name()));
|
||||||
|
|
|
@ -133,7 +133,7 @@ private static void checkLimits(WindowCacheConfig cfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doCacheTests() throws IOException {
|
private void doCacheTests() throws IOException {
|
||||||
for (final TestObject o : toLoad) {
|
for (TestObject o : toLoad) {
|
||||||
final ObjectLoader or = db.open(o.id, o.type);
|
final ObjectLoader or = db.open(o.id, o.type);
|
||||||
assertNotNull(or);
|
assertNotNull(or);
|
||||||
assertEquals(o.type, or.getType());
|
assertEquals(o.type, or.getType());
|
||||||
|
@ -145,7 +145,7 @@ private class TestObject {
|
||||||
|
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
void setType(final String typeStr) throws CorruptObjectException {
|
void setType(String typeStr) throws CorruptObjectException {
|
||||||
final byte[] typeRaw = Constants.encode(typeStr + " ");
|
final byte[] typeRaw = Constants.encode(typeStr + " ");
|
||||||
final MutableInteger ptr = new MutableInteger();
|
final MutableInteger ptr = new MutableInteger();
|
||||||
type = Constants.decodeTypeString(id, typeRaw, (byte) ' ', ptr);
|
type = Constants.decodeTypeString(id, typeRaw, (byte) ' ', ptr);
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
class XInputStream extends BufferedInputStream {
|
class XInputStream extends BufferedInputStream {
|
||||||
private final byte[] intbuf = new byte[8];
|
private final byte[] intbuf = new byte[8];
|
||||||
|
|
||||||
XInputStream(final InputStream s) {
|
XInputStream(InputStream s) {
|
||||||
super(s);
|
super(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ synchronized byte[] readFully(final int len) throws IOException {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void readFully(final byte[] b, int o, int len)
|
synchronized void readFully(byte[] b, int o, int len)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
int r;
|
int r;
|
||||||
while (len > 0 && (r = read(b, o, len)) > 0) {
|
while (len > 0 && (r = read(b, o, len)) > 0) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ public void testEquals() throws Exception {
|
||||||
|
|
||||||
final RevCommit a2;
|
final RevCommit a2;
|
||||||
final RevCommit b2;
|
final RevCommit b2;
|
||||||
try (final RevWalk rw2 = new RevWalk(db)) {
|
try (RevWalk rw2 = new RevWalk(db)) {
|
||||||
a2 = rw2.parseCommit(a1);
|
a2 = rw2.parseCommit(a1);
|
||||||
b2 = rw2.parseCommit(b1);
|
b2 = rw2.parseCommit(b1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,14 +105,14 @@ public void setUp() throws Exception {
|
||||||
protected void check(RevCommit... order) throws Exception {
|
protected void check(RevCommit... order) throws Exception {
|
||||||
markStart(i);
|
markStart(i);
|
||||||
final StringBuilder act = new StringBuilder();
|
final StringBuilder act = new StringBuilder();
|
||||||
for (final RevCommit z : rw) {
|
for (RevCommit z : rw) {
|
||||||
final String name = byName.get(z);
|
final String name = byName.get(z);
|
||||||
assertNotNull(name);
|
assertNotNull(name);
|
||||||
act.append(name);
|
act.append(name);
|
||||||
act.append(' ');
|
act.append(' ');
|
||||||
}
|
}
|
||||||
final StringBuilder exp = new StringBuilder();
|
final StringBuilder exp = new StringBuilder();
|
||||||
for (final RevCommit z : order) {
|
for (RevCommit z : order) {
|
||||||
final String name = byName.get(z);
|
final String name = byName.get(z);
|
||||||
assertNotNull(name);
|
assertNotNull(name);
|
||||||
exp.append(name);
|
exp.append(name);
|
||||||
|
|
|
@ -422,7 +422,7 @@ private class MockPushConnection extends BaseConnection implements
|
||||||
PushConnection {
|
PushConnection {
|
||||||
MockPushConnection() {
|
MockPushConnection() {
|
||||||
final Map<String, Ref> refsMap = new HashMap<>();
|
final Map<String, Ref> refsMap = new HashMap<>();
|
||||||
for (final Ref r : advertisedRefs)
|
for (Ref r : advertisedRefs)
|
||||||
refsMap.put(r.getName(), r);
|
refsMap.put(r.getName(), r);
|
||||||
available(refsMap);
|
available(refsMap);
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,7 @@ public void push(ProgressMonitor monitor,
|
||||||
public void push(ProgressMonitor monitor,
|
public void push(ProgressMonitor monitor,
|
||||||
Map<String, RemoteRefUpdate> refsToUpdate)
|
Map<String, RemoteRefUpdate> refsToUpdate)
|
||||||
throws TransportException {
|
throws TransportException {
|
||||||
for (final RemoteRefUpdate rru : refsToUpdate.values()) {
|
for (RemoteRefUpdate rru : refsToUpdate.values()) {
|
||||||
assertEquals(Status.NOT_ATTEMPTED, rru.getStatus());
|
assertEquals(Status.NOT_ATTEMPTED, rru.getStatus());
|
||||||
rru.setStatus(connectionUpdateStatus);
|
rru.setStatus(connectionUpdateStatus);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ public void testFilterHidesPrivate() throws Exception {
|
||||||
try (TransportLocal t = new TransportLocal(src, uriOf(dst),
|
try (TransportLocal t = new TransportLocal(src, uriOf(dst),
|
||||||
dst.getDirectory()) {
|
dst.getDirectory()) {
|
||||||
@Override
|
@Override
|
||||||
ReceivePack createReceivePack(final Repository db) {
|
ReceivePack createReceivePack(Repository db) {
|
||||||
db.close();
|
db.close();
|
||||||
dst.incrementOpen();
|
dst.incrementOpen();
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ private TransportLocal newTransportLocalWithStrictValidation()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
return new TransportLocal(src, uriOf(dst), dst.getDirectory()) {
|
return new TransportLocal(src, uriOf(dst), dst.getDirectory()) {
|
||||||
@Override
|
@Override
|
||||||
ReceivePack createReceivePack(final Repository db) {
|
ReceivePack createReceivePack(Repository db) {
|
||||||
db.close();
|
db.close();
|
||||||
dst.incrementOpen();
|
dst.incrementOpen();
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ public void testFindRemoteRefUpdatesWildcardNoTracking() throws IOException {
|
||||||
assertEquals(12, result.size());
|
assertEquals(12, result.size());
|
||||||
boolean foundA = false;
|
boolean foundA = false;
|
||||||
boolean foundB = false;
|
boolean foundB = false;
|
||||||
for (final RemoteRefUpdate rru : result) {
|
for (RemoteRefUpdate rru : result) {
|
||||||
if ("refs/heads/a".equals(rru.getSrcRef())
|
if ("refs/heads/a".equals(rru.getSrcRef())
|
||||||
&& "refs/heads/test/a".equals(rru.getRemoteName()))
|
&& "refs/heads/test/a".equals(rru.getRemoteName()))
|
||||||
foundA = true;
|
foundA = true;
|
||||||
|
@ -174,7 +174,7 @@ public void testFindRemoteRefUpdatesTwoRefSpecs() throws IOException {
|
||||||
assertEquals(2, result.size());
|
assertEquals(2, result.size());
|
||||||
boolean foundA = false;
|
boolean foundA = false;
|
||||||
boolean foundC = false;
|
boolean foundC = false;
|
||||||
for (final RemoteRefUpdate rru : result) {
|
for (RemoteRefUpdate rru : result) {
|
||||||
if ("refs/heads/a".equals(rru.getSrcRef())
|
if ("refs/heads/a".equals(rru.getSrcRef())
|
||||||
&& "refs/heads/b".equals(rru.getRemoteName()))
|
&& "refs/heads/b".equals(rru.getRemoteName()))
|
||||||
foundA = true;
|
foundA = true;
|
||||||
|
@ -233,7 +233,7 @@ public void testFindRemoteRefUpdatesWithLeases() throws IOException {
|
||||||
assertEquals(2, result.size());
|
assertEquals(2, result.size());
|
||||||
boolean foundA = false;
|
boolean foundA = false;
|
||||||
boolean foundC = false;
|
boolean foundC = false;
|
||||||
for (final RemoteRefUpdate rru : result) {
|
for (RemoteRefUpdate rru : result) {
|
||||||
if ("refs/heads/a".equals(rru.getSrcRef())
|
if ("refs/heads/a".equals(rru.getSrcRef())
|
||||||
&& "refs/heads/b".equals(rru.getRemoteName())) {
|
&& "refs/heads/b".equals(rru.getRemoteName())) {
|
||||||
foundA = true;
|
foundA = true;
|
||||||
|
|
|
@ -93,7 +93,7 @@ public void setUp() throws Exception {
|
||||||
|
|
||||||
private static byte[] mktree(byte[]... data) throws Exception {
|
private static byte[] mktree(byte[]... data) throws Exception {
|
||||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
for (final byte[] e : data)
|
for (byte[] e : data)
|
||||||
out.write(e);
|
out.write(e);
|
||||||
return out.toByteArray();
|
return out.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,14 +60,14 @@
|
||||||
public class PostOrderTreeWalkTest extends RepositoryTestCase {
|
public class PostOrderTreeWalkTest extends RepositoryTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testInitialize_NoPostOrder() throws Exception {
|
public void testInitialize_NoPostOrder() throws Exception {
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
assertFalse(tw.isPostOrderTraversal());
|
assertFalse(tw.isPostOrderTraversal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInitialize_TogglePostOrder() throws Exception {
|
public void testInitialize_TogglePostOrder() throws Exception {
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
assertFalse(tw.isPostOrderTraversal());
|
assertFalse(tw.isPostOrderTraversal());
|
||||||
tw.setPostOrderTraversal(true);
|
tw.setPostOrderTraversal(true);
|
||||||
assertTrue(tw.isPostOrderTraversal());
|
assertTrue(tw.isPostOrderTraversal());
|
||||||
|
@ -78,7 +78,7 @@ public void testInitialize_TogglePostOrder() throws Exception {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResetDoesNotAffectPostOrder() throws Exception {
|
public void testResetDoesNotAffectPostOrder() throws Exception {
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.setPostOrderTraversal(true);
|
tw.setPostOrderTraversal(true);
|
||||||
assertTrue(tw.isPostOrderTraversal());
|
assertTrue(tw.isPostOrderTraversal());
|
||||||
tw.reset();
|
tw.reset();
|
||||||
|
@ -104,7 +104,7 @@ public void testNoPostOrder() throws Exception {
|
||||||
b.finish();
|
b.finish();
|
||||||
assertEquals(4, tree.getEntryCount());
|
assertEquals(4, tree.getEntryCount());
|
||||||
|
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.setPostOrderTraversal(false);
|
tw.setPostOrderTraversal(false);
|
||||||
tw.addTree(new DirCacheIterator(tree));
|
tw.addTree(new DirCacheIterator(tree));
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ public void testWithPostOrder_EnterSubtree() throws Exception {
|
||||||
b.finish();
|
b.finish();
|
||||||
assertEquals(4, tree.getEntryCount());
|
assertEquals(4, tree.getEntryCount());
|
||||||
|
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.setPostOrderTraversal(true);
|
tw.setPostOrderTraversal(true);
|
||||||
tw.addTree(new DirCacheIterator(tree));
|
tw.addTree(new DirCacheIterator(tree));
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ public void testWithPostOrder_NoEnterSubtree() throws Exception {
|
||||||
b.finish();
|
b.finish();
|
||||||
assertEquals(4, tree.getEntryCount());
|
assertEquals(4, tree.getEntryCount());
|
||||||
|
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.setPostOrderTraversal(true);
|
tw.setPostOrderTraversal(true);
|
||||||
tw.addTree(new DirCacheIterator(tree));
|
tw.addTree(new DirCacheIterator(tree));
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,7 @@ private static boolean includes(TreeFilter f, TreeWalk tw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeWalk fakeWalk(final String path) throws IOException {
|
TreeWalk fakeWalk(String path) throws IOException {
|
||||||
DirCache dc = DirCache.newInCore();
|
DirCache dc = DirCache.newInCore();
|
||||||
DirCacheEditor dce = dc.editor();
|
DirCacheEditor dce = dc.editor();
|
||||||
dce.add(new DirCacheEditor.PathEdit(path) {
|
dce.add(new DirCacheEditor.PathEdit(path) {
|
||||||
|
@ -274,7 +274,7 @@ public void apply(DirCacheEntry ent) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeWalk fakeWalkAtSubtree(final String path) throws IOException {
|
TreeWalk fakeWalkAtSubtree(String path) throws IOException {
|
||||||
DirCache dc = DirCache.newInCore();
|
DirCache dc = DirCache.newInCore();
|
||||||
DirCacheEditor dce = dc.editor();
|
DirCacheEditor dce = dc.editor();
|
||||||
dce.add(new DirCacheEditor.PathEdit(path + "/README") {
|
dce.add(new DirCacheEditor.PathEdit(path + "/README") {
|
||||||
|
|
|
@ -113,7 +113,7 @@ private List<String> getMatchingPaths(String suffixFilter,
|
||||||
|
|
||||||
private List<String> getMatchingPaths(String suffixFilter,
|
private List<String> getMatchingPaths(String suffixFilter,
|
||||||
final ObjectId treeId, boolean recursiveWalk) throws IOException {
|
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.setFilter(PathSuffixFilter.create(suffixFilter));
|
||||||
tw.setRecursive(recursiveWalk);
|
tw.setRecursive(recursiveWalk);
|
||||||
tw.addTree(treeId);
|
tw.addTree(treeId);
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
public class TreeFilterTest extends RepositoryTestCase {
|
public class TreeFilterTest extends RepositoryTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testALL_IncludesAnything() throws Exception {
|
public void testALL_IncludesAnything() throws Exception {
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.addTree(new EmptyTreeIterator());
|
tw.addTree(new EmptyTreeIterator());
|
||||||
assertTrue(TreeFilter.ALL.include(tw));
|
assertTrue(TreeFilter.ALL.include(tw));
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public void testALL_IdentityClone() throws Exception {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotALL_IncludesNothing() throws Exception {
|
public void testNotALL_IncludesNothing() throws Exception {
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.addTree(new EmptyTreeIterator());
|
tw.addTree(new EmptyTreeIterator());
|
||||||
assertFalse(TreeFilter.ALL.negate().include(tw));
|
assertFalse(TreeFilter.ALL.negate().include(tw));
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public void testNotALL_IncludesNothing() throws Exception {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testANY_DIFF_IncludesSingleTreeCase() throws Exception {
|
public void testANY_DIFF_IncludesSingleTreeCase() throws Exception {
|
||||||
try (final TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.addTree(new EmptyTreeIterator());
|
tw.addTree(new EmptyTreeIterator());
|
||||||
assertTrue(TreeFilter.ANY_DIFF.include(tw));
|
assertTrue(TreeFilter.ANY_DIFF.include(tw));
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ public void testLarge_SingleWrite() throws IOException {
|
||||||
public void testInCoreInputStream() throws IOException {
|
public void testInCoreInputStream() throws IOException {
|
||||||
final int cnt = 256;
|
final int cnt = 256;
|
||||||
final byte[] test = new TestRng(getName()).nextBytes(cnt);
|
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);
|
b.write(test);
|
||||||
InputStream in = b.openInputStream();
|
InputStream in = b.openInputStream();
|
||||||
byte[] act = new byte[cnt];
|
byte[] act = new byte[cnt];
|
||||||
|
|
|
@ -66,11 +66,11 @@ final class AWTPlotRenderer extends AbstractPlotRenderer<SwingLane, Color>
|
||||||
|
|
||||||
transient Graphics2D g;
|
transient Graphics2D g;
|
||||||
|
|
||||||
AWTPlotRenderer(final GraphCellRender c) {
|
AWTPlotRenderer(GraphCellRender c) {
|
||||||
cell = c;
|
cell = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(final Graphics in, final PlotCommit<SwingLane> commit) {
|
void paint(Graphics in, PlotCommit<SwingLane> commit) {
|
||||||
g = (Graphics2D) in.create();
|
g = (Graphics2D) in.create();
|
||||||
try {
|
try {
|
||||||
final int h = cell.getHeight();
|
final int h = cell.getHeight();
|
||||||
|
@ -138,7 +138,7 @@ protected Color laneColor(SwingLane myLane) {
|
||||||
return myLane != null ? myLane.color : Color.black;
|
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 tipX = cx;
|
||||||
final int tipY = y + h;
|
final int tipY = y + h;
|
||||||
final int baseX1 = cx - 10 / 2;
|
final int baseX1 = cx - 10 / 2;
|
||||||
|
|
|
@ -175,7 +175,7 @@ public Object getValueAt(int rowIndex, int columnIndex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PersonIdent authorFor(final PlotCommit<SwingLane> c) {
|
PersonIdent authorFor(PlotCommit<SwingLane> c) {
|
||||||
if (c != lastCommit) {
|
if (c != lastCommit) {
|
||||||
lastCommit = c;
|
lastCommit = c;
|
||||||
lastAuthor = c.getAuthorIdent();
|
lastAuthor = c.getAuthorIdent();
|
||||||
|
@ -259,7 +259,7 @@ protected void paintComponent(Graphics inputGraphics) {
|
||||||
strokeCache[i] = new BasicStroke(i);
|
strokeCache[i] = new BasicStroke(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Stroke stroke(final int width) {
|
static Stroke stroke(int width) {
|
||||||
if (width < strokeCache.length)
|
if (width < strokeCache.length)
|
||||||
return strokeCache[width];
|
return strokeCache[width];
|
||||||
return new BasicStroke(width);
|
return new BasicStroke(width);
|
||||||
|
|
|
@ -315,7 +315,7 @@ private List<RefSpec> calculateRefSpecs(String dst) {
|
||||||
specs.add(wcrs);
|
specs.add(wcrs);
|
||||||
else if (branchesToClone != null
|
else if (branchesToClone != null
|
||||||
&& branchesToClone.size() > 0) {
|
&& branchesToClone.size() > 0) {
|
||||||
for (final String selectedRef : branchesToClone)
|
for (String selectedRef : branchesToClone)
|
||||||
if (wcrs.matchSource(selectedRef))
|
if (wcrs.matchSource(selectedRef))
|
||||||
specs.add(wcrs.expandFromSource(selectedRef));
|
specs.add(wcrs.expandFromSource(selectedRef));
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ private Ref findBranchToCheckout(FetchResult result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref foundBranch = null;
|
Ref foundBranch = null;
|
||||||
for (final Ref r : result.getAdvertisedRefs()) {
|
for (Ref r : result.getAdvertisedRefs()) {
|
||||||
final String n = r.getName();
|
final String n = r.getName();
|
||||||
if (!n.startsWith(Constants.R_HEADS))
|
if (!n.startsWith(Constants.R_HEADS))
|
||||||
continue;
|
continue;
|
||||||
|
@ -444,7 +444,7 @@ private RevCommit parseCommit(Repository clonedRepo, Ref ref)
|
||||||
throws MissingObjectException, IncorrectObjectTypeException,
|
throws MissingObjectException, IncorrectObjectTypeException,
|
||||||
IOException {
|
IOException {
|
||||||
final RevCommit commit;
|
final RevCommit commit;
|
||||||
try (final RevWalk rw = new RevWalk(clonedRepo)) {
|
try (RevWalk rw = new RevWalk(clonedRepo)) {
|
||||||
commit = rw.parseCommit(ref.getObjectId());
|
commit = rw.parseCommit(ref.getObjectId());
|
||||||
}
|
}
|
||||||
return commit;
|
return commit;
|
||||||
|
|
|
@ -360,7 +360,7 @@ public ResetCommand setProgressMonitor(ProgressMonitor monitor) {
|
||||||
|
|
||||||
private void resetIndexForPaths(ObjectId commitTree) {
|
private void resetIndexForPaths(ObjectId commitTree) {
|
||||||
DirCache dc = null;
|
DirCache dc = null;
|
||||||
try (final TreeWalk tw = new TreeWalk(repo)) {
|
try (TreeWalk tw = new TreeWalk(repo)) {
|
||||||
dc = repo.lockDirCache();
|
dc = repo.lockDirCache();
|
||||||
DirCacheBuilder builder = dc.builder();
|
DirCacheBuilder builder = dc.builder();
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ public DirCache call() throws GitAPIException,
|
||||||
DirCache dc = null;
|
DirCache dc = null;
|
||||||
|
|
||||||
List<String> actuallyDeletedFiles = new ArrayList<>();
|
List<String> actuallyDeletedFiles = new ArrayList<>();
|
||||||
try (final TreeWalk tw = new TreeWalk(repo)) {
|
try (TreeWalk tw = new TreeWalk(repo)) {
|
||||||
dc = repo.lockDirCache();
|
dc = repo.lockDirCache();
|
||||||
DirCacheBuilder builder = dc.builder();
|
DirCacheBuilder builder = dc.builder();
|
||||||
tw.reset(); // drop the first empty tree, which we do not need here
|
tw.reset(); // drop the first empty tree, which we do not need here
|
||||||
|
|
|
@ -195,7 +195,7 @@ public StashCreateCommand setIncludeUntracked(boolean includeUntracked) {
|
||||||
|
|
||||||
private RevCommit parseCommit(final ObjectReader reader,
|
private RevCommit parseCommit(final ObjectReader reader,
|
||||||
final ObjectId headId) throws IOException {
|
final ObjectId headId) throws IOException {
|
||||||
try (final RevWalk walk = new RevWalk(reader)) {
|
try (RevWalk walk = new RevWalk(reader)) {
|
||||||
return walk.parseCommit(headId);
|
return walk.parseCommit(headId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ int getChildCount() {
|
||||||
return children.length;
|
return children.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReverseCommit getChild(final int nth) {
|
ReverseCommit getChild(int nth) {
|
||||||
return children[nth];
|
return children[nth];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,7 +359,7 @@ void initialize(int k, int x, int minK, int maxK) {
|
||||||
abstract int getLeft(int x);
|
abstract int getLeft(int x);
|
||||||
abstract int getRight(int x);
|
abstract int getRight(int x);
|
||||||
abstract boolean isBetter(int left, int right);
|
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);
|
abstract boolean meets(int d, int k, int x, long snake);
|
||||||
|
|
||||||
final long newSnake(int k, int x) {
|
final long newSnake(int k, int x) {
|
||||||
|
@ -469,22 +469,22 @@ final int snake(int k, int x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final int getLeft(final int x) {
|
final int getLeft(int x) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final int getRight(final int x) {
|
final int getRight(int x) {
|
||||||
return x + 1;
|
return x + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final boolean isBetter(final int left, final int right) {
|
final boolean isBetter(int left, int right) {
|
||||||
return left > right;
|
return left > right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final void adjustMinMaxK(final int k, final int x) {
|
final void adjustMinMaxK(int k, int x) {
|
||||||
if (x >= endA || k + x >= endB) {
|
if (x >= endA || k + x >= endB) {
|
||||||
if (k > backward.middleK)
|
if (k > backward.middleK)
|
||||||
maxK = k;
|
maxK = k;
|
||||||
|
@ -517,22 +517,22 @@ final int snake(int k, int x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final int getLeft(final int x) {
|
final int getLeft(int x) {
|
||||||
return x - 1;
|
return x - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final int getRight(final int x) {
|
final int getRight(int x) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final boolean isBetter(final int left, final int right) {
|
final boolean isBetter(int left, int right) {
|
||||||
return left < right;
|
return left < right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final void adjustMinMaxK(final int k, final int x) {
|
final void adjustMinMaxK(int k, int x) {
|
||||||
if (x <= beginA || k + x <= beginB) {
|
if (x <= beginA || k + x <= beginB) {
|
||||||
if (k > forward.middleK)
|
if (k > forward.middleK)
|
||||||
maxK = k;
|
maxK = k;
|
||||||
|
|
|
@ -157,7 +157,7 @@ private void hashLargeObject(ObjectLoader obj) throws IOException,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
final boolean text = !RawText.isBinary(raw);
|
||||||
hashedCnt = 0;
|
hashedCnt = 0;
|
||||||
while (ptr < end) {
|
while (ptr < end) {
|
||||||
|
|
|
@ -121,11 +121,11 @@ public int compare(DirCacheEntry o1, DirCacheEntry o2) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int cmp(final DirCacheEntry a, final DirCacheEntry b) {
|
static int cmp(DirCacheEntry a, DirCacheEntry b) {
|
||||||
return cmp(a.path, a.path.length, 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 cmp(aPath, aLen, b.path, b.path.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ public DirCacheEditor editor() {
|
||||||
return new DirCacheEditor(this, entryCnt + 16);
|
return new DirCacheEditor(this, entryCnt + 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void replace(final DirCacheEntry[] e, final int cnt) {
|
void replace(DirCacheEntry[] e, int cnt) {
|
||||||
sortedEntries = e;
|
sortedEntries = e;
|
||||||
entryCnt = cnt;
|
entryCnt = cnt;
|
||||||
tree = null;
|
tree = null;
|
||||||
|
@ -648,7 +648,7 @@ public void write() throws IOException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeTo(File dir, final OutputStream os) throws IOException {
|
void writeTo(File dir, OutputStream os) throws IOException {
|
||||||
final MessageDigest foot = Constants.newMessageDigest();
|
final MessageDigest foot = Constants.newMessageDigest();
|
||||||
final DigestOutputStream dos = new DigestOutputStream(os, foot);
|
final DigestOutputStream dos = new DigestOutputStream(os, foot);
|
||||||
|
|
||||||
|
@ -848,7 +848,7 @@ public int nextEntry(int position) {
|
||||||
return nextIdx;
|
return nextIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nextEntry(final byte[] p, final int pLen, int nextIdx) {
|
int nextEntry(byte[] p, int pLen, int nextIdx) {
|
||||||
while (nextIdx < entryCnt) {
|
while (nextIdx < entryCnt) {
|
||||||
final DirCacheEntry next = sortedEntries[nextIdx];
|
final DirCacheEntry next = sortedEntries[nextIdx];
|
||||||
if (!DirCacheTree.peq(p, next.path, pLen))
|
if (!DirCacheTree.peq(p, next.path, pLen))
|
||||||
|
|
|
@ -312,7 +312,7 @@ public DirCacheEntry(DirCacheEntry src) {
|
||||||
System.arraycopy(src.info, src.infoOffset, info, 0, INFO_LEN);
|
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 len = isExtended() ? INFO_LEN_EXTENDED : INFO_LEN;
|
||||||
final int pathLen = path.length;
|
final int pathLen = path.length;
|
||||||
os.write(info, infoOffset, len);
|
os.write(info, infoOffset, len);
|
||||||
|
@ -719,7 +719,7 @@ public void copyMetaData(DirCacheEntry src) {
|
||||||
* @param keepStage
|
* @param keepStage
|
||||||
* if true, the stage attribute will not be copied
|
* 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 origflags = NB.decodeUInt16(info, infoOffset + P_FLAGS);
|
||||||
int newflags = NB.decodeUInt16(src.info, src.infoOffset + P_FLAGS);
|
int newflags = NB.decodeUInt16(src.info, src.infoOffset + P_FLAGS);
|
||||||
System.arraycopy(src.info, src.infoOffset, info, infoOffset, INFO_LEN);
|
System.arraycopy(src.info, src.infoOffset, info, infoOffset, INFO_LEN);
|
||||||
|
@ -771,7 +771,7 @@ private static void checkPath(byte[] path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String toString(final byte[] path) {
|
static String toString(byte[] path) {
|
||||||
return Constants.CHARSET.decode(ByteBuffer.wrap(path)).toString();
|
return Constants.CHARSET.decode(ByteBuffer.wrap(path)).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ public DirCacheIterator(DirCache dc) {
|
||||||
parseEntry();
|
parseEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
DirCacheIterator(final DirCacheIterator p, final DirCacheTree dct) {
|
DirCacheIterator(DirCacheIterator p, DirCacheTree dct) {
|
||||||
super(p, p.path, p.pathLen + 1);
|
super(p, p.path, p.pathLen + 1);
|
||||||
cache = p.cache;
|
cache = p.cache;
|
||||||
tree = dct;
|
tree = dct;
|
||||||
|
|
|
@ -185,7 +185,7 @@ private DirCacheTree(final DirCacheTree myParent, final byte[] path,
|
||||||
childCnt = subcnt;
|
childCnt = subcnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(final byte[] tmp, final OutputStream os) throws IOException {
|
void write(byte[] tmp, OutputStream os) throws IOException {
|
||||||
int ptr = tmp.length;
|
int ptr = tmp.length;
|
||||||
tmp[--ptr] = '\n';
|
tmp[--ptr] = '\n';
|
||||||
ptr = RawParseUtils.formatBase10(tmp, ptr, childCnt);
|
ptr = RawParseUtils.formatBase10(tmp, ptr, childCnt);
|
||||||
|
@ -404,7 +404,7 @@ final int nameLength() {
|
||||||
return encodedName.length;
|
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 byte[] e = encodedName;
|
||||||
final int eLen = e.length;
|
final int eLen = e.length;
|
||||||
for (int eOff = 0; eOff < eLen && aOff < aLen; eOff++, aOff++)
|
for (int eOff = 0; eOff < eLen && aOff < aLen; eOff++, aOff++)
|
||||||
|
@ -531,7 +531,7 @@ private void removeChild(int stIdx) {
|
||||||
children[n] = null;
|
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)
|
if (b.length < aLen)
|
||||||
return false;
|
return false;
|
||||||
for (aLen--; aLen >= 0; aLen--)
|
for (aLen--; aLen >= 0; aLen--)
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class CompoundException extends Exception {
|
||||||
private static String format(Collection<Throwable> causes) {
|
private static String format(Collection<Throwable> causes) {
|
||||||
final StringBuilder msg = new StringBuilder();
|
final StringBuilder msg = new StringBuilder();
|
||||||
msg.append(JGitText.get().failureDueToOneOfTheFollowing);
|
msg.append(JGitText.get().failureDueToOneOfTheFollowing);
|
||||||
for (final Throwable c : causes) {
|
for (Throwable c : causes) {
|
||||||
msg.append(" "); //$NON-NLS-1$
|
msg.append(" "); //$NON-NLS-1$
|
||||||
msg.append(c.getMessage());
|
msg.append(c.getMessage());
|
||||||
msg.append("\n"); //$NON-NLS-1$
|
msg.append("\n"); //$NON-NLS-1$
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class MissingBundlePrerequisiteException extends TransportException {
|
||||||
private static String format(Map<ObjectId, String> missingCommits) {
|
private static String format(Map<ObjectId, String> missingCommits) {
|
||||||
final StringBuilder r = new StringBuilder();
|
final StringBuilder r = new StringBuilder();
|
||||||
r.append(JGitText.get().missingPrerequisiteCommits);
|
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("\n "); //$NON-NLS-1$
|
||||||
r.append(e.getKey().name());
|
r.append(e.getKey().name());
|
||||||
if (e.getValue() != null)
|
if (e.getValue() != null)
|
||||||
|
|
|
@ -61,7 +61,7 @@ final class GroupHead extends AbstractHead {
|
||||||
|
|
||||||
private final boolean inverse;
|
private final boolean inverse;
|
||||||
|
|
||||||
GroupHead(String pattern, final String wholePattern)
|
GroupHead(String pattern, String wholePattern)
|
||||||
throws InvalidPatternException {
|
throws InvalidPatternException {
|
||||||
super(false);
|
super(false);
|
||||||
this.characterClasses = new ArrayList<>();
|
this.characterClasses = new ArrayList<>();
|
||||||
|
@ -214,7 +214,7 @@ public final boolean matches(char c) {
|
||||||
private static final class OneCharacterPattern implements CharacterPattern {
|
private static final class OneCharacterPattern implements CharacterPattern {
|
||||||
private char expectedCharacter;
|
private char expectedCharacter;
|
||||||
|
|
||||||
OneCharacterPattern(final char c) {
|
OneCharacterPattern(char c) {
|
||||||
this.expectedCharacter = c;
|
this.expectedCharacter = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
final class RestrictedWildCardHead extends AbstractHead {
|
final class RestrictedWildCardHead extends AbstractHead {
|
||||||
private final char excludedCharacter;
|
private final char excludedCharacter;
|
||||||
|
|
||||||
RestrictedWildCardHead(final char excludedCharacter, final boolean star) {
|
RestrictedWildCardHead(char excludedCharacter, boolean star) {
|
||||||
super(star);
|
super(star);
|
||||||
this.excludedCharacter = excludedCharacter;
|
this.excludedCharacter = excludedCharacter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -497,7 +497,7 @@ void addReftable(DfsPackDescription add, Set<DfsPackDescription> remove)
|
||||||
} while (!packList.compareAndSet(o, n));
|
} while (!packList.compareAndSet(o, n));
|
||||||
}
|
}
|
||||||
|
|
||||||
PackList scanPacks(final PackList original) throws IOException {
|
PackList scanPacks(PackList original) throws IOException {
|
||||||
PackList o, n;
|
PackList o, n;
|
||||||
synchronized (packList) {
|
synchronized (packList) {
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -60,7 +60,7 @@ class DfsObjectToPack extends ObjectToPack {
|
||||||
/** Length of the data section of the object. */
|
/** Length of the data section of the object. */
|
||||||
long length;
|
long length;
|
||||||
|
|
||||||
DfsObjectToPack(AnyObjectId src, final int type) {
|
DfsObjectToPack(AnyObjectId src, int type) {
|
||||||
super(src, type);
|
super(src, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
final class ByteArrayWindow extends ByteWindow {
|
final class ByteArrayWindow extends ByteWindow {
|
||||||
private final byte[] array;
|
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);
|
super(pack, o, b.length);
|
||||||
array = b;
|
array = b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
final class ByteBufferWindow extends ByteWindow {
|
final class ByteBufferWindow extends ByteWindow {
|
||||||
private final ByteBuffer buffer;
|
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());
|
super(pack, o, b.capacity());
|
||||||
buffer = b;
|
buffer = b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ final int size() {
|
||||||
return (int) (end - start);
|
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;
|
return pack == neededFile && start <= neededPos && neededPos < end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ private boolean has(AnyObjectId objectId, Set<AlternateHandle.Id> skips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
ObjectLoader openObject(final WindowCursor curs, final AnyObjectId objectId)
|
ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return openObject(curs, objectId, null);
|
return openObject(curs, objectId, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ static void reconfigure(WindowCacheConfig cfg) {
|
||||||
cache = new Slot[CACHE_SZ];
|
cache = new Slot[CACHE_SZ];
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry get(final PackFile pack, final long position) {
|
Entry get(PackFile pack, long position) {
|
||||||
Slot e = cache[hash(position)];
|
Slot e = cache[hash(position)];
|
||||||
if (e == null)
|
if (e == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -168,7 +168,7 @@ static class Entry {
|
||||||
|
|
||||||
final int type;
|
final int type;
|
||||||
|
|
||||||
Entry(final byte[] aData, final int aType) {
|
Entry(byte[] aData, int aType) {
|
||||||
data = aData;
|
data = aData;
|
||||||
type = aType;
|
type = aType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -852,7 +852,7 @@ public Collection<PackFile> repack() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ObjectIdSet> excluded = new LinkedList<>();
|
List<ObjectIdSet> excluded = new LinkedList<>();
|
||||||
for (final PackFile f : repo.getObjectDatabase().getPacks()) {
|
for (PackFile f : repo.getObjectDatabase().getPacks()) {
|
||||||
checkCancelled();
|
checkCancelled();
|
||||||
if (f.shouldBeKept())
|
if (f.shouldBeKept())
|
||||||
excluded.add(f.getIndex());
|
excluded.add(f.getIndex());
|
||||||
|
|
|
@ -58,7 +58,7 @@ class LocalObjectToPack extends ObjectToPack {
|
||||||
/** Length of the data section of the object. */
|
/** Length of the data section of the object. */
|
||||||
long length;
|
long length;
|
||||||
|
|
||||||
LocalObjectToPack(AnyObjectId src, final int type) {
|
LocalObjectToPack(AnyObjectId src, int type) {
|
||||||
super(src, type);
|
super(src, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ public void close() {
|
||||||
// Fully close all loaded alternates and clear the alternate list.
|
// Fully close all loaded alternates and clear the alternate list.
|
||||||
AlternateHandle[] alt = alternates.get();
|
AlternateHandle[] alt = alternates.get();
|
||||||
if (alt != null && alternates.compareAndSet(alt, null)) {
|
if (alt != null && alternates.compareAndSet(alt, null)) {
|
||||||
for(final AlternateHandle od : alt)
|
for(AlternateHandle od : alt)
|
||||||
od.close();
|
od.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -619,7 +619,7 @@ private void selectObjectRepresentation(PackWriter packer, ObjectToPack otp,
|
||||||
WindowCursor curs, Set<AlternateHandle.Id> skips) throws IOException {
|
WindowCursor curs, Set<AlternateHandle.Id> skips) throws IOException {
|
||||||
PackList pList = packList.get();
|
PackList pList = packList.get();
|
||||||
SEARCH: for (;;) {
|
SEARCH: for (;;) {
|
||||||
for (final PackFile p : pList.packs) {
|
for (PackFile p : pList.packs) {
|
||||||
try {
|
try {
|
||||||
LocalObjectRepresentation rep = p.representation(curs, otp);
|
LocalObjectRepresentation rep = p.representation(curs, otp);
|
||||||
p.resetTransientErrorCount();
|
p.resetTransientErrorCount();
|
||||||
|
@ -888,7 +888,7 @@ private PackList scanPacksImpl(PackList old) {
|
||||||
final Set<String> names = listPackDirectory();
|
final Set<String> names = listPackDirectory();
|
||||||
final List<PackFile> list = new ArrayList<>(names.size() >> 2);
|
final List<PackFile> list = new ArrayList<>(names.size() >> 2);
|
||||||
boolean foundNew = false;
|
boolean foundNew = false;
|
||||||
for (final String indexName : names) {
|
for (String indexName : names) {
|
||||||
// Must match "pack-[0-9a-f]{40}.idx" to be an index.
|
// Must match "pack-[0-9a-f]{40}.idx" to be an index.
|
||||||
//
|
//
|
||||||
if (indexName.length() != 49 || !indexName.endsWith(".idx")) //$NON-NLS-1$
|
if (indexName.length() != 49 || !indexName.endsWith(".idx")) //$NON-NLS-1$
|
||||||
|
@ -931,7 +931,7 @@ private PackList scanPacksImpl(PackList old) {
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final PackFile p : forReuse.values()) {
|
for (PackFile p : forReuse.values()) {
|
||||||
p.close();
|
p.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,7 +945,7 @@ private PackList scanPacksImpl(PackList old) {
|
||||||
|
|
||||||
private static Map<String, PackFile> reuseMap(PackList old) {
|
private static Map<String, PackFile> reuseMap(PackList old) {
|
||||||
final Map<String, PackFile> forReuse = new HashMap<>();
|
final Map<String, PackFile> forReuse = new HashMap<>();
|
||||||
for (final PackFile p : old.packs) {
|
for (PackFile p : old.packs) {
|
||||||
if (p.invalid()) {
|
if (p.invalid()) {
|
||||||
// The pack instance is corrupted, and cannot be safely used
|
// The pack instance is corrupted, and cannot be safely used
|
||||||
// again. Do not include it in our reuse map.
|
// again. Do not include it in our reuse map.
|
||||||
|
@ -974,7 +974,7 @@ private Set<String> listPackDirectory() {
|
||||||
if (nameList == null)
|
if (nameList == null)
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
final Set<String> nameSet = new HashSet<>(nameList.length << 1);
|
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$
|
if (name.startsWith("pack-")) //$NON-NLS-1$
|
||||||
nameSet.add(name);
|
nameSet.add(name);
|
||||||
}
|
}
|
||||||
|
@ -1076,7 +1076,7 @@ private static final class PackList {
|
||||||
/** All known packs, sorted by {@link PackFile#SORT}. */
|
/** All known packs, sorted by {@link PackFile#SORT}. */
|
||||||
final PackFile[] packs;
|
final PackFile[] packs;
|
||||||
|
|
||||||
PackList(final FileSnapshot monitor, final PackFile[] packs) {
|
PackList(FileSnapshot monitor, PackFile[] packs) {
|
||||||
this.snapshot = monitor;
|
this.snapshot = monitor;
|
||||||
this.packs = packs;
|
this.packs = packs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ class ObjectDirectoryInserter extends ObjectInserter {
|
||||||
|
|
||||||
private Deflater deflate;
|
private Deflater deflate;
|
||||||
|
|
||||||
ObjectDirectoryInserter(final FileObjectDatabase dest, final Config cfg) {
|
ObjectDirectoryInserter(FileObjectDatabase dest, Config cfg) {
|
||||||
db = dest;
|
db = dest;
|
||||||
config = cfg.get(WriteConfig.KEY);
|
config = cfg.get(WriteConfig.KEY);
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ private File toTemp(final int type, final byte[] buf, final int pos,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeHeader(OutputStream out, final int type, long len)
|
void writeHeader(OutputStream out, int type, long len)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
out.write(Constants.encodedTypeString(type));
|
out.write(Constants.encodedTypeString(type));
|
||||||
out.write((byte) ' ');
|
out.write((byte) ' ');
|
||||||
|
@ -279,7 +279,7 @@ File newTempFile() throws IOException {
|
||||||
return File.createTempFile("noz", null, db.getDirectory()); //$NON-NLS-1$
|
return File.createTempFile("noz", null, db.getDirectory()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
DeflaterOutputStream compress(final OutputStream out) {
|
DeflaterOutputStream compress(OutputStream out) {
|
||||||
if (deflate == null)
|
if (deflate == null)
|
||||||
deflate = new Deflater(config.getCompression());
|
deflate = new Deflater(config.getCompression());
|
||||||
else
|
else
|
||||||
|
|
|
@ -279,7 +279,7 @@ public boolean shouldBeKept() {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the pack file or the index could not be read.
|
* 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 {
|
throws IOException {
|
||||||
final long offset = idx().findOffset(id);
|
final long offset = idx().findOffset(id);
|
||||||
return 0 < offset && !isCorrupt(offset) ? load(curs, offset) : null;
|
return 0 < offset && !isCorrupt(offset) ? load(curs, offset) : null;
|
||||||
|
@ -344,7 +344,7 @@ long getObjectCount() throws IOException {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the index file cannot be loaded into memory.
|
* 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);
|
return getReverseIdx().findObject(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +692,7 @@ private void doClose() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteArrayWindow read(final long pos, int size) throws IOException {
|
ByteArrayWindow read(long pos, int size) throws IOException {
|
||||||
synchronized (readLock) {
|
synchronized (readLock) {
|
||||||
if (length < pos + size)
|
if (length < pos + size)
|
||||||
size = (int) (length - pos);
|
size = (int) (length - pos);
|
||||||
|
@ -703,7 +703,7 @@ ByteArrayWindow read(final long pos, int size) throws IOException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteWindow mmap(final long pos, int size) throws IOException {
|
ByteWindow mmap(long pos, int size) throws IOException {
|
||||||
synchronized (readLock) {
|
synchronized (readLock) {
|
||||||
if (length < pos + size)
|
if (length < pos + size)
|
||||||
size = (int) (length - pos);
|
size = (int) (length - pos);
|
||||||
|
@ -760,7 +760,7 @@ private void onOpenPack() throws IOException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectLoader load(final WindowCursor curs, long pos)
|
ObjectLoader load(WindowCursor curs, long pos)
|
||||||
throws IOException, LargeObjectException {
|
throws IOException, LargeObjectException {
|
||||||
try {
|
try {
|
||||||
final byte[] ib = curs.tempId;
|
final byte[] ib = curs.tempId;
|
||||||
|
@ -949,7 +949,7 @@ byte[] getDeltaHeader(WindowCursor wc, long pos)
|
||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getObjectType(final WindowCursor curs, long pos) throws IOException {
|
int getObjectType(WindowCursor curs, long pos) throws IOException {
|
||||||
final byte[] ib = curs.tempId;
|
final byte[] ib = curs.tempId;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
readFully(pos, ib, 0, 20, curs);
|
readFully(pos, ib, 0, 20, curs);
|
||||||
|
@ -996,13 +996,13 @@ int getObjectType(final WindowCursor curs, long pos) throws IOException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long getObjectSize(final WindowCursor curs, final AnyObjectId id)
|
long getObjectSize(WindowCursor curs, AnyObjectId id)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final long offset = idx().findOffset(id);
|
final long offset = idx().findOffset(id);
|
||||||
return 0 < offset ? getObjectSize(curs, offset) : -1;
|
return 0 < offset ? getObjectSize(curs, offset) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
long getObjectSize(final WindowCursor curs, final long pos)
|
long getObjectSize(WindowCursor curs, long pos)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final byte[] ib = curs.tempId;
|
final byte[] ib = curs.tempId;
|
||||||
readFully(pos, ib, 0, 20, curs);
|
readFully(pos, ib, 0, 20, curs);
|
||||||
|
|
|
@ -113,7 +113,7 @@ public long getObjectCount() {
|
||||||
@Override
|
@Override
|
||||||
public long getOffset64Count() {
|
public long getOffset64Count() {
|
||||||
long n64 = 0;
|
long n64 = 0;
|
||||||
for (final MutableEntry e : this) {
|
for (MutableEntry e : this) {
|
||||||
if (e.getOffset() >= Integer.MAX_VALUE)
|
if (e.getOffset() >= Integer.MAX_VALUE)
|
||||||
n64++;
|
n64++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ public static PackIndexWriter createOldestPossible(final OutputStream dst,
|
||||||
*/
|
*/
|
||||||
public static int oldestPossibleFormat(
|
public static int oldestPossibleFormat(
|
||||||
final List<? extends PackedObjectInfo> objs) {
|
final List<? extends PackedObjectInfo> objs) {
|
||||||
for (final PackedObjectInfo oe : objs) {
|
for (PackedObjectInfo oe : objs) {
|
||||||
if (!PackIndexWriterV1.canStore(oe))
|
if (!PackIndexWriterV1.canStore(oe))
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -269,11 +269,11 @@ protected void writeTOC(int version) throws IOException {
|
||||||
*/
|
*/
|
||||||
protected void writeFanOutTable() throws IOException {
|
protected void writeFanOutTable() throws IOException {
|
||||||
final int[] fanout = new int[256];
|
final int[] fanout = new int[256];
|
||||||
for (final PackedObjectInfo po : entries)
|
for (PackedObjectInfo po : entries)
|
||||||
fanout[po.getFirstByte() & 0xff]++;
|
fanout[po.getFirstByte() & 0xff]++;
|
||||||
for (int i = 1; i < 256; i++)
|
for (int i = 1; i < 256; i++)
|
||||||
fanout[i] += fanout[i - 1];
|
fanout[i] += fanout[i - 1];
|
||||||
for (final int n : fanout) {
|
for (int n : fanout) {
|
||||||
NB.encodeInt32(tmp, 0, n);
|
NB.encodeInt32(tmp, 0, n);
|
||||||
out.write(tmp, 0, 4);
|
out.write(tmp, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
* @see PackIndexV1
|
* @see PackIndexV1
|
||||||
*/
|
*/
|
||||||
class PackIndexWriterV1 extends PackIndexWriter {
|
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.
|
// We are limited to 4 GB per pack as offset is 32 bit unsigned int.
|
||||||
//
|
//
|
||||||
return oe.getOffset() >>> 1 < Integer.MAX_VALUE;
|
return oe.getOffset() >>> 1 < Integer.MAX_VALUE;
|
||||||
|
@ -73,7 +73,7 @@ static boolean canStore(final PackedObjectInfo oe) {
|
||||||
protected void writeImpl() throws IOException {
|
protected void writeImpl() throws IOException {
|
||||||
writeFanOutTable();
|
writeFanOutTable();
|
||||||
|
|
||||||
for (final PackedObjectInfo oe : entries) {
|
for (PackedObjectInfo oe : entries) {
|
||||||
if (!canStore(oe))
|
if (!canStore(oe))
|
||||||
throw new IOException(JGitText.get().packTooLargeForIndexVersion1);
|
throw new IOException(JGitText.get().packTooLargeForIndexVersion1);
|
||||||
NB.encodeInt32(tmp, 0, (int) oe.getOffset());
|
NB.encodeInt32(tmp, 0, (int) oe.getOffset());
|
||||||
|
|
|
@ -76,12 +76,12 @@ protected void writeImpl() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeObjectNames() throws IOException {
|
private void writeObjectNames() throws IOException {
|
||||||
for (final PackedObjectInfo oe : entries)
|
for (PackedObjectInfo oe : entries)
|
||||||
oe.copyRawTo(out);
|
oe.copyRawTo(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeCRCs() throws IOException {
|
private void writeCRCs() throws IOException {
|
||||||
for (final PackedObjectInfo oe : entries) {
|
for (PackedObjectInfo oe : entries) {
|
||||||
NB.encodeInt32(tmp, 0, oe.getCRC());
|
NB.encodeInt32(tmp, 0, oe.getCRC());
|
||||||
out.write(tmp, 0, 4);
|
out.write(tmp, 0, 4);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ private void writeCRCs() throws IOException {
|
||||||
|
|
||||||
private void writeOffset32() throws IOException {
|
private void writeOffset32() throws IOException {
|
||||||
int o64 = 0;
|
int o64 = 0;
|
||||||
for (final PackedObjectInfo oe : entries) {
|
for (PackedObjectInfo oe : entries) {
|
||||||
final long o = oe.getOffset();
|
final long o = oe.getOffset();
|
||||||
if (o <= MAX_OFFSET_32)
|
if (o <= MAX_OFFSET_32)
|
||||||
NB.encodeInt32(tmp, 0, (int) o);
|
NB.encodeInt32(tmp, 0, (int) o);
|
||||||
|
@ -100,7 +100,7 @@ private void writeOffset32() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeOffset64() throws IOException {
|
private void writeOffset64() throws IOException {
|
||||||
for (final PackedObjectInfo oe : entries) {
|
for (PackedObjectInfo oe : entries) {
|
||||||
final long o = oe.getOffset();
|
final long o = oe.getOffset();
|
||||||
if (MAX_OFFSET_32 < o) {
|
if (MAX_OFFSET_32 < o) {
|
||||||
NB.encodeInt64(tmp, 0, o);
|
NB.encodeInt64(tmp, 0, o);
|
||||||
|
|
|
@ -107,7 +107,7 @@ public PackReverseIndex(PackIndex packIndex) {
|
||||||
|
|
||||||
long maxOffset = 0;
|
long maxOffset = 0;
|
||||||
int ith = 0;
|
int ith = 0;
|
||||||
for (final MutableEntry me : index) {
|
for (MutableEntry me : index) {
|
||||||
final long o = me.getOffset();
|
final long o = me.getOffset();
|
||||||
offsetsBySha1[ith++] = o;
|
offsetsBySha1[ith++] = o;
|
||||||
if (o > maxOffset)
|
if (o > maxOffset)
|
||||||
|
|
|
@ -208,7 +208,7 @@ public class RefDirectory extends RefDatabase {
|
||||||
|
|
||||||
private List<Integer> retrySleepMs = RETRY_SLEEP_MS;
|
private List<Integer> retrySleepMs = RETRY_SLEEP_MS;
|
||||||
|
|
||||||
RefDirectory(final FileRepository db) {
|
RefDirectory(FileRepository db) {
|
||||||
final FS fs = db.getFS();
|
final FS fs = db.getFS();
|
||||||
parent = db;
|
parent = db;
|
||||||
gitDir = db.getDirectory();
|
gitDir = db.getDirectory();
|
||||||
|
@ -434,7 +434,7 @@ private class LooseScanner {
|
||||||
|
|
||||||
RefList.Builder<LooseRef> newLoose;
|
RefList.Builder<LooseRef> newLoose;
|
||||||
|
|
||||||
LooseScanner(final RefList<LooseRef> curLoose) {
|
LooseScanner(RefList<LooseRef> curLoose) {
|
||||||
this.curLoose = curLoose;
|
this.curLoose = curLoose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,14 +1262,14 @@ File fileFor(String name) {
|
||||||
return new File(gitDir, name);
|
return new File(gitDir, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int levelsIn(final String name) {
|
static int levelsIn(String name) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int p = name.indexOf('/'); p >= 0; p = name.indexOf('/', p + 1))
|
for (int p = name.indexOf('/'); p >= 0; p = name.indexOf('/', p + 1))
|
||||||
count++;
|
count++;
|
||||||
return 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);
|
delete(file, depth, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ protected Result doRename() throws IOException {
|
||||||
objId = source.getOldObjectId();
|
objId = source.getOldObjectId();
|
||||||
updateHEAD = needToUpdateHEAD();
|
updateHEAD = needToUpdateHEAD();
|
||||||
tmp = refdb.newTemporaryUpdate();
|
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.
|
// First backup the source so its never unreachable.
|
||||||
tmp.setNewObjectId(objId);
|
tmp.setNewObjectId(objId);
|
||||||
tmp.setForceUpdate(true);
|
tmp.setForceUpdate(true);
|
||||||
|
|
|
@ -60,7 +60,7 @@ class RefDirectoryUpdate extends RefUpdate {
|
||||||
private boolean shouldDeref;
|
private boolean shouldDeref;
|
||||||
private LockFile lock;
|
private LockFile lock;
|
||||||
|
|
||||||
RefDirectoryUpdate(final RefDirectory r, final Ref ref) {
|
RefDirectoryUpdate(RefDirectory r, Ref ref) {
|
||||||
super(ref);
|
super(ref);
|
||||||
database = r;
|
database = r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ static void checkValidEndOfStream(InputStream in, Inflater inf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isStandardFormat(final byte[] hdr) {
|
static boolean isStandardFormat(byte[] hdr) {
|
||||||
/*
|
/*
|
||||||
* We must determine if the buffer contains the standard
|
* We must determine if the buffer contains the standard
|
||||||
* zlib-deflated stream or the experimental format based
|
* zlib-deflated stream or the experimental format based
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue