Use Constants.OBJECT_ID_STRING_LENGTH instead of LEN * 2
A few locations were doing OBJECT_ID_LENGTH * 2 on their own, as the old STR_LEN constant wasn't visible. Replace them with the new public constant OBJECT_ID_STRING_LENGTH. Change-Id: Id39bddb52de8c65bb097de042e9d4ed99598201f Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
db9f8126db
commit
1ec393e744
|
@ -210,7 +210,7 @@ public void write(final ObjectId id) throws IOException {
|
||||||
requireLock();
|
requireLock();
|
||||||
try {
|
try {
|
||||||
final BufferedOutputStream b;
|
final BufferedOutputStream b;
|
||||||
b = new BufferedOutputStream(os, Constants.OBJECT_ID_LENGTH * 2 + 1);
|
b = new BufferedOutputStream(os, Constants.OBJECT_ID_STRING_LENGTH + 1);
|
||||||
id.copyTo(b);
|
id.copyTo(b);
|
||||||
b.write('\n');
|
b.write('\n');
|
||||||
b.flush();
|
b.flush();
|
||||||
|
|
|
@ -83,7 +83,7 @@ public RefWriter(Collection<Ref> refs) {
|
||||||
*/
|
*/
|
||||||
public void writeInfoRefs() throws IOException {
|
public void writeInfoRefs() throws IOException {
|
||||||
final StringWriter w = new StringWriter();
|
final StringWriter w = new StringWriter();
|
||||||
final char[] tmp = new char[Constants.OBJECT_ID_LENGTH * 2];
|
final char[] tmp = new char[Constants.OBJECT_ID_STRING_LENGTH];
|
||||||
for (final Ref r : refs) {
|
for (final Ref r : refs) {
|
||||||
if (Constants.HEAD.equals(r.getName())) {
|
if (Constants.HEAD.equals(r.getName())) {
|
||||||
// Historically HEAD has never been published through
|
// Historically HEAD has never been published through
|
||||||
|
@ -137,7 +137,7 @@ public void writePackedRefs() throws IOException {
|
||||||
w.write('\n');
|
w.write('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
final char[] tmp = new char[Constants.OBJECT_ID_LENGTH * 2];
|
final char[] tmp = new char[Constants.OBJECT_ID_STRING_LENGTH];
|
||||||
for (final Ref r : refs) {
|
for (final Ref r : refs) {
|
||||||
if (r.getStorage() != Ref.Storage.PACKED)
|
if (r.getStorage() != Ref.Storage.PACKED)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -72,12 +72,12 @@ static public class Entry {
|
||||||
|
|
||||||
Entry(byte[] raw, int pos) {
|
Entry(byte[] raw, int pos) {
|
||||||
oldId = ObjectId.fromString(raw, pos);
|
oldId = ObjectId.fromString(raw, pos);
|
||||||
pos += Constants.OBJECT_ID_LENGTH * 2;
|
pos += Constants.OBJECT_ID_STRING_LENGTH;
|
||||||
if (raw[pos++] != ' ')
|
if (raw[pos++] != ' ')
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Raw log message does not parse as log entry");
|
"Raw log message does not parse as log entry");
|
||||||
newId = ObjectId.fromString(raw, pos);
|
newId = ObjectId.fromString(raw, pos);
|
||||||
pos += Constants.OBJECT_ID_LENGTH * 2;
|
pos += Constants.OBJECT_ID_STRING_LENGTH;
|
||||||
if (raw[pos++] != ' ') {
|
if (raw[pos++] != ' ') {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Raw log message does not parse as log entry");
|
"Raw log message does not parse as log entry");
|
||||||
|
|
|
@ -179,7 +179,7 @@ public void writeBundle(OutputStream os) throws IOException {
|
||||||
w.write(TransportBundle.V2_BUNDLE_SIGNATURE);
|
w.write(TransportBundle.V2_BUNDLE_SIGNATURE);
|
||||||
w.write('\n');
|
w.write('\n');
|
||||||
|
|
||||||
final char[] tmp = new char[Constants.OBJECT_ID_LENGTH * 2];
|
final char[] tmp = new char[Constants.OBJECT_ID_STRING_LENGTH];
|
||||||
for (final RevCommit a : assume) {
|
for (final RevCommit a : assume) {
|
||||||
w.write('-');
|
w.write('-');
|
||||||
a.copyTo(tmp, w);
|
a.copyTo(tmp, w);
|
||||||
|
|
|
@ -882,7 +882,7 @@ private void sendStatusReport(final boolean forClient, final Reporter out)
|
||||||
case REJECTED_MISSING_OBJECT:
|
case REJECTED_MISSING_OBJECT:
|
||||||
if (cmd.getMessage() == null)
|
if (cmd.getMessage() == null)
|
||||||
r.append("missing object(s)");
|
r.append("missing object(s)");
|
||||||
else if (cmd.getMessage().length() == 2 * Constants.OBJECT_ID_LENGTH)
|
else if (cmd.getMessage().length() == Constants.OBJECT_ID_STRING_LENGTH)
|
||||||
r.append("object " + cmd.getMessage() + " missing");
|
r.append("object " + cmd.getMessage() + " missing");
|
||||||
else
|
else
|
||||||
r.append(cmd.getMessage());
|
r.append(cmd.getMessage());
|
||||||
|
|
|
@ -70,7 +70,7 @@ class RefAdvertiser {
|
||||||
|
|
||||||
private final StringBuilder tmpLine = new StringBuilder(100);
|
private final StringBuilder tmpLine = new StringBuilder(100);
|
||||||
|
|
||||||
private final char[] tmpId = new char[2 * Constants.OBJECT_ID_LENGTH];
|
private final char[] tmpId = new char[Constants.OBJECT_ID_STRING_LENGTH];
|
||||||
|
|
||||||
private final Set<String> capablities = new LinkedHashSet<String>();
|
private final Set<String> capablities = new LinkedHashSet<String>();
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ void deleteRefLog(final String name) throws IOException {
|
||||||
void writeRef(final String name, final ObjectId value) throws IOException {
|
void writeRef(final String name, final ObjectId value) throws IOException {
|
||||||
final ByteArrayOutputStream b;
|
final ByteArrayOutputStream b;
|
||||||
|
|
||||||
b = new ByteArrayOutputStream(Constants.OBJECT_ID_LENGTH * 2 + 1);
|
b = new ByteArrayOutputStream(Constants.OBJECT_ID_STRING_LENGTH + 1);
|
||||||
value.copyTo(b);
|
value.copyTo(b);
|
||||||
b.write('\n');
|
b.write('\n');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue