Merge changes I184945ee,Iacaad1a7
* changes: Remove unnecessary $NON-NLS comment in BaseReceivePack Use try-with-resources to close resources in BaseReceivePack
This commit is contained in:
commit
5ef9c1709e
|
@ -317,7 +317,7 @@ public ReceiveConfig parse(final Config cfg) {
|
||||||
"denynonfastforwards", false); //$NON-NLS-1$
|
"denynonfastforwards", false); //$NON-NLS-1$
|
||||||
allowOfsDelta = config.getBoolean("repack", "usedeltabaseoffset", //$NON-NLS-1$ //$NON-NLS-2$
|
allowOfsDelta = config.getBoolean("repack", "usedeltabaseoffset", //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
true);
|
true);
|
||||||
certNonceSeed = config.getString("receive", null, "certnonceseed"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
certNonceSeed = config.getString("receive", null, "certnonceseed"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
certNonceSlopLimit = config.getInt("receive", "certnonceslop", 0); //$NON-NLS-1$ //$NON-NLS-2$
|
certNonceSlopLimit = config.getInt("receive", "certnonceslop", 0); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1070,8 +1070,7 @@ private void receivePack() throws IOException {
|
||||||
if (sideBand)
|
if (sideBand)
|
||||||
resolving = new SideBandProgressMonitor(msgOut);
|
resolving = new SideBandProgressMonitor(msgOut);
|
||||||
|
|
||||||
ObjectInserter ins = db.newObjectInserter();
|
try (ObjectInserter ins = db.newObjectInserter()) {
|
||||||
try {
|
|
||||||
String lockMsg = "jgit receive-pack"; //$NON-NLS-1$
|
String lockMsg = "jgit receive-pack"; //$NON-NLS-1$
|
||||||
if (getRefLogIdent() != null)
|
if (getRefLogIdent() != null)
|
||||||
lockMsg += " from " + getRefLogIdent().toExternalString(); //$NON-NLS-1$
|
lockMsg += " from " + getRefLogIdent().toExternalString(); //$NON-NLS-1$
|
||||||
|
@ -1089,8 +1088,6 @@ private void receivePack() throws IOException {
|
||||||
packLock = parser.parse(receiving, resolving);
|
packLock = parser.parse(receiving, resolving);
|
||||||
packSize = Long.valueOf(parser.getPackSize());
|
packSize = Long.valueOf(parser.getPackSize());
|
||||||
ins.flush();
|
ins.flush();
|
||||||
} finally {
|
|
||||||
ins.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeoutIn != null)
|
if (timeoutIn != null)
|
||||||
|
@ -1119,67 +1116,69 @@ private void checkConnectivity() throws IOException {
|
||||||
}
|
}
|
||||||
parser = null;
|
parser = null;
|
||||||
|
|
||||||
final ObjectWalk ow = new ObjectWalk(db);
|
try (final ObjectWalk ow = new ObjectWalk(db)) {
|
||||||
ow.setRetainBody(false);
|
ow.setRetainBody(false);
|
||||||
if (baseObjects != null) {
|
if (baseObjects != null) {
|
||||||
ow.sort(RevSort.TOPO);
|
ow.sort(RevSort.TOPO);
|
||||||
if (!baseObjects.isEmpty())
|
if (!baseObjects.isEmpty())
|
||||||
ow.sort(RevSort.BOUNDARY, true);
|
ow.sort(RevSort.BOUNDARY, true);
|
||||||
}
|
|
||||||
|
|
||||||
for (final ReceiveCommand cmd : commands) {
|
|
||||||
if (cmd.getResult() != Result.NOT_ATTEMPTED)
|
|
||||||
continue;
|
|
||||||
if (cmd.getType() == ReceiveCommand.Type.DELETE)
|
|
||||||
continue;
|
|
||||||
ow.markStart(ow.parseAny(cmd.getNewId()));
|
|
||||||
}
|
|
||||||
for (final ObjectId have : advertisedHaves) {
|
|
||||||
RevObject o = ow.parseAny(have);
|
|
||||||
ow.markUninteresting(o);
|
|
||||||
|
|
||||||
if (baseObjects != null && !baseObjects.isEmpty()) {
|
|
||||||
o = ow.peel(o);
|
|
||||||
if (o instanceof RevCommit)
|
|
||||||
o = ((RevCommit) o).getTree();
|
|
||||||
if (o instanceof RevTree)
|
|
||||||
ow.markUninteresting(o);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
checking.beginTask(JGitText.get().countingObjects, ProgressMonitor.UNKNOWN);
|
for (final ReceiveCommand cmd : commands) {
|
||||||
RevCommit c;
|
if (cmd.getResult() != Result.NOT_ATTEMPTED)
|
||||||
while ((c = ow.next()) != null) {
|
|
||||||
checking.update(1);
|
|
||||||
if (providedObjects != null //
|
|
||||||
&& !c.has(RevFlag.UNINTERESTING) //
|
|
||||||
&& !providedObjects.contains(c))
|
|
||||||
throw new MissingObjectException(c, Constants.TYPE_COMMIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
RevObject o;
|
|
||||||
while ((o = ow.nextObject()) != null) {
|
|
||||||
checking.update(1);
|
|
||||||
if (o.has(RevFlag.UNINTERESTING))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (providedObjects != null) {
|
|
||||||
if (providedObjects.contains(o))
|
|
||||||
continue;
|
continue;
|
||||||
else
|
if (cmd.getType() == ReceiveCommand.Type.DELETE)
|
||||||
throw new MissingObjectException(o, o.getType());
|
continue;
|
||||||
|
ow.markStart(ow.parseAny(cmd.getNewId()));
|
||||||
|
}
|
||||||
|
for (final ObjectId have : advertisedHaves) {
|
||||||
|
RevObject o = ow.parseAny(have);
|
||||||
|
ow.markUninteresting(o);
|
||||||
|
|
||||||
|
if (baseObjects != null && !baseObjects.isEmpty()) {
|
||||||
|
o = ow.peel(o);
|
||||||
|
if (o instanceof RevCommit)
|
||||||
|
o = ((RevCommit) o).getTree();
|
||||||
|
if (o instanceof RevTree)
|
||||||
|
ow.markUninteresting(o);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o instanceof RevBlob && !db.hasObject(o))
|
checking.beginTask(JGitText.get().countingObjects,
|
||||||
throw new MissingObjectException(o, Constants.TYPE_BLOB);
|
ProgressMonitor.UNKNOWN);
|
||||||
}
|
RevCommit c;
|
||||||
checking.endTask();
|
while ((c = ow.next()) != null) {
|
||||||
|
checking.update(1);
|
||||||
|
if (providedObjects != null //
|
||||||
|
&& !c.has(RevFlag.UNINTERESTING) //
|
||||||
|
&& !providedObjects.contains(c))
|
||||||
|
throw new MissingObjectException(c, Constants.TYPE_COMMIT);
|
||||||
|
}
|
||||||
|
|
||||||
if (baseObjects != null) {
|
RevObject o;
|
||||||
for (ObjectId id : baseObjects) {
|
while ((o = ow.nextObject()) != null) {
|
||||||
o = ow.parseAny(id);
|
checking.update(1);
|
||||||
if (!o.has(RevFlag.UNINTERESTING))
|
if (o.has(RevFlag.UNINTERESTING))
|
||||||
throw new MissingObjectException(o, o.getType());
|
continue;
|
||||||
|
|
||||||
|
if (providedObjects != null) {
|
||||||
|
if (providedObjects.contains(o))
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
throw new MissingObjectException(o, o.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o instanceof RevBlob && !db.hasObject(o))
|
||||||
|
throw new MissingObjectException(o, Constants.TYPE_BLOB);
|
||||||
|
}
|
||||||
|
checking.endTask();
|
||||||
|
|
||||||
|
if (baseObjects != null) {
|
||||||
|
for (ObjectId id : baseObjects) {
|
||||||
|
o = ow.parseAny(id);
|
||||||
|
if (!o.has(RevFlag.UNINTERESTING))
|
||||||
|
throw new MissingObjectException(o, o.getType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1502,7 +1501,7 @@ protected void close() throws IOException {
|
||||||
* the pack could not be unlocked.
|
* the pack could not be unlocked.
|
||||||
*/
|
*/
|
||||||
protected void release() throws IOException {
|
protected void release() throws IOException {
|
||||||
walk.release();
|
walk.close();
|
||||||
unlockPack();
|
unlockPack();
|
||||||
timeoutIn = null;
|
timeoutIn = null;
|
||||||
rawIn = null;
|
rawIn = null;
|
||||||
|
|
Loading…
Reference in New Issue