@Override
protected PasswordAuthentication promptPasswordAuthentication() {
final String realm = formatRealm();
- String username = cons.readLine(MessageFormat.format(ConsoleText.get().usernameFor + " ", realm));
+ String username = cons.readLine(MessageFormat.format(ConsoleText.get().usernameFor + " ", realm)); //$NON-NLS-1$
if (username == null || username.isEmpty()) {
return null;
}
- char[] password = cons.readPassword(ConsoleText.get().password + " ");
+ char[] password = cons.readPassword(ConsoleText.get().password + " "); //$NON-NLS-1$
if (password == null) {
password = new char[0];
}
final StringBuilder realm = new StringBuilder();
if (getRequestorType() == RequestorType.PROXY) {
realm.append(getRequestorType());
- realm.append(" ");
+ realm.append(" "); //$NON-NLS-1$
realm.append(getRequestingHost());
if (getRequestingPort() > 0) {
- realm.append(":");
+ realm.append(":"); //$NON-NLS-1$
realm.append(getRequestingPort());
}
} else {
private boolean get(CredentialItem.StringType item) {
if (item.isValueSecure()) {
- char[] v = cons.readPassword("%s: ", item.getPromptText());
+ char[] v = cons.readPassword("%s: ", item.getPromptText()); //$NON-NLS-1$
if (v != null) {
item.setValue(new String(v));
return true;
return false;
}
} else {
- String v = cons.readLine("%s: ", item.getPromptText());
+ String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
if (v != null) {
item.setValue(v);
return true;
private boolean get(CredentialItem.CharArrayType item) {
if (item.isValueSecure()) {
- char[] v = cons.readPassword("%s: ", item.getPromptText());
+ char[] v = cons.readPassword("%s: ", item.getPromptText()); //$NON-NLS-1$
if (v != null) {
item.setValueNoCopy(v);
return true;
return false;
}
} else {
- String v = cons.readLine("%s: ", item.getPromptText());
+ String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
if (v != null) {
item.setValueNoCopy(v.toCharArray());
return true;
}
private boolean get(CredentialItem.InformationalMessage item) {
- cons.printf("%s\n", item.getPromptText());
+ cons.printf("%s\n", item.getPromptText()); //$NON-NLS-1$
cons.flush();
return true;
}
private boolean get(CredentialItem.YesNoType item) {
- String r = cons.readLine("%s [%s/%s]? ", item.getPromptText(),
+ String r = cons.readLine("%s [%s/%s]? ", item.getPromptText(), //$NON-NLS-1$
ConsoleText.get().answerYes, ConsoleText.get().answerNo);
if (r != null) {
item.setValue(ConsoleText.get().answerYes.equalsIgnoreCase(r));
shownURI = true;
}
- outw.format(" %c %-17s %-10s -> %s", valueOf(type), longType,
+ outw.format(" %c %-17s %-10s -> %s", valueOf(type), longType, //$NON-NLS-1$
src, dst);
outw.println();
}
if (r == RefUpdate.Result.FORCED) {
final String aOld = safeAbbreviate(reader, u.getOldObjectId());
final String aNew = safeAbbreviate(reader, u.getNewObjectId());
- return aOld + "..." + aNew;
+ return aOld + "..." + aNew; //$NON-NLS-1$
}
if (r == RefUpdate.Result.FAST_FORWARD) {
final String aOld = safeAbbreviate(reader, u.getOldObjectId());
final String aNew = safeAbbreviate(reader, u.getNewObjectId());
- return aOld + ".." + aNew;
+ return aOld + ".." + aNew; //$NON-NLS-1$
}
if (r == RefUpdate.Result.NO_CHANGE)
return "[up to date]";
- return "[" + r.name() + "]";
+ return "[" + r.name() + "]"; //$NON-NLS-1$//$NON-NLS-2$
}
private String safeAbbreviate(ObjectReader reader, ObjectId id) {
protected void run() throws Exception {
final AmazonS3 s3 = new AmazonS3(properties());
- if ("get".equals(op)) {
+ if ("get".equals(op)) { //$NON-NLS-1$
final URLConnection c = s3.get(bucket, key);
int len = c.getContentLength();
final InputStream in = c.getInputStream();
in.close();
}
- } else if ("ls".equals(op) || "list".equals(op)) {
+ } else if ("ls".equals(op) || "list".equals(op)) { //$NON-NLS-1$//$NON-NLS-2$
for (final String k : s3.list(bucket, key))
outw.println(k);
- } else if ("rm".equals(op) || "delete".equals(op)) {
+ } else if ("rm".equals(op) || "delete".equals(op)) { //$NON-NLS-1$ //$NON-NLS-2$
s3.delete(bucket, key);
- } else if ("put".equals(op)) {
+ } else if ("put".equals(op)) { //$NON-NLS-1$
final OutputStream os = s3.beginPut(bucket, key, null, null);
final byte[] tmp = new byte[2048];
int n;
}
if (abbrev == 0)
- abbrev = db.getConfig().getInt("core", "abbrev", 7);
+ abbrev = db.getConfig().getInt("core", "abbrev", 7); //$NON-NLS-1$ //$NON-NLS-2$
if (!showBlankBoundary)
- root = db.getConfig().getBoolean("blame", "blankboundary", false);
+ root = db.getConfig().getBoolean("blame", "blankboundary", false); //$NON-NLS-1$ //$NON-NLS-2$
if (!root)
- root = db.getConfig().getBoolean("blame", "showroot", false);
+ root = db.getConfig().getBoolean("blame", "showroot", false); //$NON-NLS-1$ //$NON-NLS-2$
if (showRawTimestamp)
- dateFmt = new SimpleDateFormat("ZZZZ");
+ dateFmt = new SimpleDateFormat("ZZZZ"); //$NON-NLS-1$
else
- dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZZ");
+ dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZZ"); //$NON-NLS-1$
BlameGenerator generator = new BlameGenerator(db, file);
reader = db.newObjectReader();
}
generator.reverse(rangeStart, rangeEnd);
} else if (revision != null) {
- generator.push(null, db.resolve(revision + "^{commit}"));
+ generator.push(null, db.resolve(revision + "^{commit}")); //$NON-NLS-1$
} else {
generator.push(null, db.resolve(Constants.HEAD));
if (!db.isBare()) {
maxSourceLine = Math.max(maxSourceLine, blame.getSourceLine(line));
}
- String pathFmt = MessageFormat.format(" %{0}s", valueOf(pathWidth));
- String numFmt = MessageFormat.format(" %{0}d",
+ String pathFmt = MessageFormat.format(" %{0}s", valueOf(pathWidth)); //$NON-NLS-1$
+ String numFmt = MessageFormat.format(" %{0}d", //$NON-NLS-1$
valueOf(1 + (int) Math.log10(maxSourceLine + 1)));
- String lineFmt = MessageFormat.format(" %{0}d) ",
+ String lineFmt = MessageFormat.format(" %{0}d) ", //$NON-NLS-1$
valueOf(1 + (int) Math.log10(end + 1)));
- String authorFmt = MessageFormat.format(" (%-{0}s %{1}s",
+ String authorFmt = MessageFormat.format(" (%-{0}s %{1}s", //$NON-NLS-1$
valueOf(authorWidth), valueOf(dateWidth));
for (int line = begin; line < end; line++) {
private void parseLineRangeOption() {
String beginStr, endStr;
- if (rangeString.startsWith("/")) {
- int c = rangeString.indexOf("/,", 1);
+ if (rangeString.startsWith("/")) { //$NON-NLS-1$
+ int c = rangeString.indexOf("/,", 1); //$NON-NLS-1$
if (c < 0) {
beginStr = rangeString;
endStr = String.valueOf(end);
beginStr = rangeString;
endStr = String.valueOf(end);
} else if (c == 0) {
- beginStr = "0";
+ beginStr = "0"; //$NON-NLS-1$
endStr = rangeString.substring(1);
} else {
beginStr = rangeString.substring(0, c);
}
}
- if (beginStr.equals(""))
+ if (beginStr.equals("")) //$NON-NLS-1$
begin = 0;
- else if (beginStr.startsWith("/"))
+ else if (beginStr.startsWith("/")) //$NON-NLS-1$
begin = findLine(0, beginStr);
else
begin = Math.max(0, Integer.parseInt(beginStr) - 1);
- if (endStr.equals(""))
+ if (endStr.equals("")) //$NON-NLS-1$
end = blame.getResultContents().size();
- else if (endStr.startsWith("/"))
+ else if (endStr.startsWith("/")) //$NON-NLS-1$
end = findLine(begin, endStr);
- else if (endStr.startsWith("-"))
+ else if (endStr.startsWith("-")) //$NON-NLS-1$
end = begin + Integer.parseInt(endStr);
- else if (endStr.startsWith("+"))
+ else if (endStr.startsWith("+")) //$NON-NLS-1$
end = begin + Integer.parseInt(endStr.substring(1));
else
end = Math.max(0, Integer.parseInt(endStr) - 1);
private int findLine(int b, String regex) {
String re = regex.substring(1, regex.length() - 1);
- if (!re.startsWith("^"))
- re = ".*" + re;
- if (!re.endsWith("$"))
- re = re + ".*";
+ if (!re.startsWith("^")) //$NON-NLS-1$
+ re = ".*" + re; //$NON-NLS-1$
+ if (!re.endsWith("$")) //$NON-NLS-1$
+ re = re + ".*"; //$NON-NLS-1$
Pattern p = Pattern.compile(re);
RawText text = blame.getResultContents();
for (int line = b; line < text.size(); line++) {
private String path(int line) {
String p = blame.getSourcePath(line);
- return p != null ? p : "";
+ return p != null ? p : ""; //$NON-NLS-1$
}
private String author(int line) {
PersonIdent author = blame.getSourceAuthor(line);
if (author == null)
- return "";
+ return ""; //$NON-NLS-1$
String name = showAuthorEmail ? author.getEmailAddress() : author
.getName();
- return name != null ? name : "";
+ return name != null ? name : ""; //$NON-NLS-1$
}
private String date(int line) {
if (blame.getSourceCommit(line) == null)
- return "";
+ return ""; //$NON-NLS-1$
PersonIdent author = blame.getSourceAuthor(line);
if (author == null)
- return "";
+ return ""; //$NON-NLS-1$
dateFmt.setTimeZone(author.getTimeZone());
if (!showRawTimestamp)
return dateFmt.format(author.getWhen());
- return String.format("%d %s",
+ return String.format("%d %s", //$NON-NLS-1$
valueOf(author.getWhen().getTime() / 1000L),
dateFmt.format(author.getWhen()));
}
} else if (!root && commit.getParentCount() == 0) {
if (showLongRevision)
- r = "^" + commit.name().substring(0, OBJECT_ID_STRING_LENGTH - 1);
+ r = "^" + commit.name().substring(0, OBJECT_ID_STRING_LENGTH - 1); //$NON-NLS-1$
else
- r = "^" + reader.abbreviate(commit, abbrev).name();
+ r = "^" + reader.abbreviate(commit, abbrev).name(); //$NON-NLS-1$
} else {
if (showLongRevision)
r = commit.name();
else
startBranch = Constants.HEAD;
Ref startRef = db.getRef(startBranch);
- ObjectId startAt = db.resolve(startBranch + "^0");
+ ObjectId startAt = db.resolve(startBranch + "^0"); //$NON-NLS-1$
if (startRef != null)
startBranch = startRef.getName();
else
if (head != null) {
String current = head.getLeaf().getName();
if (current.equals(Constants.HEAD))
- addRef("(no branch)", head);
+ addRef("(no branch)", head); //$NON-NLS-1$
addRefs(refs, Constants.R_HEADS, !remote);
addRefs(refs, Constants.R_REMOTES, remote);
outw.print(ref);
if (verbose) {
final int spaces = maxNameLength - ref.length() + 1;
- outw.format("%" + spaces + "s", "");
+ outw.format("%" + spaces + "s", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
final ObjectId objectId = refObj.getObjectId();
outw.print(reader.abbreviate(objectId).name());
outw.print(' ');
dst = new FileRepository(gitdir);
dst.create();
final FileBasedConfig dstcfg = dst.getConfig();
- dstcfg.setBoolean("core", null, "bare", false);
+ dstcfg.setBoolean("core", null, "bare", false); //$NON-NLS-1$ //$NON-NLS-2$
dstcfg.save();
db = dst;
final RemoteConfig rc = new RemoteConfig(dstcfg, remoteName);
rc.addURI(uri);
rc.addFetchRefSpec(new RefSpec().setForceUpdate(true)
- .setSourceDestination(Constants.R_HEADS + "*",
- Constants.R_REMOTES + remoteName + "/*"));
+ .setSourceDestination(Constants.R_HEADS + "*", //$NON-NLS-1$
+ Constants.R_REMOTES + remoteName + "/*")); //$NON-NLS-1$
rc.update(dstcfg);
dstcfg.save();
}
private Enumeration<URL> catalogs() {
try {
- final String pfx = "META-INF/services/";
+ final String pfx = "META-INF/services/"; //$NON-NLS-1$
return ldr.getResources(pfx + TextBuiltin.class.getName());
} catch (IOException err) {
return new Vector<URL>().elements();
final BufferedReader cIn;
try {
final InputStream in = cUrl.openStream();
- cIn = new BufferedReader(new InputStreamReader(in, "UTF-8"));
+ cIn = new BufferedReader(new InputStreamReader(in, "UTF-8")); //$NON-NLS-1$
} catch (IOException err) {
// If we cannot read from the service list, go to the next.
//
try {
String line;
while ((line = cIn.readLine()) != null) {
- if (line.length() > 0 && !line.startsWith("#"))
+ if (line.length() > 0 && !line.startsWith("#")) //$NON-NLS-1$
load(line);
}
} catch (IOException err) {
private CommandRef(final Class<? extends TextBuiltin> clazz, final String cn) {
impl = clazz;
name = cn;
- usage = "";
+ usage = ""; //$NON-NLS-1$
}
private static String guessName(final Class<? extends TextBuiltin> clazz) {
final StringBuilder s = new StringBuilder();
- if (clazz.getName().startsWith("org.eclipse.jgit.pgm.debug."))
- s.append("debug-");
+ if (clazz.getName().startsWith("org.eclipse.jgit.pgm.debug.")) //$NON-NLS-1$
+ s.append("debug-"); //$NON-NLS-1$
boolean lastWasDash = true;
for (final char c : clazz.getSimpleName().toCharArray()) {
if (branchName.startsWith(Constants.R_HEADS))
branchName = branchName.substring(Constants.R_HEADS.length());
}
- outw.println("[" + branchName + " " + commit.name() + "] "
+ outw.println("[" + branchName + " " + commit.name() + "] " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ commit.getShortMessage());
}
}
Set<String> names = config.getNames(section);
for (String name : names) {
for (String value : config.getStringList(section, null, name))
- outw.println(section + "." + name + "=" + value);
+ outw.println(section + "." + name + "=" + value); //$NON-NLS-1$ //$NON-NLS-2$
}
if (names.isEmpty()) {
for (String subsection : config.getSubsections(section)) {
for (String name : names) {
for (String value : config.getStringList(section,
subsection, name))
- outw.println(section + "." + subsection + "."
- + name + "=" + value);
+ outw.println(section + "." + subsection + "." //$NON-NLS-1$ //$NON-NLS-2$
+ + name + "=" + value); //$NON-NLS-1$
}
}
}
@Option(name = "--no-prefix", usage = "usage_noPrefix")
void noPrefix(@SuppressWarnings("unused") boolean on) {
- diffFmt.setOldPrefix("");
- diffFmt.setNewPrefix("");
+ diffFmt.setOldPrefix(""); //$NON-NLS-1$
+ diffFmt.setNewPrefix(""); //$NON-NLS-1$
}
// END -- Options shared with Log
try {
if (cached) {
if (oldTree == null) {
- ObjectId head = db.resolve(HEAD + "^{tree}");
+ ObjectId head = db.resolve(HEAD + "^{tree}"); //$NON-NLS-1$
if (head == null)
die(MessageFormat.format(CLIText.get().notATree, HEAD));
CanonicalTreeParser p = new CanonicalTreeParser();
for (DiffEntry ent : files) {
switch (ent.getChangeType()) {
case ADD:
- out.println("A\t" + ent.getNewPath());
+ out.println("A\t" + ent.getNewPath()); //$NON-NLS-1$
break;
case DELETE:
- out.println("D\t" + ent.getOldPath());
+ out.println("D\t" + ent.getOldPath()); //$NON-NLS-1$
break;
case MODIFY:
- out.println("M\t" + ent.getNewPath());
+ out.println("M\t" + ent.getNewPath()); //$NON-NLS-1$
break;
case COPY:
- out.format("C%1$03d\t%2$s\t%3$s", valueOf(ent.getScore()), //
+ out.format("C%1$03d\t%2$s\t%3$s", valueOf(ent.getScore()), // //$NON-NLS-1$
ent.getOldPath(), ent.getNewPath());
out.println();
break;
case RENAME:
- out.format("R%1$03d\t%2$s\t%3$s", valueOf(ent.getScore()), //
+ out.format("R%1$03d\t%2$s\t%3$s", valueOf(ent.getScore()), // //$NON-NLS-1$
ent.getOldPath(), ent.getNewPath());
out.println();
break;
graphPane.getCommitList().source(walk);
graphPane.getCommitList().fillTo(Integer.MAX_VALUE);
- frame.setTitle("[" + repoName() + "]");
+ frame.setTitle("[" + repoName() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
frame.pack();
frame.setVisible(true);
return graphPane.getCommitList().size();
@Option(name = "--no-prefix", usage = "usage_noPrefix")
void noPrefix(@SuppressWarnings("unused") boolean on) {
- diffFmt.setOldPrefix("");
- diffFmt.setNewPrefix("");
+ diffFmt.setOldPrefix(""); //$NON-NLS-1$
+ diffFmt.setNewPrefix(""); //$NON-NLS-1$
}
// END -- Options shared with Diff
@Override
protected void show(final RevCommit c) throws Exception {
outw.print(CLIText.get().commitLabel);
- outw.print(" ");
+ outw.print(" "); //$NON-NLS-1$
c.getId().copyTo(outbuffer, outw);
if (decorate) {
Collection<Ref> list = allRefsByPeeledObjectId.get(c);
if (list != null) {
- outw.print(" (");
+ outw.print(" ("); //$NON-NLS-1$
for (Iterator<Ref> i = list.iterator(); i.hasNext(); ) {
outw.print(i.next().getName());
if (i.hasNext())
- outw.print(" ");
+ outw.print(" "); //$NON-NLS-1$
}
- outw.print(")");
+ outw.print(")"); //$NON-NLS-1$
}
}
outw.println();
dateFormatter.formatDate(author)));
outw.println();
- final String[] lines = c.getFullMessage().split("\n");
+ final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
for (final String s : lines) {
- outw.print(" ");
+ outw.print(" "); //$NON-NLS-1$
outw.print(s);
outw.println();
}
outw.println();
outw.print("Notes");
if (label != null) {
- outw.print(" (");
+ outw.print(" ("); //$NON-NLS-1$
outw.print(label);
- outw.print(")");
+ outw.print(")"); //$NON-NLS-1$
}
- outw.println(":");
+ outw.println(":"); //$NON-NLS-1$
try {
RawText rawText = new RawText(argWalk.getObjectReader()
.open(blobId).getCachedBytes(Integer.MAX_VALUE));
for (int i = 0; i < rawText.size(); i++) {
- outw.print(" ");
+ outw.print(" "); //$NON-NLS-1$
outw.println(rawText.getString(i));
}
} catch (LargeObjectException e) {
for (final Ref r : c.getRefs()) {
show(r.getObjectId(), r.getName());
if (r.getPeeledObjectId() != null)
- show(r.getPeeledObjectId(), r.getName() + "^{}");
+ show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
}
} finally {
c.close();
&& err instanceof TransportException)
System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getCause().getMessage()));
- if (err.getClass().getName().startsWith("org.eclipse.jgit.errors.")) {
+ if (err.getClass().getName().startsWith("org.eclipse.jgit.errors.")) { //$NON-NLS-1$
System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
if (showStackTrace)
err.printStackTrace();
if (argv.length == 0 || help) {
final String ex = clp.printExample(ExampleMode.ALL, CLIText.get().resourceBundle());
- writer.println("jgit" + ex + " command [ARG ...]");
+ writer.println("jgit" + ex + " command [ARG ...]"); //$NON-NLS-1$
if (help) {
writer.println();
clp.printUsage(writer, CLIText.get().resourceBundle());
private static boolean installConsole() {
try {
- install("org.eclipse.jgit.console.ConsoleAuthenticator");
- install("org.eclipse.jgit.console.ConsoleCredentialsProvider");
+ install("org.eclipse.jgit.console.ConsoleAuthenticator"); //$NON-NLS-1$
+ install("org.eclipse.jgit.console.ConsoleCredentialsProvider"); //$NON-NLS-1$
return true;
} catch (ClassNotFoundException e) {
return false;
throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException, ClassNotFoundException {
try {
- Class.forName(name).getMethod("install").invoke(null);
+ Class.forName(name).getMethod("install").invoke(null); //$NON-NLS-1$
} catch (InvocationTargetException e) {
if (e.getCause() instanceof RuntimeException)
throw (RuntimeException) e.getCause();
* the value in <code>http_proxy</code> is unsupportable.
*/
private static void configureHttpProxy() throws MalformedURLException {
- final String s = System.getenv("http_proxy");
- if (s == null || s.equals(""))
+ final String s = System.getenv("http_proxy"); //$NON-NLS-1$
+ if (s == null || s.equals("")) //$NON-NLS-1$
return;
- final URL u = new URL((s.indexOf("://") == -1) ? "http://" + s : s);
- if (!"http".equals(u.getProtocol()))
+ final URL u = new URL((s.indexOf("://") == -1) ? "http://" + s : s); //$NON-NLS-1$ //$NON-NLS-2$
+ if (!"http".equals(u.getProtocol())) //$NON-NLS-1$
throw new MalformedURLException(MessageFormat.format(CLIText.get().invalidHttpProxyOnlyHttpSupported, s));
final String proxyHost = u.getHost();
final int proxyPort = u.getPort();
- System.setProperty("http.proxyHost", proxyHost);
+ System.setProperty("http.proxyHost", proxyHost); //$NON-NLS-1$
if (proxyPort > 0)
- System.setProperty("http.proxyPort", String.valueOf(proxyPort));
+ System.setProperty("http.proxyPort", String.valueOf(proxyPort)); //$NON-NLS-1$
final String userpass = u.getUserInfo();
- if (userpass != null && userpass.contains(":")) {
+ if (userpass != null && userpass.contains(":")) { //$NON-NLS-1$
final int c = userpass.indexOf(':');
final String user = userpass.substring(0, c);
final String pass = userpass.substring(c + 1);
// determine the other revision we want to merge with HEAD
final Ref srcRef = db.getRef(ref);
- final ObjectId src = db.resolve(ref + "^{commit}");
+ final ObjectId src = db.resolve(ref + "^{commit}"); //$NON-NLS-1$
if (src == null)
throw die(MessageFormat.format(
CLIText.get().refDoesNotExistOrNoCommit, ref));
case DIRTY_WORKTREE:
case DIRTY_INDEX:
outw.println(CLIText.get().dontOverwriteLocalChanges);
- outw.println(" " + entry.getKey());
+ outw.println(" " + entry.getKey()); //$NON-NLS-1$
break;
case COULD_NOT_DELETE:
outw.println(CLIText.get().cannotDeleteFile);
- outw.println(" " + entry.getKey());
+ outw.println(" " + entry.getKey()); //$NON-NLS-1$
break;
}
break;
if (!isMergedInto(oldHead, src))
name = mergeStrategy.getName();
else
- name = "recursive";
+ name = "recursive"; //$NON-NLS-1$
outw.println(MessageFormat.format(CLIText.get().mergeMadeBy, name));
break;
case MERGED_SQUASHED:
final char flag = fastForward ? ' ' : '+';
final String summary = safeAbbreviate(reader, oldRef
.getObjectId())
- + (fastForward ? ".." : "...")
+ + (fastForward ? ".." : "...") //$NON-NLS-1$ //$NON-NLS-2$
+ safeAbbreviate(reader, rru.getNewObjectId());
final String message = fastForward ? null : CLIText.get().forcedUpdate;
printUpdateLine(flag, summary, srcRef, remoteName, message);
private void printUpdateLine(final char flag, final String summary,
final String srcRef, final String destRef, final String message)
throws IOException {
- outw.format(" %c %-17s", valueOf(flag), summary);
+ outw.format(" %c %-17s", valueOf(flag), summary); //$NON-NLS-1$
if (srcRef != null)
- outw.format(" %s ->", abbreviateRef(srcRef, true));
- outw.format(" %s", abbreviateRef(destRef, true));
+ outw.format(" %s ->", abbreviateRef(srcRef, true)); //$NON-NLS-1$
+ outw.format(" %s", abbreviateRef(destRef, true)); //$NON-NLS-1$
if (message != null)
- outw.format(" (%s)", message);
+ outw.format(" (%s)", message); //$NON-NLS-1$
outw.println();
}
private String toString(ReflogEntry entry, int i) {\r
final StringBuilder s = new StringBuilder();\r
s.append(entry.getNewId().abbreviate(7).name());\r
- s.append(" ");\r
+ s.append(" "); //$NON-NLS-1$\r
s.append(ref == null ? Constants.HEAD : Repository.shortenRefName(ref));\r
- s.append("@{" + i + "}:");\r
- s.append(" ");\r
+ s.append("@{" + i + "}:"); //$NON-NLS-1$ //$NON-NLS-2$\r
+ s.append(" "); //$NON-NLS-1$\r
// temporary workaround for bug 393463\r
if (entry.getOldId().equals(ObjectId.zeroId()))\r
- s.append(entry.getComment().replaceFirst("^commit:",\r
- "commit (initial):"));\r
+ s.append(entry.getComment().replaceFirst("^commit:", //$NON-NLS-1$\r
+ "commit (initial):")); //$NON-NLS-1$\r
else\r
s.append(entry.getComment());\r
return s.toString();\r
@Option(name = "--no-prefix", usage = "usage_noPrefix")
void noPrefix(@SuppressWarnings("unused") boolean on) {
- diffFmt.setOldPrefix("");
- diffFmt.setNewPrefix("");
+ diffFmt.setOldPrefix(""); //$NON-NLS-1$
+ diffFmt.setNewPrefix(""); //$NON-NLS-1$
}
// END -- Options shared with Diff
Show() {
- fmt = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy ZZZZZ", Locale.US);
+ fmt = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy ZZZZZ", Locale.US); //$NON-NLS-1$
}
@SuppressWarnings("boxing")
break;
case Constants.OBJ_TREE:
- outw.print("tree ");
+ outw.print("tree "); //$NON-NLS-1$
outw.print(objectName);
outw.println();
outw.println();
private void show(RevTag tag) throws IOException {
outw.print(CLIText.get().tagLabel);
- outw.print(" ");
+ outw.print(" "); //$NON-NLS-1$
outw.print(tag.getTagName());
outw.println();
}
outw.println();
- final String[] lines = tag.getFullMessage().split("\n");
+ final String[] lines = tag.getFullMessage().split("\n"); //$NON-NLS-1$
for (final String s : lines) {
- outw.print(" ");
+ outw.print(" "); //$NON-NLS-1$
outw.print(s);
outw.println();
}
outw.print(walk.getPathString());
final FileMode mode = walk.getFileMode(0);
if (mode == FileMode.TREE)
- outw.print("/");
+ outw.print("/"); //$NON-NLS-1$
outw.println();
}
}
char[] outbuffer = new char[Constants.OBJECT_ID_LENGTH * 2];
outw.print(CLIText.get().commitLabel);
- outw.print(" ");
+ outw.print(" "); //$NON-NLS-1$
c.getId().copyTo(outbuffer, outw);
outw.println();
fmt.format(author.getWhen())));
outw.println();
- final String[] lines = c.getFullMessage().split("\n");
+ final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
for (final String s : lines) {
- outw.print(" ");
+ outw.print(" "); //$NON-NLS-1$
outw.print(s);
outw.println();
}
for (final Ref r : getSortedRefs()) {
show(r.getObjectId(), r.getName());
if (r.getPeeledObjectId() != null)
- show(r.getPeeledObjectId(), r.getName() + "^{}");
+ show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
}
}
int nbNotStagedForCommit = notStagedForCommit.size();
if (nbNotStagedForCommit > 0) {
if (!firstHeader)
- printSectionHeader("");
+ printSectionHeader(""); //$NON-NLS-1$
printSectionHeader(CLIText.get().changesNotStagedForCommit);
printList(CLIText.get().statusModified,
CLIText.get().statusRemoved, null, notStagedForCommit,
int nbUnmerged = unmerged.size();
if (nbUnmerged > 0) {
if (!firstHeader)
- printSectionHeader("");
+ printSectionHeader(""); //$NON-NLS-1$
printSectionHeader(CLIText.get().unmergedPaths);
printList(unmerged);
firstHeader = false;
int nbUntracked = untracked.size();
if (nbUntracked > 0) {
if (!firstHeader)
- printSectionHeader("");
+ printSectionHeader(""); //$NON-NLS-1$
printSectionHeader(CLIText.get().untrackedFiles);
printList(untracked);
}
throws IOException {
outw.println(CLIText.formatLine(MessageFormat
.format(pattern, arguments)));
- if (!pattern.equals(""))
- outw.println(CLIText.formatLine(""));
+ if (!pattern.equals("")) //$NON-NLS-1$
+ outw.println(CLIText.formatLine("")); //$NON-NLS-1$
outw.flush();
}
private boolean force;
@Option(name = "-m", metaVar = "metaVar_message", usage = "usage_tagMessage")
- private String message = "";
+ private String message = ""; //$NON-NLS-1$
@Argument(index = 0, metaVar = "metaVar_name")
private String tagName;
protected void init(final Repository repository, final String gitDir) {
try {
final String outputEncoding = repository != null ? repository
- .getConfig()
- .getString("i18n", null, "logOutputEncoding") : null;
+ .getConfig().getString("i18n", null, "logOutputEncoding") : null; //$NON-NLS-1$ //$NON-NLS-2$
if (outs == null)
outs = new FileOutputStream(FileDescriptor.out);
BufferedWriter bufw;
* @param clp
*/
public void printUsageAndExit(final CmdLineParser clp) {
- printUsageAndExit("", clp);
+ printUsageAndExit("", clp); //$NON-NLS-1$
}
/**
public void printUsageAndExit(final String message, final CmdLineParser clp) {
PrintWriter writer = new PrintWriter(System.err);
writer.println(message);
- writer.print("jgit ");
+ writer.print("jgit "); //$NON-NLS-1$
writer.print(commandName);
clp.printSingleLineUsage(writer, getResourceBundle());
writer.println();
"Algorithm", "Time(ns)", "Time(ns) on", "Time(ns) on");
outw.format("%-25s %12s ( %12s %12s )\n", //
"", "", "N=" + minN, "N=" + maxN);
- outw.println("-----------------------------------------------------"
- + "----------------");
+ outw.println("-----------------------------------------------------" //$NON-NLS-1$
+ + "----------------"); //$NON-NLS-1$
for (Test test : all) {
- outw.format("%-25s %12d ( %12d %12d )", //
+ outw.format("%-25s %12d ( %12d %12d )", // //$NON-NLS-1$
test.algorithm.name, //
valueOf(test.runningTimeNanos), //
valueOf(test.minN.runningTimeNanos), //
for (int i = 0; i < cnt; i++)
db.readDirCache();
final long end = System.currentTimeMillis();
- outw.print(" ");
+ outw.print(" "); //$NON-NLS-1$
outw.println(MessageFormat.format(CLIText.get().averageMSPerRead,
valueOf((end - start) / cnt)));
}
* <p>
*/
class RebuildCommitGraph extends TextBuiltin {
- private static final String REALLY = "--destroy-this-repository";
+ private static final String REALLY = "--destroy-this-repository"; //$NON-NLS-1$
@Option(name = REALLY, usage = "usage_approveDestructionOfRepository")
boolean really;
try {
String line;
while ((line = br.readLine()) != null) {
- final String[] parts = line.split("[ \t]{1,}");
+ final String[] parts = line.split("[ \t]{1,}"); //$NON-NLS-1$
final ObjectId oldId = ObjectId.fromString(parts[0]);
try {
rw.parseCommit(oldId);
pm.beginTask("Rewriting commits", queue.size());
final ObjectInserter oi = db.newObjectInserter();
final ObjectId emptyTree = oi.insert(Constants.OBJ_TREE, new byte[] {});
- final PersonIdent me = new PersonIdent("jgit rebuild-commitgraph",
- "rebuild-commitgraph@localhost");
+ final PersonIdent me = new PersonIdent("jgit rebuild-commitgraph", //$NON-NLS-1$
+ "rebuild-commitgraph@localhost"); //$NON-NLS-1$
while (!queue.isEmpty()) {
final ListIterator<ToRewrite> itr = queue
.listIterator(queue.size());
newc.setAuthor(new PersonIdent(me, new Date(t.commitTime)));
newc.setCommitter(newc.getAuthor());
newc.setParentIds(newParents);
- newc.setMessage("ORIGINAL " + t.oldId.name() + "\n");
+ newc.setMessage("ORIGINAL " + t.oldId.name() + "\n"); //$NON-NLS-2$
t.newId = oi.insert(newc);
rewrites.put(t.oldId, t.newId);
pm.update(1);
try {
String line;
while ((line = br.readLine()) != null) {
- final String[] parts = line.split("[ \t]{1,}");
+ final String[] parts = line.split("[ \t]{1,}"); //$NON-NLS-1$
final ObjectId origId = ObjectId.fromString(parts[0]);
final String type = parts[1];
final String name = parts[2];
final ClassLoader ldr = c.getImplementationClassLoader();
String cn = c.getImplementationClassName();
- cn = cn.replace('.', '/') + ".class";
+ cn = cn.replace('.', '/') + ".class"; //$NON-NLS-1$
final URL url = ldr.getResource(cn);
if (url == null) {
final int stage = ent.getStage();
outw.print(mode);
- outw.format(" %6d", valueOf(len));
+ outw.format(" %6d", valueOf(len)); //$NON-NLS-1$
outw.print(' ');
outw.print(fmt.format(mtime));
outw.print(' ');
File parent = db.getDirectory().getParentFile();
if (name.equals(Constants.DOT_GIT) && parent != null)
name = parent.getName();
- outw.println(name + ":");
+ outw.println(name + ":"); //$NON-NLS-1$
}
outw.format(" %6d files; %5d avg. unique lines/file\n", //
valueOf(fileCnt), //
valueOf(lineCnt / fileCnt));
outw.format("%-20s %-15s %9s\n", "Hash", "Fold", "Max Len");
- outw.println("-----------------------------------------------");
+ outw.println("-----------------------------------------------"); //$NON-NLS-1$
String lastHashName = null;
for (Function fun : all) {
String hashName = fun.hash.name;
if (hashName.equals(lastHashName))
- hashName = "";
- outw.format("%-20s %-15s %9d\n", //
+ hashName = ""; //$NON-NLS-1$
+ outw.format("%-20s %-15s %9d\n", // //$NON-NLS-1$
hashName, //
fun.fold.name, //
valueOf(fun.maxChainLength));
@Command(name = "eclipse-ipzilla", common = false, usage = "usage_synchronizeIPZillaData")
class Ipzilla extends TextBuiltin {
@Option(name = "--url", metaVar = "metaVar_url", usage = "usage_IPZillaURL")
- private String url = "https://dev.eclipse.org/ipzilla/";
+ private String url = "https://dev.eclipse.org/ipzilla/"; //$NON-NLS-1$
@Option(name = "--username", metaVar = "metaVar_user", usage = "usage_IPZillaUsername")
private String username;
final ArrayList<String> tmp = new ArrayList<String>(args.length);
for (int argi = 0; argi < args.length; argi++) {
final String str = args[argi];
- if (str.equals("--")) {
+ if (str.equals("--")) { //$NON-NLS-1$
while (argi < args.length)
tmp.add(args[argi++]);
break;
}
- if (str.startsWith("--")) {
+ if (str.startsWith("--")) { //$NON-NLS-1$
final int eq = str.indexOf('=');
if (eq > 0) {
tmp.add(str.substring(0, eq));
String name = params.getParameter(0);
boolean interesting = true;
- if (name.startsWith("^")) {
+ if (name.startsWith("^")) { //$NON-NLS-1$
name = name.substring(1);
interesting = false;
}
- final int dot2 = name.indexOf("..");
+ final int dot2 = name.indexOf(".."); //$NON-NLS-1$
if (dot2 != -1) {
if (!option.isMultiValued())
throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn
g.setBackground(new Color(colorComponents[0],colorComponents[1],colorComponents[2]));
}
if (txt.length() > 12)
- txt = txt.substring(0,11) + "\u2026"; // ellipsis "…" (in UTF-8)
+ txt = txt.substring(0,11) + "\u2026"; // ellipsis "…" (in UTF-8) //$NON-NLS-1$
final int texth = g.getFontMetrics().getHeight();
int textw = g.getFontMetrics().stringWidth(txt);
final StringBuilder instruction = new StringBuilder();
instruction.append(UIText.get().enterUsernameAndPasswordFor);
- instruction.append(" ");
+ instruction.append(" "); //$NON-NLS-1$
if (getRequestorType() == RequestorType.PROXY) {
instruction.append(getRequestorType());
- instruction.append(" ");
+ instruction.append(" "); //$NON-NLS-1$
instruction.append(getRequestingHost());
if (getRequestingPort() > 0) {
- instruction.append(":");
+ instruction.append(":"); //$NON-NLS-1$
instruction.append(getRequestingPort());
}
} else {
int h = 0;
for (int i = 0; i<getColumnCount(); ++i) {
TableCellRenderer renderer = getDefaultRenderer(getColumnClass(i));
- Component c = renderer.getTableCellRendererComponent(this, "Ã…Oj", false, false, 0, i);
+ Component c = renderer.getTableCellRendererComponent(this,
+ "Ã…Oj", false, false, 0, i); //$NON-NLS-1$
h = Math.max(h, c.getPreferredSize().height);
}
setRowHeight(h + getRowMargin());
final TableColumn author = cols.getColumn(1);
final TableColumn date = cols.getColumn(2);
- graph.setHeaderValue("");
+ graph.setHeaderValue(""); //$NON-NLS-1$
author.setHeaderValue(UIText.get().author);
date.setHeaderValue(UIText.get().date);
final String valueStr;
if (pi != null)
- valueStr = pi.getName() + " <" + pi.getEmailAddress() + ">";
+ valueStr = pi.getName() + " <" + pi.getEmailAddress() + ">"; //$NON-NLS-1$ //$NON-NLS-2$
else
- valueStr = "";
+ valueStr = ""; //$NON-NLS-1$
return super.getTableCellRendererComponent(table, valueStr,
isSelected, hasFocus, row, column);
}
private static final long serialVersionUID = 1L;
private final DateFormat fmt = new SimpleDateFormat(
- "yyyy-MM-dd HH:mm:ss");
+ "yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
public Component getTableCellRendererComponent(final JTable table,
final Object value, final boolean isSelected,
if (pi != null)
valueStr = fmt.format(pi.getWhen());
else
- valueStr = "";
+ valueStr = ""; //$NON-NLS-1$
return super.getTableCellRendererComponent(table, valueStr,
isSelected, hasFocus, row, column);
}
checkCallable();
DirCache dc = null;
boolean addAll = false;
- if (filepatterns.contains("."))
+ if (filepatterns.contains(".")) //$NON-NLS-1$
addAll = true;
ObjectInserter inserter = repo.newObjectInserter();
}
}
if (!isNoNewlineAtEndOfFile(fh))
- newLines.add("");
+ newLines.add(""); //$NON-NLS-1$
if (!rt.isMissingNewlineAtEnd())
- oldLines.add("");
+ oldLines.add(""); //$NON-NLS-1$
if (!isChanged(oldLines, newLines))
return; // don't touch the file
StringBuilder sb = new StringBuilder();
final String eol = rt.size() == 0
- || (rt.size() == 1 && rt.isMissingNewlineAtEnd()) ? "\n" : rt
+ || (rt.size() == 1 && rt.isMissingNewlineAtEnd()) ? "\n" : rt //$NON-NLS-1$
.getLineDelimiter();
for (String l : newLines) {
sb.append(l);
Ref headRef = repo.getRef(Constants.HEAD);
String shortHeadRef = getShortBranchName(headRef);
- String refLogMessage = "checkout: moving from " + shortHeadRef;
+ String refLogMessage = "checkout: moving from " + shortHeadRef; //$NON-NLS-1$
ObjectId branch = repo.resolve(name);
if (branch == null)
throw new RefNotFoundException(MessageFormat.format(JGitText
String toName = Repository.shortenRefName(name);
RefUpdate refUpdate = repo.updateRef(Constants.HEAD, ref == null);
refUpdate.setForceUpdate(force);
- refUpdate.setRefLogMessage(refLogMessage + " to " + toName, false);
+ refUpdate.setRefLogMessage(refLogMessage + " to " + toName, false); //$NON-NLS-1$
Result updateResult;
if (ref != null)
updateResult = refUpdate.link(ref.getName());
&& (name == null || !Repository
.isValidRefName(Constants.R_HEADS + name)))
throw new InvalidRefNameException(MessageFormat.format(JGitText
- .get().branchNameInvalid, name == null ? "<null>" : name));
+ .get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$
}
/**
String ourName = calculateOurName(headRef);
String cherryPickName = srcCommit.getId().abbreviate(7).name()
- + " " + srcCommit.getShortMessage();
+ + " " + srcCommit.getShortMessage(); //$NON-NLS-1$
ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE
.newMerger(repo);
newHead = new Git(getRepository()).commit()
.setMessage(srcCommit.getFullMessage())
.setReflogComment(
- "cherry-pick: "
+ "cherry-pick: " //$NON-NLS-1$
+ srcCommit.getShortMessage())
.setAuthor(srcCommit.getAuthorIdent()).call();
cherryPickedRefs.add(src);
if (!dryRun)
FileUtils.delete(new File(repo.getWorkTree(), dir),
FileUtils.RECURSIVE);
- files.add(dir + "/");
+ files.add(dir + "/"); //$NON-NLS-1$
}
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);
+ config.getName();
RefSpec refSpec = new RefSpec();
refSpec = refSpec.setForceUpdate(true);
- refSpec = refSpec.setSourceDestination(Constants.R_HEADS + "*", dst + "/*"); //$NON-NLS-1$ //$NON-NLS-2$
+ refSpec = refSpec.setSourceDestination(
+ Constants.R_HEADS + "*", dst + "/*"); //$NON-NLS-1$ //$NON-NLS-2$
config.addFetchRefSpec(refSpec);
config.update(clonedRepo.getConfig());
Git git = new Git(repo);
try {
git.add()
- .addFilepattern(".")
+ .addFilepattern(".") //$NON-NLS-1$
.setUpdate(true).call();
} catch (NoFilepatternException e) {
// should really not happen
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
// determine the current HEAD and the commit it is referring to
- ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}");
+ ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}"); //$NON-NLS-1$
if (headId == null && amend)
throw new WrongRepositoryStateException(
JGitText.get().commitAmendOnInitialNotPossible);
if (reflogComment != null) {
ru.setRefLogMessage(reflogComment, false);
} else {
- String prefix = amend ? "commit (amend): "
+ String prefix = amend ? "commit (amend): " //$NON-NLS-1$
: "commit: ";
ru.setRefLogMessage(
prefix + revCommit.getShortMessage(), false);
author, committer, message);
message = ChangeIdUtil.insertId(message, changeId);
if (changeId != null)
- message = message.replaceAll("\nChange-Id: I"
- + ObjectId.zeroId().getName() + "\n", "\nChange-Id: I"
- + changeId.getName() + "\n");
+ message = message.replaceAll("\nChange-Id: I" //$NON-NLS-1$
+ + ObjectId.zeroId().getName() + "\n", "\nChange-Id: I" //$NON-NLS-1$ //$NON-NLS-2$
+ + changeId.getName() + "\n"); //$NON-NLS-1$
}
private DirCache createTemporaryIndex(ObjectId headId, DirCache index)
while (true) {
if (p.equals(o))
return i;
- int l = p.lastIndexOf("/");
+ int l = p.lastIndexOf("/"); //$NON-NLS-1$
if (l < 1)
break;
p = p.substring(0, l);
checkCallable();
if (!only.isEmpty())
throw new JGitInternalException(MessageFormat.format(
- JGitText.get().illegalCombinationOfArguments, "--all",
- "--only"));
+ JGitText.get().illegalCombinationOfArguments, "--all", //$NON-NLS-1$
+ "--only")); //$NON-NLS-1$
this.all = all;
return this;
}
checkCallable();
if (all)
throw new JGitInternalException(MessageFormat.format(
- JGitText.get().illegalCombinationOfArguments, "--only",
- "--all"));
- String o = only.endsWith("/") ? only.substring(0, only.length() - 1)
+ JGitText.get().illegalCombinationOfArguments, "--only", //$NON-NLS-1$
+ "--all")); //$NON-NLS-1$
+ String o = only.endsWith("/") ? only.substring(0, only.length() - 1) //$NON-NLS-1$
: only;
// ignore duplicates
if (!this.only.contains(o))
// determine whether we are based on a commit,
// a branch, or a tag and compose the reflog message
String refLogMessage;
- String baseBranch = "";
+ String baseBranch = ""; //$NON-NLS-1$
if (startPointFullName == null) {
String baseCommit;
if (startCommit != null)
baseCommit = commit.getShortMessage();
}
if (exists)
- refLogMessage = "branch: Reset start-point to commit "
+ refLogMessage = "branch: Reset start-point to commit " //$NON-NLS-1$
+ baseCommit;
else
- refLogMessage = "branch: Created from commit " + baseCommit;
+ refLogMessage = "branch: Created from commit " + baseCommit; //$NON-NLS-1$
} else if (startPointFullName.startsWith(Constants.R_HEADS)
|| startPointFullName.startsWith(Constants.R_REMOTES)) {
baseBranch = startPointFullName;
if (exists)
- refLogMessage = "branch: Reset start-point to branch "
+ refLogMessage = "branch: Reset start-point to branch " //$NON-NLS-1$
+ startPointFullName; // TODO
else
- refLogMessage = "branch: Created from branch " + baseBranch;
+ refLogMessage = "branch: Created from branch " + baseBranch; //$NON-NLS-1$
} else {
startAt = revWalk.peel(revWalk.parseAny(startAt));
if (exists)
- refLogMessage = "branch: Reset start-point to tag "
+ refLogMessage = "branch: Reset start-point to tag " //$NON-NLS-1$
+ startPointFullName;
else
- refLogMessage = "branch: Created from tag "
+ refLogMessage = "branch: Created from tag " //$NON-NLS-1$
+ startPointFullName;
}
String autosetupflag = repo.getConfig().getString(
ConfigConstants.CONFIG_BRANCH_SECTION, null,
ConfigConstants.CONFIG_KEY_AUTOSETUPMERGE);
- if ("false".equals(autosetupflag)) {
+ if ("false".equals(autosetupflag)) { //$NON-NLS-1$
doConfigure = false;
- } else if ("always".equals(autosetupflag)) {
+ } else if ("always".equals(autosetupflag)) { //$NON-NLS-1$
doConfigure = true;
} else {
// in this case, the default is to configure
if (doConfigure) {
StoredConfig config = repo.getConfig();
- String[] tokens = baseBranch.split("/", 4);
- boolean isRemote = tokens[1].equals("remotes");
+ String[] tokens = baseBranch.split("/", 4); //$NON-NLS-1$
+ boolean isRemote = tokens[1].equals("remotes"); //$NON-NLS-1$
if (isRemote) {
// refs/remotes/<remote name>/<branch>
String remoteName = tokens[2];
} else {
// set "." as remote
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
- name, ConfigConstants.CONFIG_KEY_REMOTE, ".");
+ name, ConfigConstants.CONFIG_KEY_REMOTE, "."); //$NON-NLS-1$
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
name, ConfigConstants.CONFIG_KEY_MERGE, baseBranch);
}
if (name == null
|| !Repository.isValidRefName(Constants.R_HEADS + name))
throw new InvalidRefNameException(MessageFormat.format(JGitText
- .get().branchNameInvalid, name == null ? "<null>" : name));
+ .get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$
}
/**
JGitText.get().cannotDeleteCheckedOutBranch,
branchName));
RefUpdate update = repo.updateRef(fullName);
- update.setRefLogMessage("branch deleted", false);
+ update.setRefLogMessage("branch deleted", false); //$NON-NLS-1$
update.setForceUpdate(true);
Result deleteResult = update.delete();
try {
if (cached) {
if (oldTree == null) {
- ObjectId head = repo.resolve(HEAD + "^{tree}");
+ ObjectId head = repo.resolve(HEAD + "^{tree}"); //$NON-NLS-1$
if (head == null)
throw new NoHeadException(JGitText.get().cannotReadTree);
CanonicalTreeParser p = new CanonicalTreeParser();
d = new File(d, Constants.DOT_GIT);
builder.setGitDir(d);
} else if (builder.getGitDir() == null) {
- File d = new File(".");
+ File d = new File("."); //$NON-NLS-1$
if (d.getParentFile() != null)
d = d.getParentFile();
if (!bare)
Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);
if (tags)
refSpecs.add(new RefSpec(
- "refs/tags/*:refs/remotes/origin/tags/*"));
+ "refs/tags/*:refs/remotes/origin/tags/*")); //$NON-NLS-1$
if (heads)
- refSpecs.add(new RefSpec("refs/heads/*:refs/remotes/origin/*"));
+ refSpecs.add(new RefSpec("refs/heads/*:refs/remotes/origin/*")); //$NON-NLS-1$
Collection<Ref> refs;
Map<String, Ref> refmap = new HashMap<String, Ref>();
fc = transport.openFetch();
if (head == null)
throw new NoHeadException(
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
- StringBuilder refLogMessage = new StringBuilder("merge ");
+ StringBuilder refLogMessage = new StringBuilder("merge "); //$NON-NLS-1$
// Check for FAST_FORWARD, ALREADY_UP_TO_DATE
revWalk = new RevWalk(repo);
.updateRef(head.getTarget().getName());
refUpdate.setNewObjectId(objectId);
refUpdate.setExpectedOldObjectId(null);
- refUpdate.setRefLogMessage("initial pull", false);
+ refUpdate.setRefLogMessage("initial pull", false); //$NON-NLS-1$
if (refUpdate.update() != Result.NEW)
throw new NoHeadException(
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
&& fastForwardMode == FastForwardMode.FF) {
// FAST_FORWARD detected: skip doing a real merge but only
// update HEAD
- refLogMessage.append(": " + MergeStatus.FAST_FORWARD);
+ refLogMessage.append(": " + MergeStatus.FAST_FORWARD); //$NON-NLS-1$
dco = new DirCacheCheckout(repo,
headCommit.getTree(), repo.lockDirCache(),
srcCommit.getTree());
new ObjectId[] { headCommit, srcCommit },
MergeStatus.ABORTED, mergeStrategy, null, null);
}
- String mergeMessage = "";
+ String mergeMessage = ""; //$NON-NLS-1$
if (!squash) {
mergeMessage = new MergeMessageFormatter().format(
commits, head);
if (merger instanceof ResolveMerger) {
ResolveMerger resolveMerger = (ResolveMerger) merger;
resolveMerger.setCommitNames(new String[] {
- "BASE", "HEAD", ref.getName() });
+ "BASE", "HEAD", ref.getName() }); //$NON-NLS-1$
resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
noProblems = merger.merge(headCommit, srcCommit);
lowLevelResults = resolveMerger
unmergedPaths = resolveMerger.getUnmergedPaths();
} else
noProblems = merger.merge(headCommit, srcCommit);
- refLogMessage.append(": Merge made by ");
+ refLogMessage.append(": Merge made by "); //$NON-NLS-1$
if (!revWalk.isMergedInto(headCommit, srcCommit))
refLogMessage.append(mergeStrategy.getName());
else
- refLogMessage.append("recursive");
+ refLogMessage.append("recursive"); //$NON-NLS-1$
refLogMessage.append('.');
if (noProblems) {
dco = new DirCacheCheckout(repo,
return base;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
boolean first = true;
*/
public class PullCommand extends TransportCommand<PullCommand, PullResult> {
- private final static String DOT = ".";
+ private final static String DOT = "."; //$NON-NLS-1$
private ProgressMonitor monitor = NullProgressMonitor.INSTANCE;
JGitText.get().missingConfigurationForKey, missingKey));
}
- final boolean isRemote = !remote.equals(".");
+ final boolean isRemote = !remote.equals("."); //$NON-NLS-1$
String remoteUri;
FetchResult fetchRes;
if (isRemote) {
return true;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
/**
* The name of the "rebase-merge" folder
*/
- public static final String REBASE_MERGE = "rebase-merge";
+ public static final String REBASE_MERGE = "rebase-merge"; //$NON-NLS-1$
/**
* The name of the "stopped-sha" file
*/
- public static final String STOPPED_SHA = "stopped-sha";
+ public static final String STOPPED_SHA = "stopped-sha"; //$NON-NLS-1$
- private static final String AUTHOR_SCRIPT = "author-script";
+ private static final String AUTHOR_SCRIPT = "author-script"; //$NON-NLS-1$
- private static final String DONE = "done";
+ private static final String DONE = "done"; //$NON-NLS-1$
- private static final String GIT_AUTHOR_DATE = "GIT_AUTHOR_DATE";
+ private static final String GIT_AUTHOR_DATE = "GIT_AUTHOR_DATE"; //$NON-NLS-1$
- private static final String GIT_AUTHOR_EMAIL = "GIT_AUTHOR_EMAIL";
+ private static final String GIT_AUTHOR_EMAIL = "GIT_AUTHOR_EMAIL"; //$NON-NLS-1$
- private static final String GIT_AUTHOR_NAME = "GIT_AUTHOR_NAME";
+ private static final String GIT_AUTHOR_NAME = "GIT_AUTHOR_NAME"; //$NON-NLS-1$
- private static final String GIT_REBASE_TODO = "git-rebase-todo";
+ private static final String GIT_REBASE_TODO = "git-rebase-todo"; //$NON-NLS-1$
- private static final String HEAD_NAME = "head-name";
+ private static final String HEAD_NAME = "head-name"; //$NON-NLS-1$
- private static final String INTERACTIVE = "interactive";
+ private static final String INTERACTIVE = "interactive"; //$NON-NLS-1$
- private static final String MESSAGE = "message";
+ private static final String MESSAGE = "message"; //$NON-NLS-1$
- private static final String ONTO = "onto";
+ private static final String ONTO = "onto"; //$NON-NLS-1$
- private static final String ONTO_NAME = "onto-name";
+ private static final String ONTO_NAME = "onto-name"; //$NON-NLS-1$
- private static final String PATCH = "patch";
+ private static final String PATCH = "patch"; //$NON-NLS-1$
- private static final String REBASE_HEAD = "head";
+ private static final String REBASE_HEAD = "head"; //$NON-NLS-1$
- private static final String AMEND = "amend";
+ private static final String AMEND = "amend"; //$NON-NLS-1$
/**
* The available operations
for (Step step : steps) {
sb.setLength(0);
sb.append(step.action.token);
- sb.append(" ");
+ sb.append(" "); //$NON-NLS-1$
sb.append(step.commit.name());
- sb.append(" ");
+ sb.append(" "); //$NON-NLS-1$
sb.append(RawParseUtils.decode(step.shortMessage)
.trim());
fw.write(sb.toString());
}
private RevCommit checkoutCurrentHead() throws IOException, NoHeadException {
- ObjectId headTree = repo.resolve(Constants.HEAD + "^{tree}");
+ ObjectId headTree = repo.resolve(Constants.HEAD + "^{tree}"); //$NON-NLS-1$
if (headTree == null)
throw new NoHeadException(
JGitText.get().cannotRebaseWithoutCurrentHead);
treeWalk.reset();
treeWalk.setRecursive(true);
treeWalk.addTree(new DirCacheIterator(dc));
- ObjectId id = repo.resolve(Constants.HEAD + "^{tree}");
+ ObjectId id = repo.resolve(Constants.HEAD + "^{tree}"); //$NON-NLS-1$
if (id == null)
throw new NoHeadException(
JGitText.get().cannotRebaseWithoutCurrentHead);
String toAuthorScript(PersonIdent author) {
StringBuilder sb = new StringBuilder(100);
sb.append(GIT_AUTHOR_NAME);
- sb.append("='");
+ sb.append("='"); //$NON-NLS-1$
sb.append(author.getName());
- sb.append("'\n");
+ sb.append("'\n"); //$NON-NLS-1$
sb.append(GIT_AUTHOR_EMAIL);
- sb.append("='");
+ sb.append("='"); //$NON-NLS-1$
sb.append(author.getEmailAddress());
- sb.append("'\n");
+ sb.append("'\n"); //$NON-NLS-1$
// the command line uses the "external String"
// representation for date and timezone
sb.append(GIT_AUTHOR_DATE);
- sb.append("='");
- sb.append("@"); // @ for time in seconds since 1970
+ sb.append("='"); //$NON-NLS-1$
+ sb.append("@"); // @ for time in seconds since 1970 //$NON-NLS-1$
String externalString = author.toExternalString();
sb
.append(externalString.substring(externalString
.lastIndexOf('>') + 2));
- sb.append("'\n");
+ sb.append("'\n"); //$NON-NLS-1$
return sb.toString();
}
createFile(rebaseDir, HEAD_NAME, headName);
createFile(rebaseDir, ONTO, upstreamCommit.name());
createFile(rebaseDir, ONTO_NAME, upstreamCommitName);
- createFile(rebaseDir, INTERACTIVE, "");
+ createFile(rebaseDir, INTERACTIVE, ""); //$NON-NLS-1$
BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(new File(rebaseDir, GIT_REBASE_TODO)),
Constants.CHARACTER_ENCODING));
for (RevCommit commit : cherryPickList) {
sb.setLength(0);
sb.append(Action.PICK.toToken());
- sb.append(" ");
+ sb.append(" "); //$NON-NLS-1$
sb.append(reader.abbreviate(commit).name());
- sb.append(" ");
+ sb.append(" "); //$NON-NLS-1$
sb.append(commit.getShortMessage());
fw.write(sb.toString());
fw.newLine();
RefUpdate rup = repo.updateRef(headName);
rup.setExpectedOldObjectId(oldCommit);
rup.setNewObjectId(newCommit);
- rup.setRefLogMessage("Fast-foward from " + oldCommit.name()
- + " to " + newCommit.name(), false);
+ rup.setRefLogMessage("Fast-foward from " + oldCommit.name() //$NON-NLS-1$
+ + " to " + newCommit.name(), false); //$NON-NLS-1$
Result res = rup.update(walk);
switch (res) {
case FAST_FORWARD:
case FORCED:
break;
default:
- throw new IOException("Could not fast-forward");
+ throw new IOException("Could not fast-forward"); //$NON-NLS-1$
}
}
return newCommit;
*/
public static enum Action {
/** Use commit */
- PICK("pick", "p"),
+ PICK("pick", "p"), //$NON-NLS-1$ //$NON-NLS-2$
/** Use commit, but edit the commit message */
- REWORD("reword", "r"),
+ REWORD("reword", "r"), //$NON-NLS-1$ //$NON-NLS-2$
/** Use commit, but stop for amending */
- EDIT("edit", "e"); // later add SQUASH, FIXUP, etc.
+ EDIT("edit", "e"); // later add SQUASH, FIXUP, etc. //$NON-NLS-1$ //$NON-NLS-2$
private final String token;
return this.token;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "Action[" + token + "]";
return shortMessage;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
- return "Step[" + action + ", "
+ return "Step["
+ + action
+ + ", "
+ ((commit == null) ? "null" : commit)
+ ", "
+ ((shortMessage == null) ? "null" : new String(
// the time is saved as <seconds since 1970> <timezone offset>
int timeStart = 0;
- if (time.startsWith("@"))
+ if (time.startsWith("@")) //$NON-NLS-1$
timeStart = 1;
else
timeStart = 0;
if (newName == null)
throw new InvalidRefNameException(MessageFormat.format(JGitText
- .get().branchNameInvalid, "<null>"));
+ .get().branchNameInvalid, "<null>")); //$NON-NLS-1$
try {
String fullOldName;
// resolve the ref to a commit
final ObjectId commitId;
try {
- commitId = repo.resolve(ref + "^{commit}");
+ commitId = repo.resolve(ref + "^{commit}"); //$NON-NLS-1$
if (commitId == null) {
// @TODO throw an InvalidRefNameException. We can't do that
// now because this would break the API
if (!filepaths.isEmpty())
throw new JGitInternalException(MessageFormat.format(
JGitText.get().illegalCombinationOfArguments,
- "[--mixed | --soft | --hard]", "<paths>..."));
+ "[--mixed | --soft | --hard]", "<paths>...")); //$NON-NLS-1$
this.mode = mode;
return this;
}
if (mode != null)
throw new JGitInternalException(MessageFormat.format(
JGitText.get().illegalCombinationOfArguments, "<paths>...",
- "[--mixed | --soft | --hard]"));
+ "[--mixed | --soft | --hard]")); //$NON-NLS-1$
filepaths.add(file);
return this;
}
merger.getResultTreeId());
dco.setFailOnConflict(true);
dco.checkout();
- String shortMessage = "Revert \"" + srcCommit.getShortMessage() + "\"";
- String newMessage = shortMessage + "\n\n"
- + "This reverts commit "
- + srcCommit.getId().getName() + ".\n";
+ String shortMessage = "Revert \"" + srcCommit.getShortMessage() + "\""; //$NON-NLS-2$
+ String newMessage = shortMessage + "\n\n" //$NON-NLS-1$
+ + "This reverts commit " //$NON-NLS-1$
+ + srcCommit.getId().getName() + ".\n"; //$NON-NLS-1$
newHead = new Git(getRepository()).commit()
.setMessage(newMessage)
- .setReflogComment("revert: " + shortMessage).call();
+ .setReflogComment("revert: " + shortMessage).call(); //$NON-NLS-1$
revertedRefs.add(src);
} else {
unmergedPaths = merger.getUnmergedPaths();
*/
public class StashApplyCommand extends GitCommand<ObjectId> {
- private static final String DEFAULT_REF = Constants.STASH + "@{0}";
+ private static final String DEFAULT_REF = Constants.STASH + "@{0}"; //$NON-NLS-1$
/**
* Stash diff filter that looks for differences in the first three trees
@Override
public String toString() {
- return "STASH_DIFF";
+ return "STASH_DIFF"; //$NON-NLS-1$
}
}
private ObjectId getHeadTree() throws GitAPIException {
final ObjectId headTree;
try {
- headTree = repo.resolve(Constants.HEAD + "^{tree}");
+ headTree = repo.resolve(Constants.HEAD + "^{tree}"); //$NON-NLS-1$
} catch (IOException e) {
throw new JGitInternalException(JGitText.get().cannotReadTree, e);
}
// if no id is set, we should attempt to use HEAD
if (id == null) {
- ObjectId objectId = repo.resolve(Constants.HEAD + "^{commit}");
+ ObjectId objectId = repo.resolve(Constants.HEAD + "^{commit}"); //$NON-NLS-1$
if (objectId == null)
throw new NoHeadException(
JGitText.get().tagOnRepoWithoutHEADCurrentlyNotSupported);
RefUpdate tagRef = repo.updateRef(refName);
tagRef.setNewObjectId(tagId);
tagRef.setForceUpdate(forceUpdate);
- tagRef.setRefLogMessage("tagged " + name, false);
+ tagRef.setRefLogMessage("tagged " + name, false); //$NON-NLS-1$
Result updateResult = tagRef.update(revWalk);
switch (updateResult) {
case NEW:
*/
public ConcurrentRefUpdateException(String message, Ref ref,
RefUpdate.Result rc, Throwable cause) {
- super((rc == null) ? message : message + ". "
+ super((rc == null) ? message : message + ". " //$NON-NLS-1$
+ MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc), cause);
this.rc = rc;
this.ref = ref;
*/
public ConcurrentRefUpdateException(String message, Ref ref,
RefUpdate.Result rc) {
- super((rc == null) ? message : message + ". "
+ super((rc == null) ? message : message + ". " //$NON-NLS-1$
+ MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc));
this.rc = rc;
this.ref = ref;
revPool = new RevWalk(getRepository());
revPool.setRetainBody(true);
- SEEN = revPool.newFlag("SEEN");
+ SEEN = revPool.newFlag("SEEN"); //$NON-NLS-1$
reader = revPool.getObjectReader();
treeWalk = new TreeWalk(reader);
treeWalk.setRecursive(true);
@Override
public String toString() {
StringBuilder r = new StringBuilder();
- r.append("BlameResult: ");
+ r.append("BlameResult: "); //$NON-NLS-1$
r.append(getResultPath());
return r.toString();
}
return r;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder r = new StringBuilder();
@Override
public String toString() {
- return "Reverse" + super.toString();
+ return "Reverse" + super.toString(); //$NON-NLS-1$
}
}
@Override
PersonIdent getAuthor() {
- return new PersonIdent(description, "");
+ return new PersonIdent(description, ""); //$NON-NLS-1$
}
}
}
private final int renameLimit;
private DiffConfig(final Config rc) {
- noPrefix = rc.getBoolean("diff", "noprefix", false);
- renameDetectionType = parseRenameDetectionType(rc.getString("diff",
- null, "renames"));
- renameLimit = rc.getInt("diff", "renamelimit", 200);
+ noPrefix = rc.getBoolean("diff", "noprefix", false); //$NON-NLS-1$ //$NON-NLS-2$
+ renameDetectionType = parseRenameDetectionType(rc.getString("diff", //$NON-NLS-1$
+ null, "renames")); //$NON-NLS-1$
+ renameLimit = rc.getInt("diff", "renamelimit", 200); //$NON-NLS-1$ //$NON-NLS-2$
}
/** @return true if the prefix "a/" and "b/" should be suppressed. */
final String renameString) {
if (renameString == null)
return RenameDetectionType.FALSE;
- else if (StringUtils.equalsIgnoreCase("copy", renameString)
- || StringUtils.equalsIgnoreCase("copies", renameString))
+ else if (StringUtils.equalsIgnoreCase("copy", renameString) //$NON-NLS-1$
+ || StringUtils.equalsIgnoreCase("copies", renameString)) //$NON-NLS-1$
return RenameDetectionType.COPY;
else {
final Boolean renameBoolean = StringUtils
.toBooleanOrNull(renameString);
if (renameBoolean == null)
throw new IllegalArgumentException(MessageFormat.format(
- JGitText.get().enumValueNotSupported2, "diff",
- "renames", renameString));
+ JGitText.get().enumValueNotSupported2, "diff", //$NON-NLS-1$
+ "renames", renameString)); //$NON-NLS-1$
else if (renameBoolean.booleanValue())
return RenameDetectionType.TRUE;
else
.fromObjectId(ObjectId.zeroId());
/** Magical file name used for file adds or deletes. */
- public static final String DEV_NULL = "/dev/null";
+ public static final String DEV_NULL = "/dev/null"; //$NON-NLS-1$
/** General type of change a single file-level patch describes. */
public static enum ChangeType {
return side == Side.OLD ? getOldId() : getNewId();
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
public class DiffFormatter {
private static final int DEFAULT_BINARY_FILE_THRESHOLD = PackConfig.DEFAULT_BIG_FILE_THRESHOLD;
- private static final byte[] noNewLine = encodeASCII("\\ No newline at end of file\n");
+ private static final byte[] noNewLine = encodeASCII("\\ No newline at end of file\n"); //$NON-NLS-1$
/** Magic return content indicating it is empty or no content present. */
private static final byte[] EMPTY = new byte[] {};
private int binaryFileThreshold = DEFAULT_BINARY_FILE_THRESHOLD;
- private String oldPrefix = "a/";
+ private String oldPrefix = "a/"; //$NON-NLS-1$
- private String newPrefix = "b/";
+ private String newPrefix = "b/"; //$NON-NLS-1$
private TreeFilter pathFilter = TreeFilter.ALL;
DiffConfig dc = db.getConfig().get(DiffConfig.KEY);
if (dc.isNoPrefix()) {
- setOldPrefix("");
- setNewPrefix("");
+ setOldPrefix(""); //$NON-NLS-1$
+ setNewPrefix(""); //$NON-NLS-1$
}
setDetectRenames(dc.isRenameDetectionEnabled());
private void writeGitLinkDiffText(OutputStream o, DiffEntry ent)
throws IOException {
if (ent.getOldMode() == GITLINK) {
- o.write(encodeASCII("-Subproject commit " + ent.getOldId().name()
- + "\n"));
+ o.write(encodeASCII("-Subproject commit " + ent.getOldId().name() //$NON-NLS-1$
+ + "\n")); //$NON-NLS-1$
}
if (ent.getNewMode() == GITLINK) {
- o.write(encodeASCII("+Subproject commit " + ent.getNewId().name()
- + "\n"));
+ o.write(encodeASCII("+Subproject commit " + ent.getNewId().name() //$NON-NLS-1$
+ + "\n")); //$NON-NLS-1$
}
}
if (aRaw == BINARY || bRaw == BINARY //
|| RawText.isBinary(aRaw) || RawText.isBinary(bRaw)) {
formatOldNewPaths(buf, ent);
- buf.write(encodeASCII("Binary files differ\n"));
+ buf.write(encodeASCII("Binary files differ\n")); //$NON-NLS-1$
editList = new EditList();
type = PatchType.BINARY;
final FileMode oldMode = ent.getOldMode();
final FileMode newMode = ent.getNewMode();
- o.write(encodeASCII("diff --git "));
+ o.write(encodeASCII("diff --git ")); //$NON-NLS-1$
o.write(encode(quotePath(oldPrefix + (type == ADD ? newp : oldp))));
o.write(' ');
o.write(encode(quotePath(newPrefix + (type == DELETE ? oldp : newp))));
switch (type) {
case ADD:
- o.write(encodeASCII("new file mode "));
+ o.write(encodeASCII("new file mode ")); //$NON-NLS-1$
newMode.copyTo(o);
o.write('\n');
break;
case DELETE:
- o.write(encodeASCII("deleted file mode "));
+ o.write(encodeASCII("deleted file mode ")); //$NON-NLS-1$
oldMode.copyTo(o);
o.write('\n');
break;
case RENAME:
- o.write(encodeASCII("similarity index " + ent.getScore() + "%"));
+ o.write(encodeASCII("similarity index " + ent.getScore() + "%")); //$NON-NLS-1$ //$NON-NLS-2$
o.write('\n');
- o.write(encode("rename from " + quotePath(oldp)));
+ o.write(encode("rename from " + quotePath(oldp))); //$NON-NLS-1$
o.write('\n');
- o.write(encode("rename to " + quotePath(newp)));
+ o.write(encode("rename to " + quotePath(newp))); //$NON-NLS-1$
o.write('\n');
break;
case COPY:
- o.write(encodeASCII("similarity index " + ent.getScore() + "%"));
+ o.write(encodeASCII("similarity index " + ent.getScore() + "%")); //$NON-NLS-1$ //$NON-NLS-2$
o.write('\n');
- o.write(encode("copy from " + quotePath(oldp)));
+ o.write(encode("copy from " + quotePath(oldp))); //$NON-NLS-1$
o.write('\n');
- o.write(encode("copy to " + quotePath(newp)));
+ o.write(encode("copy to " + quotePath(newp))); //$NON-NLS-1$
o.write('\n');
if (!oldMode.equals(newMode)) {
- o.write(encodeASCII("new file mode "));
+ o.write(encodeASCII("new file mode ")); //$NON-NLS-1$
newMode.copyTo(o);
o.write('\n');
}
case MODIFY:
if (0 < ent.getScore()) {
- o.write(encodeASCII("dissimilarity index "
- + (100 - ent.getScore()) + "%"));
+ o.write(encodeASCII("dissimilarity index " //$NON-NLS-1$
+ + (100 - ent.getScore()) + "%")); //$NON-NLS-1$
o.write('\n');
}
break;
}
if ((type == MODIFY || type == RENAME) && !oldMode.equals(newMode)) {
- o.write(encodeASCII("old mode "));
+ o.write(encodeASCII("old mode ")); //$NON-NLS-1$
oldMode.copyTo(o);
o.write('\n');
- o.write(encodeASCII("new mode "));
+ o.write(encodeASCII("new mode ")); //$NON-NLS-1$
newMode.copyTo(o);
o.write('\n');
}
*/
protected void formatIndexLine(OutputStream o, DiffEntry ent)
throws IOException {
- o.write(encodeASCII("index " //
+ o.write(encodeASCII("index " // //$NON-NLS-1$
+ format(ent.getOldId()) //
- + ".." //
+ + ".." // //$NON-NLS-1$
+ format(ent.getNewId())));
if (ent.getOldMode().equals(ent.getNewMode())) {
o.write(' ');
break;
}
- o.write(encode("--- " + oldp + "\n"));
- o.write(encode("+++ " + newp + "\n"));
+ o.write(encode("--- " + oldp + "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ o.write(encode("+++ " + newp + "\n")); //$NON-NLS-1$ //$NON-NLS-2$
}
private int findCombinedEnd(final List<Edit> edits, final int i) {
return false;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
final Type t = getType();
@Override
public String toString() {
- return "EditList" + super.toString();
+ return "EditList" + super.toString(); //$NON-NLS-1$
}
}
*/
public String getString(int begin, int end, boolean dropLF) {
if (begin == end)
- return "";
+ return ""; //$NON-NLS-1$
int s = getStart(begin);
int e = getEnd(end - 1);
if (content[e - 1] != '\n')
return null;
if (content.length > 1 && content[e - 2] == '\r')
- return "\r\n";
+ return "\r\n"; //$NON-NLS-1$
else
- return "\n";
+ return "\n"; //$NON-NLS-1$
}
}
}
static int nameScore(String a, String b) {
- int aDirLen = a.lastIndexOf("/") + 1;
- int bDirLen = b.lastIndexOf("/") + 1;
+ int aDirLen = a.lastIndexOf("/") + 1; //$NON-NLS-1$
+ int bDirLen = b.lastIndexOf("/") + 1; //$NON-NLS-1$
int dirMin = Math.min(aDirLen, bDirLen);
int dirMax = Math.max(aDirLen, bDirLen);
private static String formatExtensionName(final byte[] hdr)
throws UnsupportedEncodingException {
- return "'" + new String(hdr, 0, 4, "ISO-8859-1") + "'";
+ return "'" + new String(hdr, 0, 4, "ISO-8859-1") + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
private static boolean is_DIRC(final byte[] hdr) {
System.arraycopy(sortedEntries, 0, r, 0, sortedEntries.length);
return r;
}
- if (!path.endsWith("/"))
- path += "/";
+ if (!path.endsWith("/")) //$NON-NLS-1$
+ path += "/"; //$NON-NLS-1$
final byte[] p = Constants.encode(path);
final int pLen = p.length;
private static IllegalStateException bad(final DirCacheEntry a,
final String msg) {
- return new IllegalStateException(msg + ": " + a.getStage() + " "
+ return new IllegalStateException(msg + ": " + a.getStage() + " " //$NON-NLS-1$ //$NON-NLS-2$
+ a.getPathString());
}
}
builder.finish();
File file = null;
- String last = "";
+ String last = ""; //$NON-NLS-1$
// when deleting files process them in the opposite order as they have
// been reported. This ensures the files are deleted before we delete
// their parent folders
ObjectLoader ol = or.open(entry.getObjectId());
File parentDir = f.getParentFile();
parentDir.mkdirs();
- File tmpFile = File.createTempFile("._" + f.getName(), null, parentDir);
+ File tmpFile = File.createTempFile("._" + f.getName(), null, parentDir); //$NON-NLS-1$
WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY);
FileOutputStream rawChannel = new FileOutputStream(tmpFile);
OutputStream channel;
private static byte[][] forbidden;
static {
- String[] list = new String[] { "AUX", "COM1", "COM2", "COM3", "COM4",
- "COM5", "COM6", "COM7", "COM8", "COM9", "CON", "LPT1", "LPT2",
- "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", "NUL",
- "PRN" };
+ String[] list = new String[] { "AUX", "COM1", "COM2", "COM3", "COM4", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "COM5", "COM6", "COM7", "COM8", "COM9", "CON", "LPT1", "LPT2", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
+ "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", "NUL", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
+ "PRN" }; //$NON-NLS-1$
forbidden = new byte[list.length][];
for (int i = 0; i < list.length; ++i)
forbidden[i] = Constants.encodeASCII(list[i]);
/**
* Use for debugging only !
*/
+ @SuppressWarnings("nls")
@Override
public String toString() {
return getFileMode() + " " + getLength() + " " + getLastModified()
private static String buildList(String[] files) {
StringBuilder builder = new StringBuilder();
for (String f : files) {
- builder.append("\n");
+ builder.append("\n"); //$NON-NLS-1$
builder.append(f);
}
return builder.toString();
final StringBuilder msg = new StringBuilder();
msg.append(JGitText.get().failureDueToOneOfTheFollowing);
for (final Throwable c : causes) {
- msg.append(" ");
+ msg.append(" "); //$NON-NLS-1$
msg.append(c.getMessage());
- msg.append("\n");
+ msg.append("\n"); //$NON-NLS-1$
}
return msg.toString();
}
private static String asAscii(byte[] bytes, int offset, int length) {
try {
- return ": " + new String(bytes, offset, length, "US-ASCII");
+ return ": " + new String(bytes, offset, length, "US-ASCII"); //$NON-NLS-1$ //$NON-NLS-2$
} catch (UnsupportedEncodingException e2) {
- return "";
+ return ""; //$NON-NLS-1$
} catch (StringIndexOutOfBoundsException e2) {
- return "";
+ return ""; //$NON-NLS-1$
}
}
}
final StringBuilder r = new StringBuilder();
r.append(JGitText.get().missingPrerequisiteCommits);
for (final Map.Entry<ObjectId, String> e : missingCommits.entrySet()) {
- r.append("\n ");
+ r.append("\n "); //$NON-NLS-1$
r.append(e.getKey().name());
if (e.getValue() != null)
- r.append(" ").append(e.getValue());
+ r.append(" ").append(e.getValue()); //$NON-NLS-1$
}
return r.toString();
}
* message
*/
public PackProtocolException(final URIish uri, final String s) {
- super(uri + ": " + s);
+ super(uri + ": " + s); //$NON-NLS-1$
}
/**
*/
public PackProtocolException(final URIish uri, final String s,
final Throwable cause) {
- this(uri + ": " + s, cause);
+ this(uri + ": " + s, cause); //$NON-NLS-1$
}
/**
@Override
public String toString() {
- return super.toString() + ":" + revstr;
+ return super.toString() + ":" + revstr; //$NON-NLS-1$
}
}
* {@link ResourceBundle#getBundle(String, Locale)} method.
*/
public TranslationBundleLoadingException(Class bundleClass, Locale locale, Exception cause) {
- super("Loading of translation bundle failed for ["
- + bundleClass.getName() + ", " + locale.toString() + "]",
+ super("Loading of translation bundle failed for [" //$NON-NLS-1$
+ + bundleClass.getName() + ", " + locale.toString() + "]", //$NON-NLS-1$ //$NON-NLS-2$
bundleClass, locale, cause);
}
}
\ No newline at end of file
* {@link ResourceBundle#getString(String)} method.
*/
public TranslationStringMissingException(Class bundleClass, Locale locale, String key, Exception cause) {
- super("Translation missing for [" + bundleClass.getName() + ", "
- + locale.toString() + ", " + key + "]", bundleClass, locale,
+ super("Translation missing for [" + bundleClass.getName() + ", " //$NON-NLS-1$ //$NON-NLS-2$
+ + locale.toString() + ", " + key + "]", bundleClass, locale, //$NON-NLS-1$ //$NON-NLS-2$
cause);
this.key = key;
}
* message
*/
public TransportException(final URIish uri, final String s) {
- super(uri.setPass(null) + ": " + s);
+ super(uri.setPass(null) + ": " + s); //$NON-NLS-1$
}
/**
*/
public TransportException(final URIish uri, final String s,
final Throwable cause) {
- this(uri.setPass(null) + ": " + s, cause);
+ this(uri.setPass(null) + ": " + s, cause); //$NON-NLS-1$
}
/**
* message
*/
public UnsupportedCredentialItem(final URIish uri, final String s) {
- super(uri.setPass(null) + ": " + s);
+ super(uri.setPass(null) + ": " + s); //$NON-NLS-1$
}
}
parent.remove(this);
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return type.getSimpleName() + "[" + listener + "]";
*/
public abstract void dispatch(T listener);
+ @SuppressWarnings("nls")
@Override
public String toString() {
String type = getClass().getSimpleName();
static final List<Head> EMPTY_HEAD_LIST = Collections.emptyList();
private static final Pattern characterClassStartPattern = Pattern
- .compile("\\[[.:=]");
+ .compile("\\[[.:=]"); //$NON-NLS-1$
private List<Head> headsStartValue;
int firstValidEndBracketIndex = indexOfStartBracket + 2;
if (indexOfStartBracket + 1 >= pattern.length())
- throw new NoClosingBracketException(indexOfStartBracket, "[", "]",
+ throw new NoClosingBracketException(indexOfStartBracket, "[", "]", //$NON-NLS-1$ //$NON-NLS-2$
pattern);
if (pattern.charAt(firstValidCharClassIndex) == '!') {
final int possibleGroupEnd = pattern.indexOf(']',
firstValidEndBracketIndex);
if (possibleGroupEnd == -1)
- throw new NoClosingBracketException(indexOfStartBracket, "[",
- "]", pattern);
+ throw new NoClosingBracketException(indexOfStartBracket, "[", //$NON-NLS-1$
+ "]", pattern); //$NON-NLS-1$
final boolean foundCharClass = charClassStartMatcher
.find(firstValidCharClassIndex);
&& charClassStartMatcher.start() < possibleGroupEnd) {
final String classStart = charClassStartMatcher.group(0);
- final String classEnd = classStart.charAt(1) + "]";
+ final String classEnd = classStart.charAt(1) + "]"; //$NON-NLS-1$
final int classStartIndex = charClassStartMatcher.start();
final int classEndIndex = pattern.indexOf(classEnd,
private final List<CharacterPattern> characterClasses;
private static final Pattern REGEX_PATTERN = Pattern
- .compile("([^-][-][^-]|\\[[.:=].*?[.:=]\\])");
+ .compile("([^-][-][^-]|\\[[.:=].*?[.:=]\\])"); //$NON-NLS-1$
private final boolean inverse;
throws InvalidPatternException {
super(false);
this.characterClasses = new ArrayList<CharacterPattern>();
- this.inverse = pattern.startsWith("!");
+ this.inverse = pattern.startsWith("!"); //$NON-NLS-1$
if (inverse) {
pattern = pattern.substring(1);
}
final char start = characterClass.charAt(0);
final char end = characterClass.charAt(2);
characterClasses.add(new CharacterRange(start, end));
- } else if (characterClass.equals("[:alnum:]")) {
+ } else if (characterClass.equals("[:alnum:]")) { //$NON-NLS-1$
characterClasses.add(LetterPattern.INSTANCE);
characterClasses.add(DigitPattern.INSTANCE);
- } else if (characterClass.equals("[:alpha:]")) {
+ } else if (characterClass.equals("[:alpha:]")) { //$NON-NLS-1$
characterClasses.add(LetterPattern.INSTANCE);
- } else if (characterClass.equals("[:blank:]")) {
+ } else if (characterClass.equals("[:blank:]")) { //$NON-NLS-1$
characterClasses.add(new OneCharacterPattern(' '));
characterClasses.add(new OneCharacterPattern('\t'));
- } else if (characterClass.equals("[:cntrl:]")) {
+ } else if (characterClass.equals("[:cntrl:]")) { //$NON-NLS-1$
characterClasses.add(new CharacterRange('\u0000', '\u001F'));
characterClasses.add(new OneCharacterPattern('\u007F'));
- } else if (characterClass.equals("[:digit:]")) {
+ } else if (characterClass.equals("[:digit:]")) { //$NON-NLS-1$
characterClasses.add(DigitPattern.INSTANCE);
- } else if (characterClass.equals("[:graph:]")) {
+ } else if (characterClass.equals("[:graph:]")) { //$NON-NLS-1$
characterClasses.add(new CharacterRange('\u0021', '\u007E'));
characterClasses.add(LetterPattern.INSTANCE);
characterClasses.add(DigitPattern.INSTANCE);
- } else if (characterClass.equals("[:lower:]")) {
+ } else if (characterClass.equals("[:lower:]")) { //$NON-NLS-1$
characterClasses.add(LowerPattern.INSTANCE);
- } else if (characterClass.equals("[:print:]")) {
+ } else if (characterClass.equals("[:print:]")) { //$NON-NLS-1$
characterClasses.add(new CharacterRange('\u0020', '\u007E'));
characterClasses.add(LetterPattern.INSTANCE);
characterClasses.add(DigitPattern.INSTANCE);
- } else if (characterClass.equals("[:punct:]")) {
+ } else if (characterClass.equals("[:punct:]")) { //$NON-NLS-1$
characterClasses.add(PunctPattern.INSTANCE);
- } else if (characterClass.equals("[:space:]")) {
+ } else if (characterClass.equals("[:space:]")) { //$NON-NLS-1$
characterClasses.add(WhitespacePattern.INSTANCE);
- } else if (characterClass.equals("[:upper:]")) {
+ } else if (characterClass.equals("[:upper:]")) { //$NON-NLS-1$
characterClasses.add(UpperPattern.INSTANCE);
- } else if (characterClass.equals("[:xdigit:]")) {
+ } else if (characterClass.equals("[:xdigit:]")) { //$NON-NLS-1$
characterClasses.add(new CharacterRange('0', '9'));
characterClasses.add(new CharacterRange('a', 'f'));
characterClasses.add(new CharacterRange('A', 'F'));
- } else if (characterClass.equals("[:word:]")) {
+ } else if (characterClass.equals("[:word:]")) { //$NON-NLS-1$
characterClasses.add(new OneCharacterPattern('_'));
characterClasses.add(LetterPattern.INSTANCE);
characterClasses.add(DigitPattern.INSTANCE);
throw new InvalidPatternException(message, wholePattern);
}
- pattern = matcher.replaceFirst("");
+ pattern = matcher.replaceFirst(""); //$NON-NLS-1$
matcher.reset(pattern);
}
// pattern contains now no ranges
private static final class PunctPattern implements CharacterPattern {
static final GroupHead.PunctPattern INSTANCE = new PunctPattern();
- private static String punctCharacters = "-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~";
+ private static String punctCharacters = "-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~"; //$NON-NLS-1$
public boolean matches(char c) {
return punctCharacters.indexOf(c) != -1;
String txt;
while ((txt = br.readLine()) != null) {
txt = txt.trim();
- if (txt.length() > 0 && !txt.startsWith("#"))
+ if (txt.length() > 0 && !txt.startsWith("#")) //$NON-NLS-1$
rules.add(new IgnoreRule(txt));
}
}
private void setup() {
int startIndex = 0;
int endIndex = pattern.length();
- if (pattern.startsWith("!")) {
+ if (pattern.startsWith("!")) { //$NON-NLS-1$
startIndex++;
negation = true;
}
- if (pattern.endsWith("/")) {
+ if (pattern.endsWith("/")) { //$NON-NLS-1$
endIndex --;
dirOnly = true;
}
pattern = pattern.substring(startIndex, endIndex);
- boolean hasSlash = pattern.contains("/");
+ boolean hasSlash = pattern.contains("/"); //$NON-NLS-1$
if (!hasSlash)
nameOnly = true;
- else if (!pattern.startsWith("/")) {
+ else if (!pattern.startsWith("/")) { //$NON-NLS-1$
//Contains "/" but does not start with one
//Adding / to the start should not interfere with matching
- pattern = "/" + pattern;
+ pattern = "/" + pattern; //$NON-NLS-1$
}
- if (pattern.contains("*") || pattern.contains("?") || pattern.contains("[")) {
+ if (pattern.contains("*") || pattern.contains("?") || pattern.contains("[")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
try {
matcher = new FileNameMatcher(pattern, Character.valueOf('/'));
} catch (InvalidPatternException e) {
* the target is ignored. Call {@link IgnoreRule#getResult() getResult()} for the result.
*/
public boolean isMatch(String target, boolean isDirectory) {
- if (!target.startsWith("/"))
- target = "/" + target;
+ if (!target.startsWith("/")) //$NON-NLS-1$
+ target = "/" + target; //$NON-NLS-1$
if (matcher == null) {
if (target.equals(pattern)) {
* "/src/new" to /src/newfile" but allows "/src/new" to match
* "/src/new/newfile", as is the git standard
*/
- if ((target).startsWith(pattern + "/"))
+ if ((target).startsWith(pattern + "/")) //$NON-NLS-1$
return true;
if (nameOnly) {
//Iterate through each sub-name
- final String[] segments = target.split("/");
+ final String[] segments = target.split("/"); //$NON-NLS-1$
for (int idx = 0; idx < segments.length; idx++) {
final String segmentName = segments[idx];
if (segmentName.equals(pattern) &&
if (matcher.isMatch())
return true;
- final String[] segments = target.split("/");
+ final String[] segments = target.split("/"); //$NON-NLS-1$
if (nameOnly) {
for (int idx = 0; idx < segments.length; idx++) {
final String segmentName = segments[idx];
for (int idx = 0; idx < segments.length; idx++) {
final String segmentName = segments[idx];
if (segmentName.length() > 0) {
- matcher.append("/" + segmentName);
+ matcher.append("/" + segmentName); //$NON-NLS-1$
}
if (matcher.isMatch() &&
return new String(b, 0, nibbles);
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
- return "AbbreviatedObjectId[" + name() + "]";
+ return "AbbreviatedObjectId[" + name() + "]"; //$NON-NLS-1$
}
}
dst[o--] = '0';
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "AnyObjectId[" + name() + "]";
*/
public B findGitDir() {
if (getGitDir() == null)
- findGitDir(new File("").getAbsoluteFile());
+ findGitDir(new File("").getAbsoluteFile()); //$NON-NLS-1$
return self();
}
if (getGitDir() == null)
setGitDir(getWorkTree().getParentFile());
if (getIndexFile() == null)
- setIndexFile(new File(getGitDir(), "index"));
+ setIndexFile(new File(getGitDir(), "index")); //$NON-NLS-1$
}
}
*/
protected void setupInternals() throws IOException {
if (getObjectDirectory() == null && getGitDir() != null)
- setObjectDirectory(safeFS().resolve(getGitDir(), "objects"));
+ setObjectDirectory(safeFS().resolve(getGitDir(), "objects")); //$NON-NLS-1$
}
/**
if (msg == null && !appendStatus)
disableRefLog();
else if (msg == null && appendStatus) {
- refLogMessage = "";
+ refLogMessage = ""; //$NON-NLS-1$
refLogIncludeResult = true;
} else {
refLogMessage = msg;
public Thread newThread(Runnable taskBody) {
Thread thr = baseFactory.newThread(taskBody);
- thr.setName("JGit-AlarmQueue");
+ thr.setName("JGit-AlarmQueue"); //$NON-NLS-1$
thr.setDaemon(true);
return thr;
}
if (remote == null || mergeRef == null)
return null;
- if (remote.equals("."))
+ if (remote.equals(".")) //$NON-NLS-1$
return mergeRef;
return findRemoteTrackingBranch(remote, mergeRef);
public class CommitBuilder {
private static final ObjectId[] EMPTY_OBJECTID_LIST = new ObjectId[0];
- private static final byte[] htree = Constants.encodeASCII("tree");
+ private static final byte[] htree = Constants.encodeASCII("tree"); //$NON-NLS-1$
- private static final byte[] hparent = Constants.encodeASCII("parent");
+ private static final byte[] hparent = Constants.encodeASCII("parent"); //$NON-NLS-1$
- private static final byte[] hauthor = Constants.encodeASCII("author");
+ private static final byte[] hauthor = Constants.encodeASCII("author"); //$NON-NLS-1$
- private static final byte[] hcommitter = Constants.encodeASCII("committer");
+ private static final byte[] hcommitter = Constants.encodeASCII("committer"); //$NON-NLS-1$
- private static final byte[] hencoding = Constants.encodeASCII("encoding");
+ private static final byte[] hencoding = Constants.encodeASCII("encoding"); //$NON-NLS-1$
private ObjectId treeId;
return build();
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder r = new StringBuilder();
r.append('"');
inquote = false;
}
- r.append("\\n\\\n");
+ r.append("\\n\\\n"); //$NON-NLS-1$
lineStart = r.length();
break;
case '\t':
- r.append("\\t");
+ r.append("\\t"); //$NON-NLS-1$
break;
case '\b':
- r.append("\\b");
+ r.append("\\b"); //$NON-NLS-1$
break;
case '\\':
- r.append("\\\\");
+ r.append("\\\\"); //$NON-NLS-1$
break;
case '"':
- r.append("\\\"");
+ r.append("\\\""); //$NON-NLS-1$
break;
case ';':
@SuppressWarnings("unchecked")
private static <T> T[] allValuesOf(final T value) {
try {
- return (T[]) value.getClass().getMethod("values").invoke(null);
+ return (T[]) value.getClass().getMethod("values").invoke(null); //$NON-NLS-1$
} catch (Exception err) {
String typeName = value.getClass().getName();
String msg = MessageFormat.format(
for (T e : all) {
if (StringUtils.equalsIgnoreCase(e.name(), n))
return e;
- else if (StringUtils.equalsIgnoreCase(e.name(), "TRUE"))
+ else if (StringUtils.equalsIgnoreCase(e.name(), "TRUE")) //$NON-NLS-1$
trueState = e;
- else if (StringUtils.equalsIgnoreCase(e.name(), "FALSE"))
+ else if (StringUtils.equalsIgnoreCase(e.name(), "FALSE")) //$NON-NLS-1$
falseState = e;
}
final String s;
if (value >= GiB && (value % GiB) == 0)
- s = String.valueOf(value / GiB) + " g";
+ s = String.valueOf(value / GiB) + " g"; //$NON-NLS-1$
else if (value >= MiB && (value % MiB) == 0)
- s = String.valueOf(value / MiB) + " m";
+ s = String.valueOf(value / MiB) + " m"; //$NON-NLS-1$
else if (value >= KiB && (value % KiB) == 0)
- s = String.valueOf(value / KiB) + " k";
+ s = String.valueOf(value / KiB) + " k"; //$NON-NLS-1$
else
s = String.valueOf(value);
*/
public void setBoolean(final String section, final String subsection,
final String name, final boolean value) {
- setString(section, subsection, name, value ? "true" : "false");
+ setString(section, subsection, name, value ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
out.append(' ');
String escaped = escapeValue(e.subsection);
// make sure to avoid double quotes here
- boolean quoted = escaped.startsWith("\"")
- && escaped.endsWith("\"");
+ boolean quoted = escaped.startsWith("\"") //$NON-NLS-1$
+ && escaped.endsWith("\""); //$NON-NLS-1$
if (!quoted)
out.append('"');
out.append(escaped);
}
out.append(']');
} else if (e.section != null && e.name != null) {
- if (e.prefix == null || "".equals(e.prefix))
+ if (e.prefix == null || "".equals(e.prefix)) //$NON-NLS-1$
out.append('\t');
out.append(e.name);
if (MAGIC_EMPTY_VALUE != e.value) {
- out.append(" =");
+ out.append(" ="); //$NON-NLS-1$
if (e.value != null) {
out.append(' ');
out.append(escapeValue(e.value));
} else if (e.section == null && Character.isWhitespace(c)) {
// Save the leading whitespace (if any).
if (e.prefix == null)
- e.prefix = "";
+ e.prefix = ""; //$NON-NLS-1$
e.prefix += c;
} else if ('[' == c) {
}
if (']' != input)
throw new ConfigInvalidException(JGitText.get().badGroupHeader);
- e.suffix = "";
+ e.suffix = ""; //$NON-NLS-1$
} else if (last != null) {
// Read a value.
e.subsection = last.subsection;
in.reset();
e.name = readKeyName(in);
- if (e.name.endsWith("\n")) {
+ if (e.name.endsWith("\n")) { //$NON-NLS-1$
e.name = e.name.substring(0, e.name.length() - 1);
e.value = MAGIC_EMPTY_VALUE;
} else
* Constants for use with the Configuration classes: section names,
* configuration keys
*/
+@SuppressWarnings("nls")
public class ConfigConstants {
/** The "core" section */
public static final String CONFIG_CORE_SECTION = "core";
return a.equals(b);
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
if (section == null)
Set<String> getNames(String section, String subsection) {
List<ConfigLine> s = sorted();
- int idx = find(s, section, subsection, "");
+ int idx = find(s, section, subsection, ""); //$NON-NLS-1$
if (idx < 0)
idx = -(idx + 1);
import org.eclipse.jgit.util.MutableInteger;
/** Misc. constants used throughout JGit. */
+@SuppressWarnings("nls")
public final class Constants {
/** Hash function used natively by Git for all objects. */
private static final String HASH_FUNCTION = "SHA-1";
public String toString() {
final StringBuilder r = new StringBuilder();
r.append(ObjectId.toString(getId()));
- r.append(" G ");
+ r.append(" G "); //$NON-NLS-1$
r.append(getFullName());
return r.toString();
}
* @throws IOException
*/
public boolean diff() throws IOException {
- return diff(null, 0, 0, "");
+ return diff(null, 0, 0, ""); //$NON-NLS-1$
}
/**
*/
public class ObjectChecker {
/** Header "tree " */
- public static final byte[] tree = Constants.encodeASCII("tree ");
+ public static final byte[] tree = Constants.encodeASCII("tree "); //$NON-NLS-1$
/** Header "parent " */
- public static final byte[] parent = Constants.encodeASCII("parent ");
+ public static final byte[] parent = Constants.encodeASCII("parent "); //$NON-NLS-1$
/** Header "author " */
- public static final byte[] author = Constants.encodeASCII("author ");
+ public static final byte[] author = Constants.encodeASCII("author "); //$NON-NLS-1$
/** Header "committer " */
- public static final byte[] committer = Constants.encodeASCII("committer ");
+ public static final byte[] committer = Constants.encodeASCII("committer "); //$NON-NLS-1$
/** Header "encoding " */
- public static final byte[] encoding = Constants.encodeASCII("encoding ");
+ public static final byte[] encoding = Constants.encodeASCII("encoding "); //$NON-NLS-1$
/** Header "object " */
- public static final byte[] object = Constants.encodeASCII("object ");
+ public static final byte[] object = Constants.encodeASCII("object "); //$NON-NLS-1$
/** Header "type " */
- public static final byte[] type = Constants.encodeASCII("type ");
+ public static final byte[] type = Constants.encodeASCII("type "); //$NON-NLS-1$
/** Header "tag " */
- public static final byte[] tag = Constants.encodeASCII("tag ");
+ public static final byte[] tag = Constants.encodeASCII("tag "); //$NON-NLS-1$
/** Header "tagger " */
- public static final byte[] tagger = Constants.encodeASCII("tagger ");
+ public static final byte[] tagger = Constants.encodeASCII("tagger "); //$NON-NLS-1$
private final MutableObjectId tempId = new MutableObjectId();
@Override
public String toString() {
StringBuilder r = new StringBuilder();
- r.append("Ref[");
+ r.append("Ref["); //$NON-NLS-1$
r.append(getName());
r.append('=');
r.append(ObjectId.toString(getObjectId()));
*/
public TimeZone getTimeZone() {
StringBuilder tzId = new StringBuilder(8);
- tzId.append("GMT");
+ tzId.append("GMT"); //$NON-NLS-1$
appendTimezone(tzId);
return TimeZone.getTimeZone(tzId.toString());
}
public String toExternalString() {
final StringBuilder r = new StringBuilder();
r.append(getName());
- r.append(" <");
+ r.append(" <"); //$NON-NLS-1$
r.append(getEmailAddress());
- r.append("> ");
+ r.append("> "); //$NON-NLS-1$
r.append(when / 1000);
r.append(' ');
appendTimezone(r);
r.append(offsetMins);
}
+ @SuppressWarnings("nls")
public String toString() {
final StringBuilder r = new StringBuilder();
final SimpleDateFormat dtfmt;
source = src;
destination = dst;
- String cmd = "";
+ String cmd = ""; //$NON-NLS-1$
if (source.getName().startsWith(Constants.R_HEADS)
&& destination.getName().startsWith(Constants.R_HEADS))
- cmd = "Branch: ";
- setRefLogMessage(cmd + "renamed "
- + Repository.shortenRefName(source.getName()) + " to "
+ cmd = "Branch: "; //$NON-NLS-1$
+ setRefLogMessage(cmd + "renamed " //$NON-NLS-1$
+ + Repository.shortenRefName(source.getName()) + " to " //$NON-NLS-1$
+ Repository.shortenRefName(destination.getName()));
}
/** Don't record this rename in the ref's associated reflog. */
public void disableRefLog() {
- destination.setRefLogMessage("", false);
+ destination.setRefLogMessage("", false); //$NON-NLS-1$
}
/**
protected RefUpdate(final Ref ref) {
this.ref = ref;
oldValue = ref.getObjectId();
- refLogMessage = "";
+ refLogMessage = ""; //$NON-NLS-1$
}
/** @return the reference database this update modifies. */
if (msg == null && !appendStatus)
disableRefLog();
else if (msg == null && appendStatus) {
- refLogMessage = "";
+ refLogMessage = ""; //$NON-NLS-1$
refLogIncludeResult = true;
} else {
refLogMessage = msg;
r.getPeeledObjectId().copyTo(tmp, w);
w.write('\t');
w.write(r.getName());
- w.write("^{}\n");
+ w.write("^{}\n"); //$NON-NLS-1$
}
}
writeFile(Constants.INFO_REFS, Constants.encode(w.toString()));
}
i = k;
if (item != null)
- if (item.equals("tree")) {
+ if (item.equals("tree")) { //$NON-NLS-1$
rev = rw.parseTree(rev);
- } else if (item.equals("commit")) {
+ } else if (item.equals("commit")) { //$NON-NLS-1$
rev = rw.parseCommit(rev);
- } else if (item.equals("blob")) {
+ } else if (item.equals("blob")) { //$NON-NLS-1$
rev = rw.peel(rev);
if (!(rev instanceof RevBlob))
throw new IncorrectObjectTypeException(rev,
Constants.TYPE_BLOB);
- } else if (item.equals("")) {
+ } else if (item.equals("")) { //$NON-NLS-1$
rev = rw.peel(rev);
} else
throw new RevisionSyntaxException(revstr);
}
}
if (time != null) {
- if (time.equals("upstream")) {
+ if (time.equals("upstream")) { //$NON-NLS-1$
if (name == null)
name = new String(revChars, done, i);
- if (name.equals(""))
+ if (name.equals("")) //$NON-NLS-1$
// Currently checked out branch, HEAD if
// detached
name = Constants.HEAD;
- if (!Repository.isValidRefName("x/" + name))
+ if (!Repository.isValidRefName("x/" + name)) //$NON-NLS-1$
throw new RevisionSyntaxException(revstr);
Ref ref = getRef(name);
name = null;
RemoteConfig remoteConfig;
try {
remoteConfig = new RemoteConfig(getConfig(),
- "origin");
+ "origin"); //$NON-NLS-1$
} catch (URISyntaxException e) {
throw new RevisionSyntaxException(revstr);
}
}
if (name == null)
throw new RevisionSyntaxException(revstr);
- } else if (time.matches("^-\\d+$")) {
+ } else if (time.matches("^-\\d+$")) { //$NON-NLS-1$
if (name != null)
throw new RevisionSyntaxException(revstr);
else {
} else {
if (name == null)
name = new String(revChars, done, i);
- if (name.equals(""))
+ if (name.equals("")) //$NON-NLS-1$
name = Constants.HEAD;
- if (!Repository.isValidRefName("x/" + name))
+ if (!Repository.isValidRefName("x/" + name)) //$NON-NLS-1$
throw new RevisionSyntaxException(revstr);
Ref ref = getRef(name);
name = null;
if (rev == null) {
if (name == null)
name = new String(revChars, done, i);
- if (name.equals(""))
+ if (name.equals("")) //$NON-NLS-1$
name = Constants.HEAD;
rev = parseSimple(rw, name);
name = null;
if (done == revstr.length())
return null;
name = revstr.substring(done);
- if (!Repository.isValidRefName("x/" + name))
+ if (!Repository.isValidRefName("x/" + name)) //$NON-NLS-1$
throw new RevisionSyntaxException(revstr);
if (getRef(name) != null)
return name;
if (ObjectId.isId(revstr))
return ObjectId.fromString(revstr);
- if (Repository.isValidRefName("x/" + revstr)) {
+ if (Repository.isValidRefName("x/" + revstr)) { //$NON-NLS-1$
Ref r = getRefDatabase().getRef(revstr);
if (r != null)
return r.getObjectId();
if (AbbreviatedObjectId.isId(revstr))
return resolveAbbreviation(revstr);
- int dashg = revstr.indexOf("-g");
+ int dashg = revstr.indexOf("-g"); //$NON-NLS-1$
if ((dashg + 5) < revstr.length() && 0 <= dashg
&& isHex(revstr.charAt(dashg + 2))
&& isHex(revstr.charAt(dashg + 3))
getRefDatabase().close();
}
+ @SuppressWarnings("nls")
public String toString() {
String desc;
if (getDirectory() != null)
desc = getDirectory().getPath();
else
- desc = getClass().getSimpleName() + "-"
+ desc = getClass().getSimpleName() + "-" //$NON-NLS-1$
+ System.identityHashCode(this);
- return "Repository[" + desc + "]";
+ return "Repository[" + desc + "]"; //$NON-NLS-1$
}
/**
return RepositoryState.BARE;
// Pre Git-1.6 logic
- if (new File(getWorkTree(), ".dotest").exists())
+ if (new File(getWorkTree(), ".dotest").exists()) //$NON-NLS-1$
return RepositoryState.REBASING;
- if (new File(getDirectory(), ".dotest-merge").exists())
+ if (new File(getDirectory(), ".dotest-merge").exists()) //$NON-NLS-1$
return RepositoryState.REBASING_INTERACTIVE;
// From 1.6 onwards
- if (new File(getDirectory(),"rebase-apply/rebasing").exists())
+ if (new File(getDirectory(),"rebase-apply/rebasing").exists()) //$NON-NLS-1$
return RepositoryState.REBASING_REBASING;
- if (new File(getDirectory(),"rebase-apply/applying").exists())
+ if (new File(getDirectory(),"rebase-apply/applying").exists()) //$NON-NLS-1$
return RepositoryState.APPLY;
- if (new File(getDirectory(),"rebase-apply").exists())
+ if (new File(getDirectory(),"rebase-apply").exists()) //$NON-NLS-1$
return RepositoryState.REBASING;
- if (new File(getDirectory(),"rebase-merge/interactive").exists())
+ if (new File(getDirectory(),"rebase-merge/interactive").exists()) //$NON-NLS-1$
return RepositoryState.REBASING_INTERACTIVE;
- if (new File(getDirectory(),"rebase-merge").exists())
+ if (new File(getDirectory(),"rebase-merge").exists()) //$NON-NLS-1$
return RepositoryState.REBASING_MERGE;
// Both versions
return RepositoryState.MERGING;
}
- if (new File(getDirectory(), "BISECT_LOG").exists())
+ if (new File(getDirectory(), "BISECT_LOG").exists()) //$NON-NLS-1$
return RepositoryState.BISECTING;
if (new File(getDirectory(), Constants.CHERRY_PICK_HEAD).exists()) {
final int len = refName.length();
if (len == 0)
return false;
- if (refName.endsWith(".lock"))
+ if (refName.endsWith(".lock")) //$NON-NLS-1$
return false;
int components = 1;
File absWd = workDir.isAbsolute() ? workDir : workDir.getAbsoluteFile();
File absFile = file.isAbsolute() ? file : file.getAbsoluteFile();
if (absWd == workDir && absFile == file)
- return "";
+ return ""; //$NON-NLS-1$
return stripWorkDir(absWd, absFile);
}
* Git directory.
*/
public static boolean isGitRepository(final File dir, FS fs) {
- return fs.resolve(dir, "objects").exists()
- && fs.resolve(dir, "refs").exists()
+ return fs.resolve(dir, "objects").exists() //$NON-NLS-1$
+ && fs.resolve(dir, "refs").exists() //$NON-NLS-1$
&& isValidHead(new File(dir, Constants.HEAD));
}
private static boolean isValidHead(final File head) {
final String ref = readFirstLine(head);
return ref != null
- && (ref.startsWith("ref: refs/") || ObjectId.isId(ref));
+ && (ref.startsWith("ref: refs/") || ObjectId.isId(ref)); //$NON-NLS-1$
}
private static String readFirstLine(final File head) {
return getLeaf().isPeeled();
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder r = new StringBuilder();
public String toString() {
final StringBuilder r = new StringBuilder();
r.append(ObjectId.toString(getId()));
- r.append(" S ");
+ r.append(" S "); //$NON-NLS-1$
r.append(getFullName());
return r.toString();
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
OutputStreamWriter w = new OutputStreamWriter(os, Constants.CHARSET);
try {
- w.write("object ");
+ w.write("object "); //$NON-NLS-1$
getObjectId().copyTo(w);
w.write('\n');
- w.write("type ");
+ w.write("type "); //$NON-NLS-1$
w.write(Constants.typeString(getObjectType()));
- w.write("\n");
+ w.write("\n"); //$NON-NLS-1$
- w.write("tag ");
+ w.write("tag "); //$NON-NLS-1$
w.write(getTag());
- w.write("\n");
+ w.write("\n"); //$NON-NLS-1$
if (getTagger() != null) {
- w.write("tagger ");
+ w.write("tagger "); //$NON-NLS-1$
w.write(getTagger().toExternalString());
w.write('\n');
}
return build();
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder r = new StringBuilder();
protected void onEndTask(String taskName, int workCurr) {
StringBuilder s = new StringBuilder();
format(s, taskName, workCurr);
- s.append("\n");
+ s.append("\n"); //$NON-NLS-1$
send(s);
}
private void format(StringBuilder s, String taskName, int workCurr) {
- s.append("\r");
+ s.append("\r"); //$NON-NLS-1$
s.append(taskName);
- s.append(": ");
+ s.append(": "); //$NON-NLS-1$
while (s.length() < 25)
s.append(' ');
s.append(workCurr);
protected void onEndTask(String taskName, int cmp, int totalWork, int pcnt) {
StringBuilder s = new StringBuilder();
format(s, taskName, cmp, totalWork, pcnt);
- s.append("\n");
+ s.append("\n"); //$NON-NLS-1$
send(s);
}
private void format(StringBuilder s, String taskName, int cmp,
int totalWork, int pcnt) {
- s.append("\r");
+ s.append("\r"); //$NON-NLS-1$
s.append(taskName);
- s.append(": ");
+ s.append(": "); //$NON-NLS-1$
while (s.length() < 25)
s.append(' ');
String endStr = String.valueOf(totalWork);
String curStr = String.valueOf(cmp);
while (curStr.length() < endStr.length())
- curStr = " " + curStr;
+ curStr = " " + curStr; //$NON-NLS-1$
if (pcnt < 100)
s.append(' ');
if (pcnt < 10)
s.append(' ');
s.append(pcnt);
- s.append("% (");
+ s.append("% ("); //$NON-NLS-1$
s.append(curStr);
- s.append("/");
+ s.append("/"); //$NON-NLS-1$
s.append(endStr);
- s.append(")");
+ s.append(")"); //$NON-NLS-1$
}
private void send(StringBuilder s) {
public String toString() {
final StringBuilder r = new StringBuilder();
r.append(ObjectId.toString(getId()));
- r.append(" T ");
+ r.append(" T "); //$NON-NLS-1$
r.append(getFullName());
return r.toString();
}
}
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
byte[] raw = toByteArray();
private static String getNameInternal(Config rc, String envKey) {
// try to get the user name from the local and global configurations.
- String username = rc.getString("user", null, "name");
+ String username = rc.getString("user", null, "name"); //$NON-NLS-1$ //$NON-NLS-2$
if (username == null) {
// try to get the user name for the system property GIT_XXX_NAME
private static String getEmailInternal(Config rc, String envKey) {
// try to get the email from the local and global configurations.
- String email = rc.getString("user", null, "email");
+ String email = rc.getString("user", null, "email"); //$NON-NLS-1$ //$NON-NLS-2$
if (email == null) {
// try to get the email for the system property GIT_XXX_EMAIL
private static String getDefaultEmail() {
// try to construct an email
String username = getDefaultUserName();
- return username + "@" + system().getHostname();
+ return username + "@" + system().getHostname(); //$NON-NLS-1$
}
private static SystemReader system() {
if (lastConflictingName != null
&& chunk.getConflictState() != ConflictState.NEXT_CONFLICTING_RANGE) {
// found the end of an conflict
- out.write((">>>>>>> " + lastConflictingName + "\n").getBytes(charsetName));
+ out.write((">>>>>>> " + lastConflictingName + "\n").getBytes(charsetName)); //$NON-NLS-1$ //$NON-NLS-2$
lastConflictingName = null;
}
if (chunk.getConflictState() == ConflictState.FIRST_CONFLICTING_RANGE) {
// found the start of an conflict
- out.write(("<<<<<<< " + seqName.get(chunk.getSequenceIndex()) +
- "\n").getBytes(charsetName));
+ out.write(("<<<<<<< " + seqName.get(chunk.getSequenceIndex()) + //$NON-NLS-1$
+ "\n").getBytes(charsetName)); //$NON-NLS-1$
lastConflictingName = seqName.get(chunk.getSequenceIndex());
} else if (chunk.getConflictState() == ConflictState.NEXT_CONFLICTING_RANGE) {
// found another conflicting chunk
* present non-three-way merges - feel free to correct here.
*/
lastConflictingName = seqName.get(chunk.getSequenceIndex());
- out.write((threeWayMerge ? "=======\n" : "======= "
- + lastConflictingName + "\n").getBytes(charsetName));
+ out.write((threeWayMerge ? "=======\n" : "======= " //$NON-NLS-1$ //$NON-NLS-2$
+ + lastConflictingName + "\n").getBytes(charsetName)); //$NON-NLS-1$
}
// the lines with conflict-metadata are written. Now write the chunk
for (int i = chunk.getBegin(); i < chunk.getEnd(); i++) {
// one possible leftover: if the merge result ended with a conflict we
// have to close the last conflict here
if (lastConflictingName != null) {
- out.write((">>>>>>> " + lastConflictingName + "\n").getBytes(charsetName));
+ out.write((">>>>>>> " + lastConflictingName + "\n").getBytes(charsetName)); //$NON-NLS-1$ //$NON-NLS-2$
}
}
*/
public String format(List<Ref> refsToMerge, Ref target) {
StringBuilder sb = new StringBuilder();
- sb.append("Merge ");
+ sb.append("Merge "); //$NON-NLS-1$
List<String> branches = new ArrayList<String>();
List<String> remoteBranches = new ArrayList<String>();
List<String> others = new ArrayList<String>();
for (Ref ref : refsToMerge) {
if (ref.getName().startsWith(Constants.R_HEADS))
- branches.add("'" + Repository.shortenRefName(ref.getName())
- + "'");
+ branches.add("'" + Repository.shortenRefName(ref.getName()) //$NON-NLS-1$
+ + "'"); //$NON-NLS-1$
else if (ref.getName().startsWith(Constants.R_REMOTES))
- remoteBranches.add("'"
- + Repository.shortenRefName(ref.getName()) + "'");
+ remoteBranches.add("'" //$NON-NLS-1$
+ + Repository.shortenRefName(ref.getName()) + "'"); //$NON-NLS-1$
else if (ref.getName().startsWith(Constants.R_TAGS))
- tags.add("'" + Repository.shortenRefName(ref.getName()) + "'");
+ tags.add("'" + Repository.shortenRefName(ref.getName()) + "'"); //$NON-NLS-1$ //$NON-NLS-2$
else if (ref.getName().equals(ref.getObjectId().getName()))
- commits.add("'" + ref.getName() + "'");
+ commits.add("'" + ref.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
else
others.add(ref.getName());
listings.add(joinNames(commits, "commit", "commits"));
if (!others.isEmpty())
- listings.add(StringUtils.join(others, ", ", " and "));
+ listings.add(StringUtils.join(others, ", ", " and ")); //$NON-NLS-1$
- sb.append(StringUtils.join(listings, ", "));
+ sb.append(StringUtils.join(listings, ", ")); //$NON-NLS-1$
String targetName = target.getLeaf().getName();
if (!targetName.equals(Constants.R_HEADS + Constants.MASTER)) {
public String formatWithConflicts(String message,
List<String> conflictingPaths) {
StringBuilder sb = new StringBuilder(message);
- if (!message.endsWith("\n") && message.length() != 0)
- sb.append("\n");
- sb.append("\n");
+ if (!message.endsWith("\n") && message.length() != 0) //$NON-NLS-1$
+ sb.append("\n"); //$NON-NLS-1$
+ sb.append("\n"); //$NON-NLS-1$
sb.append("Conflicts:\n");
for (String conflictingPath : conflictingPaths)
sb.append('\t').append(conflictingPath).append('\n');
private static String joinNames(List<String> names, String singular,
String plural) {
if (names.size() == 1)
- return singular + " " + names.get(0);
+ return singular + " " + names.get(0); //$NON-NLS-1$
else
- return plural + " " + StringUtils.join(names, ", ", " and ");
+ return plural + " " + StringUtils.join(names, ", ", " and "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
*/
public abstract class MergeStrategy {
/** Simple strategy that sets the output tree to the first input tree. */
- public static final MergeStrategy OURS = new StrategyOneSided("ours", 0);
+ public static final MergeStrategy OURS = new StrategyOneSided("ours", 0); //$NON-NLS-1$
/** Simple strategy that sets the output tree to the second input tree. */
- public static final MergeStrategy THEIRS = new StrategyOneSided("theirs", 1);
+ public static final MergeStrategy THEIRS = new StrategyOneSided("theirs", 1); //$NON-NLS-1$
/** Simple strategy to merge paths, without simultaneous edits. */
public static final ThreeWayMergeStrategy SIMPLE_TWO_WAY_IN_CORE = new StrategySimpleTwoWayInCore();
} else if (!result.containsConflicts()) {
// When working inCore, only trivial merges can be handled,
// so we generate objects only in conflict free cases
- of = File.createTempFile("merge_", "_temp", null);
+ of = File.createTempFile("merge_", "_temp", null); //$NON-NLS-1$ //$NON-NLS-2$
fos = new FileOutputStream(of);
try {
fmt.formatMerge(fos, result, Arrays.asList(commitNames),
for (RevCommit c : squashedCommits) {
sb.append("\ncommit ");
sb.append(c.getName());
- sb.append("\n");
+ sb.append("\n"); //$NON-NLS-1$
sb.append(toString(c.getAuthorIdent()));
- sb.append("\n\t");
+ sb.append("\n\t"); //$NON-NLS-1$
sb.append(c.getShortMessage());
- sb.append("\n");
+ sb.append("\n"); //$NON-NLS-1$
}
return sb.toString();
}
a.append("Author: ");
a.append(author.getName());
- a.append(" <");
+ a.append(" <"); //$NON-NLS-1$
a.append(author.getEmailAddress());
- a.append(">\n");
+ a.append(">\n"); //$NON-NLS-1$
a.append("Date: ");
a.append(dateFormatter.formatDate(author));
- a.append("\n");
+ a.append("\n"); //$NON-NLS-1$
return a.toString();
}
@Override
public String getName() {
- return "resolve";
+ return "resolve"; //$NON-NLS-1$
}
}
\ No newline at end of file
@Override
public String getName() {
- return "simple-two-way-in-core";
+ return "simple-two-way-in-core"; //$NON-NLS-1$
}
@Override
*/
public class NLS {
/** The root locale constant. It is defined here because the Locale.ROOT is not defined in Java 5 */
- public static final Locale ROOT_LOCALE = new Locale("", "", "");
+ public static final Locale ROOT_LOCALE = new Locale("", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
private static final InheritableThreadLocal<NLS> local = new InheritableThreadLocal<NLS>() {
protected NLS initialValue() {
data = newData;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "Note[" + name() + " -> " + data.name() + "]";
private void load(ObjectId rootTree) throws MissingObjectException,
IncorrectObjectTypeException, CorruptObjectException, IOException {
- AbbreviatedObjectId none = AbbreviatedObjectId.fromString("");
+ AbbreviatedObjectId none = AbbreviatedObjectId.fromString(""); //$NON-NLS-1$
root = NoteParser.parse(none, rootTree, reader);
}
}
throw new NotesMergeConflictException(baseList, oursList,
theirsList);
ObjectId resultTreeId = m.getResultTreeId();
- AbbreviatedObjectId none = AbbreviatedObjectId.fromString("");
+ AbbreviatedObjectId none = AbbreviatedObjectId.fromString(""); //$NON-NLS-1$
return NoteParser.parse(none, resultTreeId, reader).nonNotes;
}
private static String noteData(Note n) {
if (n != null)
return n.getData().name();
- return "";
+ return ""; //$NON-NLS-1$
}
private static String name(NonNoteEntry e) {
- return e != null ? e.name() : "";
+ return e != null ? e.name() : ""; //$NON-NLS-1$
}
}
/** Part of a "GIT binary patch" to describe the pre-image or post-image */
public class BinaryHunk {
- private static final byte[] LITERAL = encodeASCII("literal ");
+ private static final byte[] LITERAL = encodeASCII("literal "); //$NON-NLS-1$
- private static final byte[] DELTA = encodeASCII("delta ");
+ private static final byte[] DELTA = encodeASCII("delta "); //$NON-NLS-1$
/** Type of information stored in a binary hunk. */
public static enum Type {
* merge which introduces changes not in any ancestor.
*/
public class CombinedFileHeader extends FileHeader {
- private static final byte[] MODE = encodeASCII("mode ");
+ private static final byte[] MODE = encodeASCII("mode "); //$NON-NLS-1$
private AbbreviatedObjectId[] oldIds;
/** Patch header describing an action for a single file path. */
public class FileHeader extends DiffEntry {
- private static final byte[] OLD_MODE = encodeASCII("old mode ");
+ private static final byte[] OLD_MODE = encodeASCII("old mode "); //$NON-NLS-1$
- private static final byte[] NEW_MODE = encodeASCII("new mode ");
+ private static final byte[] NEW_MODE = encodeASCII("new mode "); //$NON-NLS-1$
- static final byte[] DELETED_FILE_MODE = encodeASCII("deleted file mode ");
+ static final byte[] DELETED_FILE_MODE = encodeASCII("deleted file mode "); //$NON-NLS-1$
- static final byte[] NEW_FILE_MODE = encodeASCII("new file mode ");
+ static final byte[] NEW_FILE_MODE = encodeASCII("new file mode "); //$NON-NLS-1$
- private static final byte[] COPY_FROM = encodeASCII("copy from ");
+ private static final byte[] COPY_FROM = encodeASCII("copy from "); //$NON-NLS-1$
- private static final byte[] COPY_TO = encodeASCII("copy to ");
+ private static final byte[] COPY_TO = encodeASCII("copy to "); //$NON-NLS-1$
- private static final byte[] RENAME_OLD = encodeASCII("rename old ");
+ private static final byte[] RENAME_OLD = encodeASCII("rename old "); //$NON-NLS-1$
- private static final byte[] RENAME_NEW = encodeASCII("rename new ");
+ private static final byte[] RENAME_NEW = encodeASCII("rename new "); //$NON-NLS-1$
- private static final byte[] RENAME_FROM = encodeASCII("rename from ");
+ private static final byte[] RENAME_FROM = encodeASCII("rename from "); //$NON-NLS-1$
- private static final byte[] RENAME_TO = encodeASCII("rename to ");
+ private static final byte[] RENAME_TO = encodeASCII("rename to "); //$NON-NLS-1$
- private static final byte[] SIMILARITY_INDEX = encodeASCII("similarity index ");
+ private static final byte[] SIMILARITY_INDEX = encodeASCII("similarity index "); //$NON-NLS-1$
- private static final byte[] DISSIMILARITY_INDEX = encodeASCII("dissimilarity index ");
+ private static final byte[] DISSIMILARITY_INDEX = encodeASCII("dissimilarity index "); //$NON-NLS-1$
- static final byte[] INDEX = encodeASCII("index ");
+ static final byte[] INDEX = encodeASCII("index "); //$NON-NLS-1$
- static final byte[] OLD_NAME = encodeASCII("--- ");
+ static final byte[] OLD_NAME = encodeASCII("--- "); //$NON-NLS-1$
- static final byte[] NEW_NAME = encodeASCII("+++ ");
+ static final byte[] NEW_NAME = encodeASCII("+++ "); //$NON-NLS-1$
/** Type of patch used by this file. */
public static enum PatchType {
public String toString() {
final StringBuilder r = new StringBuilder();
r.append(getSeverity().name().toLowerCase());
- r.append(": at offset ");
+ r.append(": at offset "); //$NON-NLS-1$
r.append(getOffset());
- r.append(": ");
+ r.append(": "); //$NON-NLS-1$
r.append(getMessage());
- r.append("\n");
- r.append(" in ");
+ r.append("\n"); //$NON-NLS-1$
+ r.append(" in "); //$NON-NLS-1$
r.append(getLineText());
return r.toString();
}
} else if (nContext + old.nDeleted > old.lineCount
|| nContext + old.nAdded > newLineCount) {
- final String oldcnt = old.lineCount + ":" + newLineCount;
- final String newcnt = (nContext + old.nDeleted) + ":"
+ final String oldcnt = old.lineCount + ":" + newLineCount; //$NON-NLS-1$
+ final String newcnt = (nContext + old.nDeleted) + ":" //$NON-NLS-1$
+ (nContext + old.nAdded);
script.warn(buf, startOffset, MessageFormat.format(
JGitText.get().hunkHeaderDoesNotMatchBodyLineCountOf, oldcnt, newcnt));
offsets[fileIdx] = end < 0 ? s.length() : end + 1;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
/** A parsed collection of {@link FileHeader}s from a unified diff patch file */
public class Patch {
- static final byte[] DIFF_GIT = encodeASCII("diff --git ");
+ static final byte[] DIFF_GIT = encodeASCII("diff --git "); //$NON-NLS-1$
- private static final byte[] DIFF_CC = encodeASCII("diff --cc ");
+ private static final byte[] DIFF_CC = encodeASCII("diff --cc "); //$NON-NLS-1$
- private static final byte[] DIFF_COMBINED = encodeASCII("diff --combined ");
+ private static final byte[] DIFF_COMBINED = encodeASCII("diff --combined "); //$NON-NLS-1$
private static final byte[][] BIN_HEADERS = new byte[][] {
- encodeASCII("Binary files "), encodeASCII("Files "), };
+ encodeASCII("Binary files "), encodeASCII("Files "), }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final byte[] BIN_TRAILER = encodeASCII(" differ\n");
+ private static final byte[] BIN_TRAILER = encodeASCII(" differ\n"); //$NON-NLS-1$
- private static final byte[] GIT_BINARY = encodeASCII("GIT binary patch\n");
+ private static final byte[] GIT_BINARY = encodeASCII("GIT binary patch\n"); //$NON-NLS-1$
- static final byte[] SIG_FOOTER = encodeASCII("-- \n");
+ static final byte[] SIG_FOOTER = encodeASCII("-- \n"); //$NON-NLS-1$
/** The files, in the order they were parsed out of the input. */
private final List<FileHeader> files;
super(repo);
this.depth = depth;
- this.UNSHALLOW = newFlag("UNSHALLOW");
- this.REINTERESTING = newFlag("REINTERESTING");
+ this.UNSHALLOW = newFlag("UNSHALLOW"); //$NON-NLS-1$
+ this.REINTERESTING = newFlag("REINTERESTING"); //$NON-NLS-1$
}
/**
super(or);
this.depth = depth;
- this.UNSHALLOW = newFlag("UNSHALLOW");
- this.REINTERESTING = newFlag("REINTERESTING");
+ this.UNSHALLOW = newFlag("UNSHALLOW"); //$NON-NLS-1$
+ this.REINTERESTING = newFlag("REINTERESTING"); //$NON-NLS-1$
}
/**
super(repo);
this.depth = depth;
- this.UNSHALLOW = newFlag("UNSHALLOW");
- this.REINTERESTING = newFlag("REINTERESTING");
+ this.UNSHALLOW = newFlag("UNSHALLOW"); //$NON-NLS-1$
+ this.REINTERESTING = newFlag("REINTERESTING"); //$NON-NLS-1$
}
/**
super(or);
this.depth = depth;
- this.UNSHALLOW = newFlag("UNSHALLOW");
- this.REINTERESTING = newFlag("REINTERESTING");
+ this.UNSHALLOW = newFlag("UNSHALLOW"); //$NON-NLS-1$
+ this.REINTERESTING = newFlag("REINTERESTING"); //$NON-NLS-1$
}
/**
return new FollowFilter(path.clone());
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "(FOLLOW(" + path.toString() + ")" //
/** Case insensitive key for a {@link FooterLine}. */
public final class FooterKey {
/** Standard {@code Signed-off-by} */
- public static final FooterKey SIGNED_OFF_BY = new FooterKey("Signed-off-by");
+ public static final FooterKey SIGNED_OFF_BY = new FooterKey("Signed-off-by"); //$NON-NLS-1$
/** Standard {@code Acked-by} */
- public static final FooterKey ACKED_BY = new FooterKey("Acked-by");
+ public static final FooterKey ACKED_BY = new FooterKey("Acked-by"); //$NON-NLS-1$
/** Standard {@code CC} */
- public static final FooterKey CC = new FooterKey("CC");
+ public static final FooterKey CC = new FooterKey("CC"); //$NON-NLS-1$
private final String name;
return name;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "FooterKey[" + name + "]";
@Override
public String toString() {
- return getKey() + ": " + getValue();
+ return getKey() + ": " + getValue(); //$NON-NLS-1$
}
}
default:
throw new CorruptObjectException(MessageFormat.format(
JGitText.get().corruptObjectInvalidMode3,
- String.format("%o", Integer.valueOf(mode)),
+ String.format("%o", Integer.valueOf(mode)), //$NON-NLS-1$
idBuffer.name(),
RawParseUtils.decode(buf, tv.namePtr, tv.nameEnd),
tv.obj));
idBuffer.fromRaw(raw, ptr);
throw new CorruptObjectException(MessageFormat.format(
JGitText.get().corruptObjectInvalidMode3,
- String.format("%o", Integer.valueOf(mode)),
- idBuffer.name(), "", tree));
+ String.format("%o", Integer.valueOf(mode)), //$NON-NLS-1$
+ idBuffer.name(), "", tree)); //$NON-NLS-1$
}
ptr += ID_SZ;
}
final byte[] raw = buffer;
final int msgB = RawParseUtils.commitMessage(raw, 0);
if (msgB < 0)
- return "";
+ return ""; //$NON-NLS-1$
final Charset enc = RawParseUtils.parseEncoding(raw);
return RawParseUtils.decode(enc, raw, msgB, raw.length);
}
final byte[] raw = buffer;
final int msgB = RawParseUtils.commitMessage(raw, 0);
if (msgB < 0)
- return "";
+ return ""; //$NON-NLS-1$
final Charset enc = RawParseUtils.parseEncoding(raw);
final int msgE = RawParseUtils.endOfParagraph(raw, msgB);
* This is a static flag. Its RevWalk is not available.
*/
public static final RevFlag UNINTERESTING = new StaticRevFlag(
- "UNINTERESTING", RevWalk.UNINTERESTING);
+ "UNINTERESTING", RevWalk.UNINTERESTING); //$NON-NLS-1$
final RevWalk walker;
final byte[] raw = buffer;
final int msgB = RawParseUtils.tagMessage(raw, 0);
if (msgB < 0)
- return "";
+ return ""; //$NON-NLS-1$
final Charset enc = RawParseUtils.parseEncoding(raw);
return RawParseUtils.decode(enc, raw, msgB, raw.length);
}
final byte[] raw = buffer;
final int msgB = RawParseUtils.tagMessage(raw, 0);
if (msgB < 0)
- return "";
+ return ""; //$NON-NLS-1$
final Charset enc = RawParseUtils.parseEncoding(raw);
final int msgE = RawParseUtils.endOfParagraph(raw, msgB);
return new Binary(a.clone(), b.clone());
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
- return "(" + a.toString() + " AND " + b.toString() + ")";
+ return "(" + a.toString() + " AND " + b.toString() + ")"; //$NON-NLS-1$
}
}
return new List(s);
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
final StringBuilder r = new StringBuilder();
return cmit.getCommitTime() <= when;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return super.toString() + "(" + new Date(when * 1000L) + ")";
return true;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return super.toString() + "(" + new Date(when * 1000L) + ")";
return cmit.getCommitTime() <= until && cmit.getCommitTime() >= when;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
- return super.toString() + "(" + new Date(when * 1000L) + " - " + new Date(until * 1000L) + ")";
+ return super.toString() + "(" + new Date(when * 1000L) + " - "
+ + new Date(until * 1000L) + ")";
}
}
@Override
public String toString() {
- return "NOT " + a.toString();
+ return "NOT " + a.toString(); //$NON-NLS-1$
}
}
return new Binary(a.clone(), b.clone());
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "(" + a.toString() + " OR " + b.toString() + ")";
@Override
public String toString() {
final StringBuilder r = new StringBuilder();
- r.append("(");
+ r.append("("); //$NON-NLS-1$
for (int i = 0; i < subfilters.length; i++) {
if (i > 0)
- r.append(" OR ");
+ r.append(" OR "); //$NON-NLS-1$
r.append(subfilters[i].toString());
}
- r.append(")");
+ r.append(")"); //$NON-NLS-1$
return r.toString();
}
}
patternText = pattern;
if (innerString) {
- if (!pattern.startsWith("^") && !pattern.startsWith(".*"))
- pattern = ".*" + pattern;
- if (!pattern.endsWith("$") && !pattern.endsWith(".*"))
- pattern = pattern + ".*";
+ if (!pattern.startsWith("^") && !pattern.startsWith(".*")) //$NON-NLS-1$ //$NON-NLS-2$
+ pattern = ".*" + pattern; //$NON-NLS-1$
+ if (!pattern.endsWith("$") && !pattern.endsWith(".*")) //$NON-NLS-1$ //$NON-NLS-2$
+ pattern = pattern + ".*"; //$NON-NLS-1$
}
final String p = rawEncoding ? forceToRaw(pattern) : pattern;
- compiledPattern = Pattern.compile(p, flags).matcher("");
+ compiledPattern = Pattern.compile(p, flags).matcher(""); //$NON-NLS-1$
}
/**
*/
protected abstract CharSequence text(RevCommit cmit);
+ @SuppressWarnings("nls")
@Override
public String toString() {
return super.toString() + "(\"" + patternText + "\")";
@Override
public String toString() {
- return "ALL";
+ return "ALL"; //$NON-NLS-1$
}
}
@Override
public String toString() {
- return "NONE";
+ return "NONE"; //$NON-NLS-1$
}
}
@Override
public String toString() {
- return "NO_MERGES";
+ return "NO_MERGES"; //$NON-NLS-1$
}
}
@Override
public String toString() {
- return "MERGE_BASE";
+ return "MERGE_BASE"; //$NON-NLS-1$
}
}
return this; // Typically we are actually thread-safe.
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return super.toString() + "(\"" + pattern.pattern() + "\")";
60, TimeUnit.SECONDS, // Idle threads wait this long before ending.
new ArrayBlockingQueue<Runnable>(1), // Do not queue deeply.
new ThreadFactory() {
- private final String name = "JGit-DFS-ReadAhead";
+ private final String name = "JGit-DFS-ReadAhead"; //$NON-NLS-1$
private final AtomicInteger cnt = new AtomicInteger();
private final ThreadGroup group = new ThreadGroup(name);
public Thread newThread(Runnable body) {
int id = cnt.incrementAndGet();
- Thread thread = new Thread(group, body, name + "-" + id);
+ Thread thread = new Thread(group, body, name + "-" + id); //$NON-NLS-1$
thread.setDaemon(true);
thread.setContextClassLoader(getClass().getClassLoader());
return thread;
});
RevWalk rw = new RevWalk(ctx);
- RevFlag added = rw.newFlag("ADDED");
+ RevFlag added = rw.newFlag("ADDED"); //$NON-NLS-1$
pm.beginTask(JGitText.get().countingObjects, ProgressMonitor.UNKNOWN);
for (DfsPackFile src : srcPacks) {
int dot = name.lastIndexOf('.');
if (dot < 0)
dot = name.length();
- return name.substring(0, dot) + ".idx";
+ return name.substring(0, dot) + ".idx"; //$NON-NLS-1$
}
/** @return the source of the pack. */
public void create(boolean bare) throws IOException {
if (exists())
throw new IOException(MessageFormat.format(
- JGitText.get().repositoryAlreadyExists, ""));
+ JGitText.get().repositoryAlreadyExists, "")); //$NON-NLS-1$
String master = Constants.R_HEADS + Constants.MASTER;
RefUpdate.Result result = updateRef(Constants.HEAD, true).link(master);
return false;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "DfsRepositoryDescription[" + getRepositoryName() + "]";
protected DfsPackDescription newPack(PackSource source) {
int id = packId.incrementAndGet();
DfsPackDescription desc = new MemPack(
- "pack-" + id + "-" + source.name(),
+ "pack-" + id + "-" + source.name(), //$NON-NLS-1$ //$NON-NLS-2$
getRepository().getDescription());
return desc.setPackSource(source);
}
* Parsed information about a checkout.
*/
public class CheckoutEntry {
- static final String CHECKOUT_MOVING_FROM = "checkout: moving from ";
+ static final String CHECKOUT_MOVING_FROM = "checkout: moving from "; //$NON-NLS-1$
private String from;
CheckoutEntry(ReflogEntry reflogEntry) {
String comment = reflogEntry.getComment();
int p1 = CHECKOUT_MOVING_FROM.length();
- int p2 = comment.indexOf(" to ", p1);
+ int p2 = comment.indexOf(" to ", p1); //$NON-NLS-1$
int p3 = comment.length();
from = comment.substring(p1,p2);
- to = comment.substring(p2 + " to ".length(), p3);
+ to = comment.substring(p2 + " to ".length(), p3); //$NON-NLS-1$
}
/**
return ObjectId.fromRaw(Constants.newMessageDigest().digest(rawText));
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return getClass().getSimpleName() + "[" + getFile().getPath() + "]";
refs.create();
objectDatabase.create();
- FileUtils.mkdir(new File(getDirectory(), "branches"));
- FileUtils.mkdir(new File(getDirectory(), "hooks"));
+ FileUtils.mkdir(new File(getDirectory(), "branches")); //$NON-NLS-1$
+ FileUtils.mkdir(new File(getDirectory(), "hooks")); //$NON-NLS-1$
RefUpdate head = updateRef(Constants.HEAD);
head.disableRefLog();
final boolean fileMode;
if (getFS().supportsExecute()) {
- File tmp = File.createTempFile("try", "execute", getDirectory());
+ File tmp = File.createTempFile("try", "execute", getDirectory()); //$NON-NLS-1$ //$NON-NLS-2$
getFS().setExecute(tmp, true);
final boolean on = getFS().canExecute(tmp);
* adapted to FileRepositories.
*/
public class GC {
- private static final String PRUNE_EXPIRE_DEFAULT = "2.weeks.ago";
+ private static final String PRUNE_EXPIRE_DEFAULT = "2.weeks.ago"; //$NON-NLS-1$
private final FileRepository repo;
if (!oldPack.shouldBeKept()) {
oldPack.close();
- FileUtils.delete(nameFor(oldName, ".pack"), deleteOptions);
- FileUtils.delete(nameFor(oldName, ".idx"), deleteOptions);
+ FileUtils.delete(nameFor(oldName, ".pack"), deleteOptions); //$NON-NLS-1$
+ FileUtils.delete(nameFor(oldName, ".idx"), deleteOptions); //$NON-NLS-1$
}
}
// close the complete object database. Thats my only chance to force
default:
throw new IOException(MessageFormat.format(
JGitText.get().corruptObjectInvalidMode3, String
- .format("%o", Integer.valueOf(treeWalk
+ .format("%o", Integer.valueOf(treeWalk //$NON-NLS-1$
.getRawMode(0)),
- (objectId == null) ? "null"
+ (objectId == null) ? "null" //$NON-NLS-1$
: objectId.name(), treeWalk
.getPathString(), repo
.getIndexFile())));
// create temporary files
String id = pw.computeName().getName();
- File packdir = new File(repo.getObjectsDirectory(), "pack");
- tmpPack = File.createTempFile("gc_", ".pack_tmp", packdir);
+ File packdir = new File(repo.getObjectsDirectory(), "pack"); //$NON-NLS-1$
+ tmpPack = File.createTempFile("gc_", ".pack_tmp", packdir); //$NON-NLS-1$ //$NON-NLS-2$
tmpIdx = new File(packdir, tmpPack.getName().substring(0,
tmpPack.getName().lastIndexOf('.'))
- + ".idx_tmp");
+ + ".idx_tmp"); //$NON-NLS-1$
if (!tmpIdx.createNewFile())
throw new IOException(MessageFormat.format(
}
// rename the temporary files to real files
- File realPack = nameFor(id, ".pack");
+ File realPack = nameFor(id, ".pack"); //$NON-NLS-1$
tmpPack.setReadOnly();
- File realIdx = nameFor(id, ".idx");
+ File realIdx = nameFor(id, ".idx"); //$NON-NLS-1$
realIdx.setReadOnly();
boolean delete = true;
try {
delete = false;
if (!tmpIdx.renameTo(realIdx)) {
File newIdx = new File(realIdx.getParentFile(),
- realIdx.getName() + ".new");
+ realIdx.getName() + ".new"); //$NON-NLS-1$
if (!tmpIdx.renameTo(newIdx))
newIdx = tmpIdx;
throw new IOException(MessageFormat.format(
}
private File nameFor(String name, String ext) {
- File packdir = new File(repo.getObjectsDirectory(), "pack");
- return new File(packdir, "pack-" + name + ext);
+ File packdir = new File(repo.getObjectsDirectory(), "pack"); //$NON-NLS-1$
+ return new File(packdir, "pack-" + name + ext); //$NON-NLS-1$
}
/**
}
private String getPackFilePath(String packName) {
- final File packDir = new File(odb.getDirectory(), "pack");
- return new File(packDir, "pack-" + packName + ".pack").getPath();
+ final File packDir = new File(odb.getDirectory(), "pack"); //$NON-NLS-1$
+ return new File(packDir, "pack-" + packName + ".pack").getPath(); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "LockFile[" + lck + ", haveLck=" + haveLck + "]";
File[] alternatePaths, FS fs, File shallowFile) throws IOException {
config = cfg;
objects = dir;
- infoDirectory = new File(objects, "info");
- packDirectory = new File(objects, "pack");
- alternatesFile = new File(infoDirectory, "alternates");
- cachedPacksFile = new File(infoDirectory, "cached-packs");
+ infoDirectory = new File(objects, "info"); //$NON-NLS-1$
+ packDirectory = new File(objects, "pack"); //$NON-NLS-1$
+ alternatesFile = new File(infoDirectory, "alternates"); //$NON-NLS-1$
+ cachedPacksFile = new File(infoDirectory, "cached-packs"); //$NON-NLS-1$
packList = new AtomicReference<PackList>(NO_PACKS);
cachedPacks = new AtomicReference<CachedPackList>();
unpackedObjectCache = new UnpackedObjectCache();
final String p = pack.getName();
final String i = idx.getName();
- if (p.length() != 50 || !p.startsWith("pack-") || !p.endsWith(".pack"))
+ if (p.length() != 50 || !p.startsWith("pack-") || !p.endsWith(".pack")) //$NON-NLS-1$
throw new IOException(MessageFormat.format(JGitText.get().notAValidPack, pack));
- if (i.length() != 49 || !i.startsWith("pack-") || !i.endsWith(".idx"))
+ if (i.length() != 49 || !i.startsWith("pack-") || !i.endsWith(".idx")) //$NON-NLS-1$
throw new IOException(MessageFormat.format(JGitText.get().notAValidPack, idx));
if (!p.substring(0, 45).equals(i.substring(0, 45)))
@Override
public String toString() {
- return "ObjectDirectory[" + getDirectory() + "]";
+ return "ObjectDirectory[" + getDirectory() + "]"; //$NON-NLS-1$
}
boolean hasObject1(final AnyObjectId objectId) {
for (final String indexName : names) {
// Must match "pack-[0-9a-f]{40}.idx" to be an index.
//
- if (indexName.length() != 49 || !indexName.endsWith(".idx"))
+ if (indexName.length() != 49 || !indexName.endsWith(".idx")) //$NON-NLS-1$
continue;
final String base = indexName.substring(0, indexName.length() - 4);
- final String packName = base + ".pack";
+ final String packName = base + ".pack"; //$NON-NLS-1$
if (!names.contains(packName)) {
// Sometimes C Git's HTTP fetch transport leaves a
// .idx file behind and does not download the .pack.
return Collections.emptySet();
final Set<String> nameSet = new HashSet<String>(nameList.length << 1);
for (final String name : nameList) {
- if (name.startsWith("pack-"))
+ if (name.startsWith("pack-")) //$NON-NLS-1$
nameSet.add(name);
}
return nameSet;
}
File newTempFile() throws IOException {
- return File.createTempFile("noz", null, db.getDirectory());
+ return File.createTempFile("noz", null, db.getDirectory()); //$NON-NLS-1$
}
DeflaterOutputStream compress(final OutputStream out) {
@Override
public PackLock parse(ProgressMonitor receiving, ProgressMonitor resolving)
throws IOException {
- tmpPack = File.createTempFile("incoming_", ".pack", db.getDirectory());
- tmpIdx = new File(db.getDirectory(), baseName(tmpPack) + ".idx");
+ tmpPack = File.createTempFile("incoming_", ".pack", db.getDirectory()); //$NON-NLS-1$ //$NON-NLS-2$
+ tmpIdx = new File(db.getDirectory(), baseName(tmpPack) + ".idx"); //$NON-NLS-1$
try {
- out = new RandomAccessFile(tmpPack, "rw");
+ out = new RandomAccessFile(tmpPack, "rw"); //$NON-NLS-1$
super.parse(receiving, resolving);
}
final String name = ObjectId.fromRaw(d.digest()).name();
- final File packDir = new File(db.getDirectory(), "pack");
- final File finalPack = new File(packDir, "pack-" + name + ".pack");
- final File finalIdx = new File(packDir, "pack-" + name + ".idx");
+ final File packDir = new File(db.getDirectory(), "pack"); //$NON-NLS-1$
+ final File finalPack = new File(packDir, "pack-" + name + ".pack"); //$NON-NLS-1$ //$NON-NLS-2$
+ final File finalIdx = new File(packDir, "pack-" + name + ".idx"); //$NON-NLS-1$ //$NON-NLS-2$
final PackLock keep = new PackLock(finalPack, db.getFS());
if (!packDir.exists() && !packDir.mkdir() && !packDir.exists()) {
String name = packName;
if (name == null) {
name = getPackFile().getName();
- if (name.startsWith("pack-"))
- name = name.substring("pack-".length());
- if (name.endsWith(".pack"))
- name = name.substring(0, name.length() - ".pack".length());
+ if (name.startsWith("pack-")) //$NON-NLS-1$
+ name = name.substring("pack-".length()); //$NON-NLS-1$
+ if (name.endsWith(".pack")) //$NON-NLS-1$
+ name = name.substring(0, name.length() - ".pack".length()); //$NON-NLS-1$
packName = name;
}
return name;
*/
public boolean shouldBeKept() {
if (keepFile == null)
- keepFile = new File(packFile.getPath() + ".keep");
+ keepFile = new File(packFile.getPath() + ".keep"); //$NON-NLS-1$
return keepFile.exists();
}
if (invalid)
throw new PackInvalidException(packFile);
synchronized (readLock) {
- fd = new RandomAccessFile(packFile, "r");
+ fd = new RandomAccessFile(packFile, "r"); //$NON-NLS-1$
length = fd.length();
onOpenPack();
}
public PackLock(final File packFile, final FS fs) {
final File p = packFile.getParentFile();
final String n = packFile.getName();
- keepFile = new File(p, n.substring(0, n.length() - 5) + ".keep");
+ keepFile = new File(p, n.substring(0, n.length() - 5) + ".keep"); //$NON-NLS-1$
this.fs = fs;
}
public boolean lock(String msg) throws IOException {
if (msg == null)
return false;
- if (!msg.endsWith("\n"))
- msg += "\n";
+ if (!msg.endsWith("\n")) //$NON-NLS-1$
+ msg += "\n"; //$NON-NLS-1$
final LockFile lf = new LockFile(keepFile, fs);
if (!lf.lock())
return false;
break;
}
} catch (IOException e) {
- if (!(!needle.contains("/") && "".equals(prefix) && e
+ if (!(!needle.contains("/") && "".equals(prefix) && e //$NON-NLS-1$ //$NON-NLS-2$
.getCause() instanceof InvalidObjectIdException)) {
throw e;
}
if (newLoose == null && curIdx < curLoose.size())
newLoose = curLoose.copy(curIdx);
- } else if (prefix.startsWith(R_REFS) && prefix.endsWith("/")) {
+ } else if (prefix.startsWith(R_REFS) && prefix.endsWith("/")) { //$NON-NLS-1$
curIdx = -(curLoose.find(prefix) + 1);
File dir = new File(refsDir, prefix.substring(R_REFS.length()));
scanTree(prefix, dir);
* a temporary name cannot be allocated.
*/
RefDirectoryUpdate newTemporaryUpdate() throws IOException {
- File tmp = File.createTempFile("renamed_", "_ref", refsDir);
+ File tmp = File.createTempFile("renamed_", "_ref", refsDir); //$NON-NLS-1$ //$NON-NLS-2$
String name = Constants.R_REFS + tmp.getName();
Ref ref = new ObjectIdRef.Unpeeled(NEW, name, null);
return new RefDirectoryUpdate(this, ref);
String strResult = toResultString(status);
if (strResult != null) {
if (msg.length() > 0)
- msg = msg + ": " + strResult;
+ msg = msg + ": " + strResult; //$NON-NLS-1$
else
msg = strResult;
}
who = RawParseUtils.parsePersonIdentOnly(raw, pos);
int p0 = RawParseUtils.next(raw, pos, '\t');
if (p0 >= raw.length)
- comment = ""; // personident has no \t, no comment present
+ comment = ""; // personident has no \t, no comment present //$NON-NLS-1$
else {
int p1 = RawParseUtils.nextLF(raw, p0);
- comment = p1 > p0 ? RawParseUtils.decode(raw, p0, p1 - 1) : "";
+ comment = p1 > p0 ? RawParseUtils.decode(raw, p0, p1 - 1) : ""; //$NON-NLS-1$
}
}
return comment;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
- return "Entry[" + oldId.name() + ", " + newId.name() + ", " + getWho() + ", "
- + getComment() + "]";
+ return "Entry[" + oldId.name() + ", " + newId.name() + ", " + getWho()
+ + ", " + getComment() + "]";
}
/**
* @param rc configuration to read properties from.
*/
public void fromConfig(final Config rc) {
- setPackedGitOpenFiles(rc.getInt("core", null, "packedgitopenfiles", getPackedGitOpenFiles()));
- setPackedGitLimit(rc.getLong("core", null, "packedgitlimit", getPackedGitLimit()));
- setPackedGitWindowSize(rc.getInt("core", null, "packedgitwindowsize", getPackedGitWindowSize()));
- setPackedGitMMAP(rc.getBoolean("core", null, "packedgitmmap", isPackedGitMMAP()));
- setDeltaBaseCacheLimit(rc.getInt("core", null, "deltabasecachelimit", getDeltaBaseCacheLimit()));
+ setPackedGitOpenFiles(rc.getInt(
+ "core", null, "packedgitopenfiles", getPackedGitOpenFiles())); //$NON-NLS-1$ //$NON-NLS-2$
+ setPackedGitLimit(rc.getLong(
+ "core", null, "packedgitlimit", getPackedGitLimit())); //$NON-NLS-1$ //$NON-NLS-2$
+ setPackedGitWindowSize(rc.getInt(
+ "core", null, "packedgitwindowsize", getPackedGitWindowSize())); //$NON-NLS-1$ //$NON-NLS-2$
+ setPackedGitMMAP(rc.getBoolean(
+ "core", null, "packedgitmmap", isPackedGitMMAP())); //$NON-NLS-1$ //$NON-NLS-2$
+ setDeltaBaseCacheLimit(rc.getInt(
+ "core", null, "deltabasecachelimit", getDeltaBaseCacheLimit())); //$NON-NLS-1$ //$NON-NLS-2$
long maxMem = Runtime.getRuntime().maxMemory();
- long sft = rc.getLong("core", null, "streamfilethreshold", getStreamFileThreshold());
+ long sft = rc.getLong(
+ "core", null, "streamfilethreshold", getStreamFileThreshold()); //$NON-NLS-1$ //$NON-NLS-2$
sft = Math.min(sft, maxMem / 4); // don't use more than 1/4 of the heap
sft = Math.min(sft, Integer.MAX_VALUE); // cannot exceed array length
setStreamFileThreshold((int) sft);
private WriteConfig(final Config rc) {
compression = rc.get(CoreConfig.KEY).getCompression();
- fsyncObjectFiles = rc.getBoolean("core", "fsyncobjectfiles", false);
- fsyncRefFiles = rc.getBoolean("core", "fsyncreffiles", false);
+ fsyncObjectFiles = rc.getBoolean("core", "fsyncobjectfiles", false); //$NON-NLS-1$ //$NON-NLS-2$
+ fsyncRefFiles = rc.getBoolean("core", "fsyncreffiles", false); //$NON-NLS-1$ //$NON-NLS-2$
}
int getCompression() {
} while ((c & 0x80) != 0);
if (includeHeader)
- r.append("DELTA( BASE=" + baseLen + " RESULT=" + resLen + " )\n");
+ r.append("DELTA( BASE=" + baseLen + " RESULT=" + resLen + " )\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
while (deltaPtr < delta.length) {
final int cmd = delta[deltaPtr++] & 0xff;
if (copySize == 0)
copySize = 0x10000;
- r.append(" COPY (" + copyOffset + ", " + copySize + ")\n");
+ r.append(" COPY (" + copyOffset + ", " + copySize + ")\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} else if (cmd != 0) {
// Anything else the data is literal within the delta
// itself.
//
- r.append(" INSERT(");
+ r.append(" INSERT("); //$NON-NLS-1$
r.append(QuotedString.GIT_PATH.quote(RawParseUtils.decode(
delta, deltaPtr, deltaPtr + cmd)));
- r.append(")\n");
+ r.append(")\n"); //$NON-NLS-1$
deltaPtr += cmd;
} else {
// cmd == 0 has been reserved for future encoding but
return start - resPtr;
}
+ @SuppressWarnings("nls")
public String toString() {
String[] units = { "bytes", "KiB", "MiB", "GiB" };
long sz = getIndexSize();
// Empty by default.
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
* configuration to read properties from.
*/
public void fromConfig(final Config rc) {
- setMaxDeltaDepth(rc.getInt("pack", "depth", getMaxDeltaDepth()));
- setDeltaSearchWindowSize(rc.getInt("pack", "window", getDeltaSearchWindowSize()));
- setDeltaSearchMemoryLimit(rc.getLong("pack", "windowmemory", getDeltaSearchMemoryLimit()));
- setDeltaCacheSize(rc.getLong("pack", "deltacachesize", getDeltaCacheSize()));
- setDeltaCacheLimit(rc.getInt("pack", "deltacachelimit", getDeltaCacheLimit()));
- setCompressionLevel(rc.getInt("pack", "compression",
- rc.getInt("core", "compression", getCompressionLevel())));
- setIndexVersion(rc.getInt("pack", "indexversion", getIndexVersion()));
- setBigFileThreshold(rc.getInt("core", "bigfilethreshold", getBigFileThreshold()));
- setThreads(rc.getInt("pack", "threads", getThreads()));
+ setMaxDeltaDepth(rc.getInt("pack", "depth", getMaxDeltaDepth())); //$NON-NLS-1$ //$NON-NLS-2$
+ setDeltaSearchWindowSize(rc.getInt(
+ "pack", "window", getDeltaSearchWindowSize())); //$NON-NLS-1$ //$NON-NLS-2$
+ setDeltaSearchMemoryLimit(rc.getLong(
+ "pack", "windowmemory", getDeltaSearchMemoryLimit())); //$NON-NLS-1$ //$NON-NLS-2$
+ setDeltaCacheSize(rc.getLong(
+ "pack", "deltacachesize", getDeltaCacheSize())); //$NON-NLS-1$ //$NON-NLS-2$
+ setDeltaCacheLimit(rc.getInt(
+ "pack", "deltacachelimit", getDeltaCacheLimit())); //$NON-NLS-1$ //$NON-NLS-2$
+ setCompressionLevel(rc.getInt("pack", "compression", //$NON-NLS-1$ //$NON-NLS-2$
+ rc.getInt("core", "compression", getCompressionLevel()))); //$NON-NLS-1$ //$NON-NLS-2$
+ setIndexVersion(rc.getInt("pack", "indexversion", getIndexVersion())); //$NON-NLS-1$ //$NON-NLS-2$
+ setBigFileThreshold(rc.getInt(
+ "core", "bigfilethreshold", getBigFileThreshold())); //$NON-NLS-1$ //$NON-NLS-2$
+ setThreads(rc.getInt("pack", "threads", getThreads())); //$NON-NLS-1$ //$NON-NLS-2$
// These variables aren't standardized
//
- setReuseDeltas(rc.getBoolean("pack", "reusedeltas", isReuseDeltas()));
- setReuseObjects(rc.getBoolean("pack", "reuseobjects", isReuseObjects()));
- setDeltaCompress(rc.getBoolean("pack", "deltacompression", isDeltaCompress()));
+ setReuseDeltas(rc.getBoolean("pack", "reusedeltas", isReuseDeltas())); //$NON-NLS-1$ //$NON-NLS-2$
+ setReuseObjects(rc.getBoolean("pack", "reuseobjects", isReuseObjects())); //$NON-NLS-1$ //$NON-NLS-2$
+ setDeltaCompress(rc.getBoolean(
+ "pack", "deltacompression", isDeltaCompress())); //$NON-NLS-1$ //$NON-NLS-2$
}
}
// Object writing already started, we cannot recover.
//
CorruptObjectException coe;
- coe = new CorruptObjectException(otp, "");
+ coe = new CorruptObjectException(otp, ""); //$NON-NLS-1$
coe.initCause(gone);
throw coe;
}
all.addAll(have);
final Map<ObjectId, CachedPack> tipToPack = new HashMap<ObjectId, CachedPack>();
- final RevFlag inCachedPack = walker.newFlag("inCachedPack");
- final RevFlag include = walker.newFlag("include");
- final RevFlag added = walker.newFlag("added");
+ final RevFlag inCachedPack = walker.newFlag("inCachedPack"); //$NON-NLS-1$
+ final RevFlag include = walker.newFlag("include"); //$NON-NLS-1$
+ final RevFlag added = walker.newFlag("added"); //$NON-NLS-1$
final RevFlagSet keepOnRestart = new RevFlagSet();
keepOnRestart.add(inCachedPack);
return bytesUsed;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "PackWriter.State[" + phase + ", memory=" + bytesUsed + "]";
*/
public static String getSubmoduleRemoteUrl(final Repository parent,
final String url) throws IOException {
- if (!url.startsWith("./") && !url.startsWith("../"))
+ if (!url.startsWith("./") && !url.startsWith("../")) //$NON-NLS-1$ //$NON-NLS-2$
return url;
String remoteName = null;
char separator = '/';
String submoduleUrl = url;
while (submoduleUrl.length() > 0) {
- if (submoduleUrl.startsWith("./"))
+ if (submoduleUrl.startsWith("./")) //$NON-NLS-1$
submoduleUrl = submoduleUrl.substring(2);
- else if (submoduleUrl.startsWith("../")) {
+ else if (submoduleUrl.startsWith("../")) { //$NON-NLS-1$
int lastSeparator = remoteUrl.lastIndexOf('/');
if (lastSeparator < 1) {
lastSeparator = remoteUrl.lastIndexOf(':');
public class AmazonS3 {
private static final Set<String> SIGNED_HEADERS;
- private static final String HMAC = "HmacSHA1";
+ private static final String HMAC = "HmacSHA1"; //$NON-NLS-1$
- private static final String DOMAIN = "s3.amazonaws.com";
+ private static final String DOMAIN = "s3.amazonaws.com"; //$NON-NLS-1$
- private static final String X_AMZ_ACL = "x-amz-acl";
+ private static final String X_AMZ_ACL = "x-amz-acl"; //$NON-NLS-1$
- private static final String X_AMZ_META = "x-amz-meta-";
+ private static final String X_AMZ_META = "x-amz-meta-"; //$NON-NLS-1$
static {
SIGNED_HEADERS = new HashSet<String>();
- SIGNED_HEADERS.add("content-type");
- SIGNED_HEADERS.add("content-md5");
- SIGNED_HEADERS.add("date");
+ SIGNED_HEADERS.add("content-type"); //$NON-NLS-1$
+ SIGNED_HEADERS.add("content-md5"); //$NON-NLS-1$
+ SIGNED_HEADERS.add("date"); //$NON-NLS-1$
}
private static boolean isSignedHeader(final String name) {
final String nameLC = StringUtils.toLowerCase(name);
- return SIGNED_HEADERS.contains(nameLC) || nameLC.startsWith("x-amz-");
+ return SIGNED_HEADERS.contains(nameLC) || nameLC.startsWith("x-amz-"); //$NON-NLS-1$
}
private static String toCleanString(final List<String> list) {
for (final String v : list) {
if (s.length() > 0)
s.append(',');
- s.append(v.replaceAll("\n", "").trim());
+ s.append(v.replaceAll("\n", "").trim()); //$NON-NLS-1$ //$NON-NLS-2$
}
return s.toString();
}
private static String remove(final Map<String, String> m, final String k) {
final String r = m.remove(k);
- return r != null ? r : "";
+ return r != null ? r : ""; //$NON-NLS-1$
}
private static String httpNow() {
- final String tz = "GMT";
+ final String tz = "GMT"; //$NON-NLS-1$
final SimpleDateFormat fmt;
- fmt = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.US);
+ fmt = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.US); //$NON-NLS-1$
fmt.setTimeZone(TimeZone.getTimeZone(tz));
- return fmt.format(new Date()) + " " + tz;
+ return fmt.format(new Date()) + " " + tz; //$NON-NLS-1$
}
private static MessageDigest newMD5() {
try {
- return MessageDigest.getInstance("MD5");
+ return MessageDigest.getInstance("MD5"); //$NON-NLS-1$
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(JGitText.get().JRELacksMD5Implementation, e);
}
*
*/
public AmazonS3(final Properties props) {
- publicKey = props.getProperty("accesskey");
+ publicKey = props.getProperty("accesskey"); //$NON-NLS-1$
if (publicKey == null)
throw new IllegalArgumentException(JGitText.get().missingAccesskey);
- final String secret = props.getProperty("secretkey");
+ final String secret = props.getProperty("secretkey"); //$NON-NLS-1$
if (secret == null)
throw new IllegalArgumentException(JGitText.get().missingSecretkey);
privateKey = new SecretKeySpec(Constants.encodeASCII(secret), HMAC);
- final String pacl = props.getProperty("acl", "PRIVATE");
- if (StringUtils.equalsIgnoreCase("PRIVATE", pacl))
- acl = "private";
- else if (StringUtils.equalsIgnoreCase("PUBLIC", pacl))
- acl = "public-read";
- else if (StringUtils.equalsIgnoreCase("PUBLIC-READ", pacl))
- acl = "public-read";
- else if (StringUtils.equalsIgnoreCase("PUBLIC_READ", pacl))
- acl = "public-read";
+ final String pacl = props.getProperty("acl", "PRIVATE"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (StringUtils.equalsIgnoreCase("PRIVATE", pacl)) //$NON-NLS-1$
+ acl = "private"; //$NON-NLS-1$
+ else if (StringUtils.equalsIgnoreCase("PUBLIC", pacl)) //$NON-NLS-1$
+ acl = "public-read"; //$NON-NLS-1$
+ else if (StringUtils.equalsIgnoreCase("PUBLIC-READ", pacl)) //$NON-NLS-1$
+ acl = "public-read"; //$NON-NLS-1$
+ else if (StringUtils.equalsIgnoreCase("PUBLIC_READ", pacl)) //$NON-NLS-1$
+ acl = "public-read"; //$NON-NLS-1$
else
- throw new IllegalArgumentException("Invalid acl: " + pacl);
+ throw new IllegalArgumentException("Invalid acl: " + pacl); //$NON-NLS-1$
try {
- final String cPas = props.getProperty("password");
+ final String cPas = props.getProperty("password"); //$NON-NLS-1$
if (cPas != null) {
- String cAlg = props.getProperty("crypto.algorithm");
+ String cAlg = props.getProperty("crypto.algorithm"); //$NON-NLS-1$
if (cAlg == null)
- cAlg = "PBEWithMD5AndDES";
+ cAlg = "PBEWithMD5AndDES"; //$NON-NLS-1$
encryption = new WalkEncryption.ObjectEncryptionV2(cAlg, cPas);
} else {
encryption = WalkEncryption.NONE;
}
maxAttempts = Integer.parseInt(props.getProperty(
- "httpclient.retry-max", "3"));
+ "httpclient.retry-max", "3")); //$NON-NLS-1$ //$NON-NLS-2$
proxySelector = ProxySelector.getDefault();
}
public URLConnection get(final String bucket, final String key)
throws IOException {
for (int curAttempt = 0; curAttempt < maxAttempts; curAttempt++) {
- final HttpURLConnection c = open("GET", bucket, key);
+ final HttpURLConnection c = open("GET", bucket, key); //$NON-NLS-1$
authorize(c);
switch (HttpSupport.response(c)) {
case HttpURLConnection.HTTP_OK:
*/
public List<String> list(final String bucket, String prefix)
throws IOException {
- if (prefix.length() > 0 && !prefix.endsWith("/"))
- prefix += "/";
+ if (prefix.length() > 0 && !prefix.endsWith("/")) //$NON-NLS-1$
+ prefix += "/"; //$NON-NLS-1$
final ListParser lp = new ListParser(bucket, prefix);
do {
lp.list();
public void delete(final String bucket, final String key)
throws IOException {
for (int curAttempt = 0; curAttempt < maxAttempts; curAttempt++) {
- final HttpURLConnection c = open("DELETE", bucket, key);
+ final HttpURLConnection c = open("DELETE", bucket, key); //$NON-NLS-1$
authorize(c);
switch (HttpSupport.response(c)) {
case HttpURLConnection.HTTP_NO_CONTENT:
final String md5str = Base64.encodeBytes(newMD5().digest(data));
final String lenstr = String.valueOf(data.length);
for (int curAttempt = 0; curAttempt < maxAttempts; curAttempt++) {
- final HttpURLConnection c = open("PUT", bucket, key);
- c.setRequestProperty("Content-Length", lenstr);
- c.setRequestProperty("Content-MD5", md5str);
+ final HttpURLConnection c = open("PUT", bucket, key); //$NON-NLS-1$
+ c.setRequestProperty("Content-Length", lenstr); //$NON-NLS-1$
+ c.setRequestProperty("Content-MD5", md5str); //$NON-NLS-1$
c.setRequestProperty(X_AMZ_ACL, acl);
authorize(c);
c.setDoOutput(true);
final long len = buf.length();
final String lenstr = String.valueOf(len);
for (int curAttempt = 0; curAttempt < maxAttempts; curAttempt++) {
- final HttpURLConnection c = open("PUT", bucket, key);
- c.setRequestProperty("Content-Length", lenstr);
- c.setRequestProperty("Content-MD5", md5str);
+ final HttpURLConnection c = open("PUT", bucket, key); //$NON-NLS-1$
+ c.setRequestProperty("Content-Length", lenstr); //$NON-NLS-1$
+ c.setRequestProperty("Content-MD5", md5str); //$NON-NLS-1$
c.setRequestProperty(X_AMZ_ACL, acl);
encryption.request(c, X_AMZ_META);
authorize(c);
}
buf = b.toByteArray();
if (buf.length > 0)
- err.initCause(new IOException("\n" + new String(buf)));
+ err.initCause(new IOException("\n" + new String(buf))); //$NON-NLS-1$
return err;
}
final String key, final Map<String, String> args)
throws IOException {
final StringBuilder urlstr = new StringBuilder();
- urlstr.append("http://");
+ urlstr.append("http://"); //$NON-NLS-1$
urlstr.append(bucket);
urlstr.append('.');
urlstr.append(DOMAIN);
c = (HttpURLConnection) url.openConnection(proxy);
c.setRequestMethod(method);
- c.setRequestProperty("User-Agent", "jgit/1.0");
- c.setRequestProperty("Date", httpNow());
+ c.setRequestProperty("User-Agent", "jgit/1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+ c.setRequestProperty("Date", httpNow()); //$NON-NLS-1$
return c;
}
s.append(c.getRequestMethod());
s.append('\n');
- s.append(remove(sigHdr, "content-md5"));
+ s.append(remove(sigHdr, "content-md5")); //$NON-NLS-1$
s.append('\n');
- s.append(remove(sigHdr, "content-type"));
+ s.append(remove(sigHdr, "content-type")); //$NON-NLS-1$
s.append('\n');
- s.append(remove(sigHdr, "date"));
+ s.append(remove(sigHdr, "date")); //$NON-NLS-1$
s.append('\n');
for (final Map.Entry<String, String> e : sigHdr.entrySet()) {
try {
final Mac m = Mac.getInstance(HMAC);
m.init(privateKey);
- sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes("UTF-8")));
+ sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes("UTF-8"))); //$NON-NLS-1$
} catch (NoSuchAlgorithmException e) {
throw new IOException(MessageFormat.format(JGitText.get().noHMACsupport, HMAC, e.getMessage()));
} catch (InvalidKeyException e) {
throw new IOException(MessageFormat.format(JGitText.get().invalidKey, e.getMessage()));
}
- c.setRequestProperty("Authorization", "AWS " + publicKey + ":" + sec);
+ c.setRequestProperty("Authorization", "AWS " + publicKey + ":" + sec); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
static Properties properties(final File authFile)
void list() throws IOException {
final Map<String, String> args = new TreeMap<String, String>();
if (prefix.length() > 0)
- args.put("prefix", prefix);
+ args.put("prefix", prefix); //$NON-NLS-1$
if (!entries.isEmpty())
- args.put("marker", prefix + entries.get(entries.size() - 1));
+ args.put("marker", prefix + entries.get(entries.size() - 1)); //$NON-NLS-1$
for (int curAttempt = 0; curAttempt < maxAttempts; curAttempt++) {
- final HttpURLConnection c = open("GET", bucket, "", args);
+ final HttpURLConnection c = open("GET", bucket, "", args); //$NON-NLS-1$ //$NON-NLS-2$
authorize(c);
switch (HttpSupport.response(c)) {
case HttpURLConnection.HTTP_OK:
continue;
default:
- throw AmazonS3.this.error("Listing", prefix, c);
+ throw AmazonS3.this.error("Listing", prefix, c); //$NON-NLS-1$
}
}
- throw maxAttempts("Listing", prefix);
+ throw maxAttempts("Listing", prefix); //$NON-NLS-1$
}
@Override
public void startElement(final String uri, final String name,
final String qName, final Attributes attributes)
throws SAXException {
- if ("Key".equals(name) || "IsTruncated".equals(name))
+ if ("Key".equals(name) || "IsTruncated".equals(name)) //$NON-NLS-1$ //$NON-NLS-2$
data = new StringBuilder();
}
@Override
public void endElement(final String uri, final String name,
final String qName) throws SAXException {
- if ("Key".equals(name))
+ if ("Key".equals(name)) //$NON-NLS-1$
entries.add(data.toString().substring(prefix.length()));
- else if ("IsTruncated".equals(name))
- truncated = StringUtils.equalsIgnoreCase("true", data.toString());
+ else if ("IsTruncated".equals(name)) //$NON-NLS-1$
+ truncated = StringUtils.equalsIgnoreCase("true", data.toString()); //$NON-NLS-1$
data = null;
}
}
}
public String getMessages() {
- return messageWriter != null ? messageWriter.toString() : "";
+ return messageWriter != null ? messageWriter.toString() : ""; //$NON-NLS-1$
}
public abstract void close();
final int timeout = transport.getTimeout();
if (timeout > 0) {
final Thread caller = Thread.currentThread();
- myTimer = new InterruptTimer(caller.getName() + "-Timer");
+ myTimer = new InterruptTimer(caller.getName() + "-Timer"); //$NON-NLS-1$
timeoutIn = new TimeoutInputStream(myIn, myTimer);
timeoutOut = new TimeoutOutputStream(myOut, myTimer);
timeoutIn.setTimeout(timeout * 1000);
if (line == PacketLineIn.END)
break;
- if (line.startsWith("ERR ")) {
+ if (line.startsWith("ERR ")) { //$NON-NLS-1$
// This is a customized remote service error.
// Users should be informed about it.
throw new RemoteRepositoryException(uri, line.substring(4));
if (nul >= 0) {
// The first line (if any) may contain "hidden"
// capability values after a NUL byte.
- for (String c : line.substring(nul + 1).split(" "))
+ for (String c : line.substring(nul + 1).split(" ")) //$NON-NLS-1$
remoteCapablities.add(c);
line = line.substring(0, nul);
}
}
String name = line.substring(41, line.length());
- if (avail.isEmpty() && name.equals("capabilities^{}")) {
+ if (avail.isEmpty() && name.equals("capabilities^{}")) { //$NON-NLS-1$
// special line from git-receive-pack to show
// capabilities when there are no refs to advertise
continue;
}
final ObjectId id = ObjectId.fromString(line.substring(0, 40));
- if (name.equals(".have")) {
+ if (name.equals(".have")) { //$NON-NLS-1$
additionalHaves.add(id);
- } else if (name.endsWith("^{}")) {
+ } else if (name.endsWith("^{}")) { //$NON-NLS-1$
name = name.substring(0, name.length() - 3);
final Ref prior = avail.get(name);
if (prior == null)
JGitText.get().advertisementCameBefore, name, name));
if (prior.getPeeledObjectId() != null)
- throw duplicateAdvertisement(name + "^{}");
+ throw duplicateAdvertisement(name + "^{}"); //$NON-NLS-1$
avail.put(name, new ObjectIdRef.PeeledTag(
Ref.Storage.NETWORK, name, prior.getObjectId(), id));
* Include tags if we are also including the referenced objects.
* @since 2.0
*/
- public static final String OPTION_INCLUDE_TAG = "include-tag";
+ public static final String OPTION_INCLUDE_TAG = "include-tag"; //$NON-NLS-1$
/**
* Mutli-ACK support for improved negotiation.
* @since 2.0
*/
- public static final String OPTION_MULTI_ACK = "multi_ack";
+ public static final String OPTION_MULTI_ACK = "multi_ack"; //$NON-NLS-1$
/**
* Mutli-ACK detailed support for improved negotiation.
* @since 2.0
*/
- public static final String OPTION_MULTI_ACK_DETAILED = "multi_ack_detailed";
+ public static final String OPTION_MULTI_ACK_DETAILED = "multi_ack_detailed"; //$NON-NLS-1$
/**
* The client supports packs with deltas but not their bases.
* @since 2.0
*/
- public static final String OPTION_THIN_PACK = "thin-pack";
+ public static final String OPTION_THIN_PACK = "thin-pack"; //$NON-NLS-1$
/**
* The client supports using the side-band for progress messages.
* @since 2.0
*/
- public static final String OPTION_SIDE_BAND = "side-band";
+ public static final String OPTION_SIDE_BAND = "side-band"; //$NON-NLS-1$
/**
* The client supports using the 64K side-band for progress messages.
* @since 2.0
*/
- public static final String OPTION_SIDE_BAND_64K = "side-band-64k";
+ public static final String OPTION_SIDE_BAND_64K = "side-band-64k"; //$NON-NLS-1$
/**
* The client supports packs with OFS deltas.
* @since 2.0
*/
- public static final String OPTION_OFS_DELTA = "ofs-delta";
+ public static final String OPTION_OFS_DELTA = "ofs-delta"; //$NON-NLS-1$
/**
* The client supports shallow fetches.
* @since 2.0
*/
- public static final String OPTION_SHALLOW = "shallow";
+ public static final String OPTION_SHALLOW = "shallow"; //$NON-NLS-1$
/**
* The client does not want progress messages and will ignore them.
* @since 2.0
*/
- public static final String OPTION_NO_PROGRESS = "no-progress";
+ public static final String OPTION_NO_PROGRESS = "no-progress"; //$NON-NLS-1$
/**
* The client supports receiving a pack before it has sent "done".
* @since 2.0
*/
- public static final String OPTION_NO_DONE = "no-done";
+ public static final String OPTION_NO_DONE = "no-done"; //$NON-NLS-1$
static enum MultiAck {
OFF, CONTINUE, DETAILED;
walk = new RevWalk(local);
reachableCommits = new RevCommitList<RevCommit>();
- REACHABLE = walk.newFlag("REACHABLE");
- COMMON = walk.newFlag("COMMON");
- STATE = walk.newFlag("STATE");
- ADVERTISED = walk.newFlag("ADVERTISED");
+ REACHABLE = walk.newFlag("REACHABLE"); //$NON-NLS-1$
+ COMMON = walk.newFlag("COMMON"); //$NON-NLS-1$
+ STATE = walk.newFlag("STATE"); //$NON-NLS-1$
+ ADVERTISED = walk.newFlag("ADVERTISED"); //$NON-NLS-1$
walk.carry(COMMON);
walk.carry(REACHABLE);
final boolean allowOfsDelta;
FetchConfig(final Config c) {
- allowOfsDelta = c.getBoolean("repack", "usedeltabaseoffset", true);
+ allowOfsDelta = c.getBoolean("repack", "usedeltabaseoffset", true); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
final StringBuilder line = new StringBuilder(46);
- line.append("want ");
+ line.append("want "); //$NON-NLS-1$
line.append(r.getObjectId().name());
if (first) {
line.append(enableCapabilities());
if (c == null)
break SEND_HAVES;
- pckOut.writeString("have " + c.getId().name() + "\n");
+ pckOut.writeString("have " + c.getId().name() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
havesSent++;
havesSinceLastContinue++;
// loop above while in the middle of a request. This allows us
// to just write done immediately.
//
- pckOut.writeString("done\n");
+ pckOut.writeString("done\n"); //$NON-NLS-1$
pckOut.flush();
}
* The client expects a status report after the server processes the pack.
* @since 2.0
*/
- public static final String CAPABILITY_REPORT_STATUS = "report-status";
+ public static final String CAPABILITY_REPORT_STATUS = "report-status"; //$NON-NLS-1$
/**
* The server supports deleting refs.
* @since 2.0
*/
- public static final String CAPABILITY_DELETE_REFS = "delete-refs";
+ public static final String CAPABILITY_DELETE_REFS = "delete-refs"; //$NON-NLS-1$
/**
* The server supports packs with OFS deltas.
* @since 2.0
*/
- public static final String CAPABILITY_OFS_DELTA = "ofs-delta";
+ public static final String CAPABILITY_OFS_DELTA = "ofs-delta"; //$NON-NLS-1$
/**
* The client supports using the 64K side-band for progress messages.
* @since 2.0
*/
- public static final String CAPABILITY_SIDE_BAND_64K = "side-band-64k";
+ public static final String CAPABILITY_SIDE_BAND_64K = "side-band-64k"; //$NON-NLS-1$
private final boolean thinPack;
private void readStatusReport(final Map<String, RemoteRefUpdate> refUpdates)
throws IOException {
final String unpackLine = readStringLongTimeout();
- if (!unpackLine.startsWith("unpack "))
+ if (!unpackLine.startsWith("unpack ")) //$NON-NLS-1$
throw new PackProtocolException(uri, MessageFormat.format(JGitText.get().unexpectedReportLine, unpackLine));
- final String unpackStatus = unpackLine.substring("unpack ".length());
- if (!unpackStatus.equals("ok"))
+ final String unpackStatus = unpackLine.substring("unpack ".length()); //$NON-NLS-1$
+ if (!unpackStatus.equals("ok")) //$NON-NLS-1$
throw new TransportException(uri, MessageFormat.format(
JGitText.get().errorOccurredDuringUnpackingOnTheRemoteEnd, unpackStatus));
while ((refLine = pckIn.readString()) != PacketLineIn.END) {
boolean ok = false;
int refNameEnd = -1;
- if (refLine.startsWith("ok ")) {
+ if (refLine.startsWith("ok ")) { //$NON-NLS-1$
ok = true;
refNameEnd = refLine.length();
- } else if (refLine.startsWith("ng ")) {
+ } else if (refLine.startsWith("ng ")) { //$NON-NLS-1$
ok = false;
- refNameEnd = refLine.indexOf(" ", 3);
+ refNameEnd = refLine.indexOf(" ", 3); //$NON-NLS-1$
}
if (refNameEnd == -1)
throw new PackProtocolException(MessageFormat.format(JGitText.get().unexpectedReportLine2
final HashSet<String> caps = new HashSet<String>();
final int nul = line.indexOf('\0');
if (nul >= 0) {
- for (String c : line.substring(nul + 1).split(" "))
+ for (String c : line.substring(nul + 1).split(" ")) //$NON-NLS-1$
caps.add(c);
this.line = line.substring(0, nul);
} else
final boolean allowOfsDelta;
ReceiveConfig(final Config config) {
- checkReceivedObjects = config.getBoolean("receive", "fsckobjects",
+ checkReceivedObjects = config.getBoolean("receive", "fsckobjects", //$NON-NLS-1$ //$NON-NLS-2$
false);
allowCreates = true;
- allowDeletes = !config.getBoolean("receive", "denydeletes", false);
- allowNonFastForwards = !config.getBoolean("receive",
- "denynonfastforwards", false);
- allowOfsDelta = config.getBoolean("repack", "usedeltabaseoffset",
+ allowDeletes = !config.getBoolean("receive", "denydeletes", false); //$NON-NLS-1$ //$NON-NLS-2$
+ allowNonFastForwards = !config.getBoolean("receive", //$NON-NLS-1$
+ "denynonfastforwards", false); //$NON-NLS-1$
+ allowOfsDelta = config.getBoolean("repack", "usedeltabaseoffset", //$NON-NLS-1$ //$NON-NLS-2$
true);
}
}
advertiseError = new StringBuilder();
advertiseError.append(what).append('\n');
} else {
- msgOutWrapper.write(Constants.encode("error: " + what + "\n"));
+ msgOutWrapper.write(Constants.encode("error: " + what + "\n")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
* string must not end with an LF, and must not contain an LF.
*/
public void sendMessage(final String what) {
- msgOutWrapper.write(Constants.encode(what + "\n"));
+ msgOutWrapper.write(Constants.encode(what + "\n")); //$NON-NLS-1$
}
/** @return an underlying stream for sending messages to the client. */
if (timeout > 0) {
final Thread caller = Thread.currentThread();
- timer = new InterruptTimer(caller.getName() + "-Timer");
+ timer = new InterruptTimer(caller.getName() + "-Timer"); //$NON-NLS-1$
timeoutIn = new TimeoutInputStream(rawIn, timer);
TimeoutOutputStream o = new TimeoutOutputStream(rawOut, timer);
timeoutIn.setTimeout(timeout * 1000);
public void sendAdvertisedRefs(final RefAdvertiser adv)
throws IOException, ServiceMayNotContinueException {
if (advertiseError != null) {
- adv.writeOne("ERR " + advertiseError);
+ adv.writeOne("ERR " + advertiseError); //$NON-NLS-1$
return;
}
advertiseRefsHook.advertiseRefs(this);
} catch (ServiceMayNotContinueException fail) {
if (fail.getMessage() != null) {
- adv.writeOne("ERR " + fail.getMessage());
+ adv.writeOne("ERR " + fail.getMessage()); //$NON-NLS-1$
fail.setOutput();
}
throw fail;
for (ObjectId obj : advertisedHaves)
adv.advertiseHave(obj);
if (adv.isEmpty())
- adv.advertiseId(ObjectId.zeroId(), "capabilities^{}");
+ adv.advertiseId(ObjectId.zeroId(), "capabilities^{}"); //$NON-NLS-1$
adv.end();
}
ObjectInserter ins = db.newObjectInserter();
try {
- String lockMsg = "jgit receive-pack";
+ String lockMsg = "jgit receive-pack"; //$NON-NLS-1$
if (getRefLogIdent() != null)
- lockMsg += " from " + getRefLogIdent().toExternalString();
+ lockMsg += " from " + getRefLogIdent().toExternalString(); //$NON-NLS-1$
parser = ins.newPackParser(rawIn);
parser.setAllowThin(true);
BatchRefUpdate batch = db.getRefDatabase().newBatchUpdate();
batch.setAllowNonFastForwards(isAllowNonFastForwards());
batch.setRefLogIdent(getRefLogIdent());
- batch.setRefLogMessage("push", true);
+ batch.setRefLogMessage("push", true); //$NON-NLS-1$
batch.addCommand(toApply);
try {
batch.execute(walk, updating);
protected void sendStatusReport(final boolean forClient,
final Throwable unpackError, final Reporter out) throws IOException {
if (unpackError != null) {
- out.sendString("unpack error " + unpackError.getMessage());
+ out.sendString("unpack error " + unpackError.getMessage()); //$NON-NLS-1$
if (forClient) {
for (final ReceiveCommand cmd : commands) {
- out.sendString("ng " + cmd.getRefName()
- + " n/a (unpacker error)");
+ out.sendString("ng " + cmd.getRefName() //$NON-NLS-1$
+ + " n/a (unpacker error)"); //$NON-NLS-1$
}
}
return;
}
if (forClient)
- out.sendString("unpack ok");
+ out.sendString("unpack ok"); //$NON-NLS-1$
for (final ReceiveCommand cmd : commands) {
if (cmd.getResult() == Result.OK) {
if (forClient)
- out.sendString("ok " + cmd.getRefName());
+ out.sendString("ok " + cmd.getRefName()); //$NON-NLS-1$
continue;
}
final StringBuilder r = new StringBuilder();
if (forClient)
- r.append("ng ").append(cmd.getRefName()).append(" ");
+ r.append("ng ").append(cmd.getRefName()).append(" "); //$NON-NLS-1$ //$NON-NLS-2$
else
- r.append(" ! [rejected] ").append(cmd.getRefName()).append(" (");
+ r.append(" ! [rejected] ").append(cmd.getRefName()).append(" ("); //$NON-NLS-1$ //$NON-NLS-2$
switch (cmd.getResult()) {
case NOT_ATTEMPTED:
- r.append("server bug; ref not processed");
+ r.append("server bug; ref not processed"); //$NON-NLS-1$
break;
case REJECTED_NOCREATE:
- r.append("creation prohibited");
+ r.append("creation prohibited"); //$NON-NLS-1$
break;
case REJECTED_NODELETE:
- r.append("deletion prohibited");
+ r.append("deletion prohibited"); //$NON-NLS-1$
break;
case REJECTED_NONFASTFORWARD:
- r.append("non-fast forward");
+ r.append("non-fast forward"); //$NON-NLS-1$
break;
case REJECTED_CURRENT_BRANCH:
- r.append("branch is currently checked out");
+ r.append("branch is currently checked out"); //$NON-NLS-1$
break;
case REJECTED_MISSING_OBJECT:
if (cmd.getMessage() == null)
- r.append("missing object(s)");
+ r.append("missing object(s)"); //$NON-NLS-1$
else if (cmd.getMessage().length() == Constants.OBJECT_ID_STRING_LENGTH)
- r.append("object " + cmd.getMessage() + " missing");
+ r.append("object " + cmd.getMessage() + " missing"); //$NON-NLS-1$ //$NON-NLS-2$
else
r.append(cmd.getMessage());
break;
case REJECTED_OTHER_REASON:
if (cmd.getMessage() == null)
- r.append("unspecified reason");
+ r.append("unspecified reason"); //$NON-NLS-1$
else
r.append(cmd.getMessage());
break;
case LOCK_FAILURE:
- r.append("failed to lock");
+ r.append("failed to lock"); //$NON-NLS-1$
break;
case OK:
continue;
}
if (!forClient)
- r.append(")");
+ r.append(")"); //$NON-NLS-1$
out.sendString(r.toString());
}
}
final RevWalk rw = new RevWalk(transport.local);
try {
- final RevFlag PREREQ = rw.newFlag("PREREQ");
- final RevFlag SEEN = rw.newFlag("SEEN");
+ final RevFlag PREREQ = rw.newFlag("PREREQ"); //$NON-NLS-1$
+ final RevFlag SEEN = rw.newFlag("SEEN"); //$NON-NLS-1$
final Map<ObjectId, String> missing = new HashMap<ObjectId, String>();
final List<RevObject> commits = new ArrayList<RevObject>();
private static URIish createURI(Session session) {
URIish uri = new URIish();
- uri = uri.setScheme("ssh");
+ uri = uri.setScheme("ssh"); //$NON-NLS-1$
uri = uri.setUser(session.getUserName());
uri = uri.setHost(session.getHost());
uri = uri.setPort(session.getPort());
*/
public Daemon(final InetSocketAddress addr) {
myAddress = addr;
- processors = new ThreadGroup("Git-Daemon");
+ processors = new ThreadGroup("Git-Daemon"); //$NON-NLS-1$
repositoryResolver = (RepositoryResolver<DaemonClient>) RepositoryResolver.NONE;
String host = peer.getCanonicalHostName();
if (host == null)
host = peer.getHostAddress();
- String name = "anonymous";
- String email = name + "@" + host;
+ String name = "anonymous"; //$NON-NLS-1$
+ String email = name + "@" + host; //$NON-NLS-1$
rp.setRefLogIdent(new PersonIdent(name, email));
rp.setTimeout(getTimeout());
};
services = new DaemonService[] {
- new DaemonService("upload-pack", "uploadpack") {
+ new DaemonService("upload-pack", "uploadpack") { //$NON-NLS-1$ //$NON-NLS-2$
{
setEnabled(true);
}
OutputStream out = dc.getOutputStream();
up.upload(in, out, null);
}
- }, new DaemonService("receive-pack", "receivepack") {
+ }, new DaemonService("receive-pack", "receivepack") { //$NON-NLS-1$ //$NON-NLS-2$
{
setEnabled(false);
}
* the requested service type.
*/
public synchronized DaemonService getService(String name) {
- if (!name.startsWith("git-"))
- name = "git-" + name;
+ if (!name.startsWith("git-")) //$NON-NLS-1$
+ name = "git-" + name; //$NON-NLS-1$
for (final DaemonService s : services) {
if (s.getCommandName().equals(name))
return s;
myAddress = (InetSocketAddress) listenSock.getLocalSocketAddress();
run = true;
- acceptThread = new Thread(processors, "Git-Daemon-Accept") {
+ acceptThread = new Thread(processors, "Git-Daemon-Accept") { //$NON-NLS-1$
public void run() {
while (isRunning()) {
try {
if (peer instanceof InetSocketAddress)
dc.setRemoteAddress(((InetSocketAddress) peer).getAddress());
- new Thread(processors, "Git-Daemon-Client " + peer.toString()) {
+ new Thread(processors, "Git-Daemon-Client " + peer.toString()) { //$NON-NLS-1$
public void run() {
try {
dc.execute(s);
// git://thishost/path should always be name="/path" here
//
- if (!name.startsWith("/"))
+ if (!name.startsWith("/")) //$NON-NLS-1$
return null;
try {
private boolean overridable;
DaemonService(final String cmdName, final String cfgName) {
- command = cmdName.startsWith("git-") ? cmdName : "git-" + cmdName;
+ command = cmdName.startsWith("git-") ? cmdName : "git-" + cmdName; //$NON-NLS-1$ //$NON-NLS-2$
configKey = new SectionParser<ServiceConfig>() {
public ServiceConfig parse(final Config cfg) {
return new ServiceConfig(DaemonService.this, cfg, cfgName);
ServiceConfig(final DaemonService service, final Config cfg,
final String name) {
- enabled = cfg.getBoolean("daemon", name, service.isEnabled());
+ enabled = cfg.getBoolean("daemon", name, service.isEnabled()); //$NON-NLS-1$
}
}
// An error when opening the repo means the client is expecting a ref
// advertisement, so use that style of error.
PacketLineOut pktOut = new PacketLineOut(client.getOutputStream());
- pktOut.writeString("ERR " + e.getMessage() + "\n");
+ pktOut.writeString("ERR " + e.getMessage() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
db = null;
}
if (db == null)
final String type;
final String name;
if (sourceName.startsWith(R_HEADS)) {
- type = "branch";
+ type = "branch"; //$NON-NLS-1$
name = sourceName.substring(R_HEADS.length());
} else if (sourceName.startsWith(R_TAGS)) {
- type = "tag";
+ type = "tag"; //$NON-NLS-1$
name = sourceName.substring(R_TAGS.length());
} else if (sourceName.startsWith(R_REMOTES)) {
- type = "remote branch";
+ type = "remote branch"; //$NON-NLS-1$
name = sourceName.substring(R_REMOTES.length());
} else {
- type = "";
+ type = ""; //$NON-NLS-1$
name = sourceName;
}
pw.write(newValue.name());
pw.write('\t');
if (notForMerge)
- pw.write("not-for-merge");
+ pw.write("not-for-merge"); //$NON-NLS-1$
pw.write('\t');
pw.write(type);
- pw.write(" '");
+ pw.write(" '"); //$NON-NLS-1$
pw.write(name);
- pw.write("' of ");
+ pw.write("' of "); //$NON-NLS-1$
pw.write(sourceURI.toString());
- pw.write("\n");
+ pw.write("\n"); //$NON-NLS-1$
}
}
BatchRefUpdate batch = transport.local.getRefDatabase()
.newBatchUpdate()
.setAllowNonFastForwards(true)
- .setRefLogMessage("fetch", true);
+ .setRefLogMessage("fetch", true); //$NON-NLS-1$
final RevWalk walk = new RevWalk(transport.local);
try {
if (monitor instanceof BatchingProgressMonitor) {
private void fetchObjects(final ProgressMonitor monitor)
throws TransportException {
try {
- conn.setPackLockMessage("jgit fetch " + transport.uri);
+ conn.setPackLockMessage("jgit fetch " + transport.uri); //$NON-NLS-1$
conn.fetch(monitor, askFor.values(), have);
} finally {
packLocks.addAll(conn.getPackLocks());
File meta = transport.local.getDirectory();
if (meta == null)
return;
- final LockFile lock = new LockFile(new File(meta, "FETCH_HEAD"),
+ final LockFile lock = new LockFile(new File(meta, "FETCH_HEAD"), //$NON-NLS-1$
transport.local.getFS());
try {
if (lock.lock()) {
if (cmd.getResult() != ReceiveCommand.Result.OK)
return cmd.getRefName();
}
- return "";
+ return ""; //$NON-NLS-1$
}
}
/** Performs HTTP basic authentication (plaintext username/password). */
private static class Basic extends HttpAuthMethod {
- static final String NAME = "Basic";
+ static final String NAME = "Basic"; //$NON-NLS-1$
private String user;
@Override
void configureRequest(final HttpURLConnection conn) throws IOException {
- String ident = user + ":" + pass;
- String enc = Base64.encodeBytes(ident.getBytes("UTF-8"));
- conn.setRequestProperty(HDR_AUTHORIZATION, NAME + " " + enc);
+ String ident = user + ":" + pass; //$NON-NLS-1$
+ String enc = Base64.encodeBytes(ident.getBytes("UTF-8")); //$NON-NLS-1$
+ conn.setRequestProperty(HDR_AUTHORIZATION, NAME + " " + enc); //$NON-NLS-1$
}
}
/** Performs HTTP digest authentication. */
private static class Digest extends HttpAuthMethod {
- static final String NAME = "Digest";
+ static final String NAME = "Digest"; //$NON-NLS-1$
private static final Random PRNG = new Random();
Digest(String hdr) {
params = parse(hdr);
- final String qop = params.get("qop");
- if ("auth".equals(qop)) {
+ final String qop = params.get("qop"); //$NON-NLS-1$
+ if ("auth".equals(qop)) { //$NON-NLS-1$
final byte[] bin = new byte[8];
PRNG.nextBytes(bin);
- params.put("cnonce", Base64.encodeBytes(bin));
+ params.put("cnonce", Base64.encodeBytes(bin)); //$NON-NLS-1$
}
}
void configureRequest(final HttpURLConnection conn) throws IOException {
final Map<String, String> r = new LinkedHashMap<String, String>();
- final String realm = params.get("realm");
- final String nonce = params.get("nonce");
- final String cnonce = params.get("cnonce");
+ final String realm = params.get("realm"); //$NON-NLS-1$
+ final String nonce = params.get("nonce"); //$NON-NLS-1$
+ final String cnonce = params.get("cnonce"); //$NON-NLS-1$
final String uri = uri(conn.getURL());
- final String qop = params.get("qop");
+ final String qop = params.get("qop"); //$NON-NLS-1$
final String method = conn.getRequestMethod();
- final String A1 = user + ":" + realm + ":" + pass;
- final String A2 = method + ":" + uri;
+ final String A1 = user + ":" + realm + ":" + pass; //$NON-NLS-1$ //$NON-NLS-2$
+ final String A2 = method + ":" + uri; //$NON-NLS-1$
- r.put("username", user);
- r.put("realm", realm);
- r.put("nonce", nonce);
- r.put("uri", uri);
+ r.put("username", user); //$NON-NLS-1$
+ r.put("realm", realm); //$NON-NLS-1$
+ r.put("nonce", nonce); //$NON-NLS-1$
+ r.put("uri", uri); //$NON-NLS-1$
final String response, nc;
- if ("auth".equals(qop)) {
- nc = String.format("%08x", ++requestCount);
- response = KD(H(A1), nonce + ":" + nc + ":" + cnonce + ":"
- + qop
- + ":"
+ if ("auth".equals(qop)) { //$NON-NLS-1$
+ nc = String.format("%08x", ++requestCount); //$NON-NLS-1$
+ response = KD(H(A1), nonce + ":" + nc + ":" + cnonce + ":" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + qop + ":" //$NON-NLS-1$
+ H(A2));
} else {
nc = null;
- response = KD(H(A1), nonce + ":" + H(A2));
+ response = KD(H(A1), nonce + ":" + H(A2)); //$NON-NLS-1$
}
- r.put("response", response);
- if (params.containsKey("algorithm"))
- r.put("algorithm", "MD5");
+ r.put("response", response); //$NON-NLS-1$
+ if (params.containsKey("algorithm")) //$NON-NLS-1$
+ r.put("algorithm", "MD5"); //$NON-NLS-1$ //$NON-NLS-2$
if (cnonce != null && qop != null)
- r.put("cnonce", cnonce);
- if (params.containsKey("opaque"))
- r.put("opaque", params.get("opaque"));
+ r.put("cnonce", cnonce); //$NON-NLS-1$
+ if (params.containsKey("opaque")) //$NON-NLS-1$
+ r.put("opaque", params.get("opaque")); //$NON-NLS-1$ //$NON-NLS-2$
if (qop != null)
- r.put("qop", qop);
+ r.put("qop", qop); //$NON-NLS-1$
if (nc != null)
- r.put("nc", nc);
+ r.put("nc", nc); //$NON-NLS-1$
StringBuilder v = new StringBuilder();
for (Map.Entry<String, String> e : r.entrySet()) {
if (v.length() > 0)
- v.append(", ");
+ v.append(", "); //$NON-NLS-1$
v.append(e.getKey());
v.append('=');
v.append('"');
v.append(e.getValue());
v.append('"');
}
- conn.setRequestProperty(HDR_AUTHORIZATION, NAME + " " + v);
+ conn.setRequestProperty(HDR_AUTHORIZATION, NAME + " " + v); //$NON-NLS-1$
}
private static String uri(URL u) {
StringBuilder r = new StringBuilder();
r.append(u.getProtocol());
- r.append("://");
+ r.append("://"); //$NON-NLS-1$
r.append(u.getHost());
if (0 < u.getPort()) {
- if (u.getPort() == 80 && "http".equals(u.getProtocol())) {
+ if (u.getPort() == 80 && "http".equals(u.getProtocol())) { //$NON-NLS-1$
/* nothing */
} else if (u.getPort() == 443
- && "https".equals(u.getProtocol())) {
+ && "https".equals(u.getProtocol())) { //$NON-NLS-1$
/* nothing */
} else {
r.append(':').append(u.getPort());
private static String H(String data) {
try {
MessageDigest md = newMD5();
- md.update(data.getBytes("UTF-8"));
+ md.update(data.getBytes("UTF-8")); //$NON-NLS-1$
return LHEX(md.digest());
} catch (UnsupportedEncodingException e) {
- throw new RuntimeException("UTF-8 encoding not available", e);
+ throw new RuntimeException("UTF-8 encoding not available", e); //$NON-NLS-1$
}
}
private static String KD(String secret, String data) {
try {
MessageDigest md = newMD5();
- md.update(secret.getBytes("UTF-8"));
+ md.update(secret.getBytes("UTF-8")); //$NON-NLS-1$
md.update((byte) ':');
- md.update(data.getBytes("UTF-8"));
+ md.update(data.getBytes("UTF-8")); //$NON-NLS-1$
return LHEX(md.digest());
} catch (UnsupportedEncodingException e) {
- throw new RuntimeException("UTF-8 encoding not available", e);
+ throw new RuntimeException("UTF-8 encoding not available", e); //$NON-NLS-1$
}
}
private static MessageDigest newMD5() {
try {
- return MessageDigest.getInstance("MD5");
+ return MessageDigest.getInstance("MD5"); //$NON-NLS-1$
} catch (NoSuchAlgorithmException e) {
- throw new RuntimeException("No MD5 available", e);
+ throw new RuntimeException("No MD5 available", e); //$NON-NLS-1$
}
}
// if authentication failed maybe credentials changed at the
// remote end therefore reset credentials and retry
if (credentialsProvider != null && e.getCause() == null
- && e.getMessage().equals("Auth fail")
+ && e.getMessage().equals("Auth fail") //$NON-NLS-1$
&& retries < 3) {
credentialsProvider.reset(uri);
session = createSession(credentialsProvider, fs, user,
final String strictHostKeyCheckingPolicy = hc
.getStrictHostKeyChecking();
if (strictHostKeyCheckingPolicy != null)
- session.setConfig("StrictHostKeyChecking",
+ session.setConfig("StrictHostKeyChecking", //$NON-NLS-1$
strictHostKeyCheckingPolicy);
final String pauth = hc.getPreferredAuthentications();
if (pauth != null)
- session.setConfig("PreferredAuthentications", pauth);
+ session.setConfig("PreferredAuthentications", pauth); //$NON-NLS-1$
if (credentialsProvider != null
&& (!hc.isBatchMode() || !credentialsProvider.isInteractive())) {
session.setUserInfo(new CredentialsProviderUserInfo(session,
final File home = fs.userHome();
if (home == null)
return;
- final File known_hosts = new File(new File(home, ".ssh"), "known_hosts");
+ final File known_hosts = new File(new File(home, ".ssh"), "known_hosts"); //$NON-NLS-1$ //$NON-NLS-2$
try {
final FileInputStream in = new FileInputStream(known_hosts);
try {
final File home = fs.userHome();
if (home == null)
return;
- final File sshdir = new File(home, ".ssh");
+ final File sshdir = new File(home, ".ssh"); //$NON-NLS-1$
if (sshdir.isDirectory()) {
- loadIdentity(sch, new File(sshdir, "identity"));
- loadIdentity(sch, new File(sshdir, "id_rsa"));
- loadIdentity(sch, new File(sshdir, "id_dsa"));
+ loadIdentity(sch, new File(sshdir, "identity")); //$NON-NLS-1$
+ loadIdentity(sch, new File(sshdir, "id_rsa")); //$NON-NLS-1$
+ loadIdentity(sch, new File(sshdir, "id_dsa")); //$NON-NLS-1$
}
}
* on problems getting the channel.
*/
public Channel getSftpChannel() throws JSchException {
- return sock.openChannel("sftp");
+ return sock.openChannel("sftp"); //$NON-NLS-1$
}
/**
throws TransportException, IOException {
timeout = tms;
try {
- channel = (ChannelExec) sock.openChannel("exec");
+ channel = (ChannelExec) sock.openChannel("exec"); //$NON-NLS-1$
channel.setCommand(commandName);
setupStreams();
channel.connect(timeout > 0 ? timeout * 1000 : 0);
public static OpenSshConfig get(FS fs) {
File home = fs.userHome();
if (home == null)
- home = new File(".").getAbsoluteFile();
+ home = new File(".").getAbsoluteFile(); //$NON-NLS-1$
- final File config = new File(new File(home, ".ssh"), Constants.CONFIG);
+ final File config = new File(new File(home, ".ssh"), Constants.CONFIG); //$NON-NLS-1$
final OpenSshConfig osc = new OpenSshConfig(home, config);
osc.refresh();
return osc;
while ((line = br.readLine()) != null) {
line = line.trim();
- if (line.length() == 0 || line.startsWith("#"))
+ if (line.length() == 0 || line.startsWith("#")) //$NON-NLS-1$
continue;
- final String[] parts = line.split("[ \t]*[= \t]", 2);
+ final String[] parts = line.split("[ \t]*[= \t]", 2); //$NON-NLS-1$
final String keyword = parts[0].trim();
final String argValue = parts[1].trim();
- if (StringUtils.equalsIgnoreCase("Host", keyword)) {
+ if (StringUtils.equalsIgnoreCase("Host", keyword)) { //$NON-NLS-1$
current.clear();
- for (final String pattern : argValue.split("[ \t]")) {
+ for (final String pattern : argValue.split("[ \t]")) { //$NON-NLS-1$
final String name = dequote(pattern);
Host c = m.get(name);
if (c == null) {
continue;
}
- if (StringUtils.equalsIgnoreCase("HostName", keyword)) {
+ if (StringUtils.equalsIgnoreCase("HostName", keyword)) { //$NON-NLS-1$
for (final Host c : current)
if (c.hostName == null)
c.hostName = dequote(argValue);
- } else if (StringUtils.equalsIgnoreCase("User", keyword)) {
+ } else if (StringUtils.equalsIgnoreCase("User", keyword)) { //$NON-NLS-1$
for (final Host c : current)
if (c.user == null)
c.user = dequote(argValue);
- } else if (StringUtils.equalsIgnoreCase("Port", keyword)) {
+ } else if (StringUtils.equalsIgnoreCase("Port", keyword)) { //$NON-NLS-1$
try {
final int port = Integer.parseInt(dequote(argValue));
for (final Host c : current)
} catch (NumberFormatException nfe) {
// Bad port number. Don't set it.
}
- } else if (StringUtils.equalsIgnoreCase("IdentityFile", keyword)) {
+ } else if (StringUtils.equalsIgnoreCase("IdentityFile", keyword)) { //$NON-NLS-1$
for (final Host c : current)
if (c.identityFile == null)
c.identityFile = toFile(dequote(argValue));
- } else if (StringUtils.equalsIgnoreCase("PreferredAuthentications", keyword)) {
+ } else if (StringUtils.equalsIgnoreCase(
+ "PreferredAuthentications", keyword)) { //$NON-NLS-1$
for (final Host c : current)
if (c.preferredAuthentications == null)
c.preferredAuthentications = nows(dequote(argValue));
- } else if (StringUtils.equalsIgnoreCase("BatchMode", keyword)) {
+ } else if (StringUtils.equalsIgnoreCase("BatchMode", keyword)) { //$NON-NLS-1$
for (final Host c : current)
if (c.batchMode == null)
c.batchMode = yesno(dequote(argValue));
- } else if (StringUtils.equalsIgnoreCase("StrictHostKeyChecking", keyword)) {
+ } else if (StringUtils.equalsIgnoreCase(
+ "StrictHostKeyChecking", keyword)) { //$NON-NLS-1$
String value = dequote(argValue);
for (final Host c : current)
if (c.strictHostKeyChecking == null)
}
private static String dequote(final String value) {
- if (value.startsWith("\"") && value.endsWith("\""))
+ if (value.startsWith("\"") && value.endsWith("\"")) //$NON-NLS-1$ //$NON-NLS-2$
return value.substring(1, value.length() - 1);
return value;
}
}
private static Boolean yesno(final String value) {
- if (StringUtils.equalsIgnoreCase("yes", value))
+ if (StringUtils.equalsIgnoreCase("yes", value)) //$NON-NLS-1$
return Boolean.TRUE;
return Boolean.FALSE;
}
private File toFile(final String path) {
- if (path.startsWith("~/"))
+ if (path.startsWith("~/")) //$NON-NLS-1$
return new File(home, path.substring(2));
File ret = new File(path);
if (ret.isAbsolute())
static String userName() {
return AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return System.getProperty("user.name");
+ return System.getProperty("user.name"); //$NON-NLS-1$
}
});
}
* remote produced no additional messages.
*/
public String getMessages() {
- return messageBuffer != null ? messageBuffer.toString() : "";
+ return messageBuffer != null ? messageBuffer.toString() : ""; //$NON-NLS-1$
}
void addMessages(final String msg) {
if (messageBuffer == null)
messageBuffer = new StringBuilder();
messageBuffer.append(msg);
- if (!msg.endsWith("\n"))
+ if (!msg.endsWith("\n")) //$NON-NLS-1$
messageBuffer.append('\n');
}
}
if (bAvail != 0 && !expectDataAfterPackFooter)
throw new CorruptObjectException(MessageFormat.format(
JGitText.get().expectedEOFReceived,
- "\\x" + Integer.toHexString(buf[bOffset] & 0xff)));
+ "\\x" + Integer.toHexString(buf[bOffset] & 0xff))); //$NON-NLS-1$
if (isCheckEofAfterPackFooter()) {
int eof = in.read();
if (0 <= eof)
throw new CorruptObjectException(MessageFormat.format(
JGitText.get().expectedEOFReceived,
- "\\x" + Integer.toHexString(eof)));
+ "\\x" + Integer.toHexString(eof))); //$NON-NLS-1$
} else if (bAvail > 0 && expectDataAfterPackFooter) {
in.reset();
IO.skipFully(in, bOffset);
final String line = readString();
if (line.length() == 0)
throw new PackProtocolException(JGitText.get().expectedACKNAKFoundEOF);
- if ("NAK".equals(line))
+ if ("NAK".equals(line)) //$NON-NLS-1$
return AckNackResult.NAK;
- if (line.startsWith("ACK ")) {
+ if (line.startsWith("ACK ")) { //$NON-NLS-1$
returnedId.fromString(line.substring(4, 44));
if (line.length() == 44)
return AckNackResult.ACK;
final String arg = line.substring(44);
- if (arg.equals(" continue"))
+ if (arg.equals(" continue")) //$NON-NLS-1$
return AckNackResult.ACK_CONTINUE;
- else if (arg.equals(" common"))
+ else if (arg.equals(" common")) //$NON-NLS-1$
return AckNackResult.ACK_COMMON;
- else if (arg.equals(" ready"))
+ else if (arg.equals(" ready")) //$NON-NLS-1$
return AckNackResult.ACK_READY;
}
- if (line.startsWith("ERR "))
+ if (line.startsWith("ERR ")) //$NON-NLS-1$
throw new PackProtocolException(line.substring(4));
throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedACKNAKGot, line));
}
len -= 4; // length header (4 bytes)
if (len == 0)
- return "";
+ return ""; //$NON-NLS-1$
byte[] raw;
if (len <= lineBuffer.length)
return len;
} catch (ArrayIndexOutOfBoundsException err) {
throw new IOException(MessageFormat.format(JGitText.get().invalidPacketLineHeader,
- "" + (char) lineBuffer[0] + (char) lineBuffer[1]
+ "" + (char) lineBuffer[0] + (char) lineBuffer[1] //$NON-NLS-1$
+ (char) lineBuffer[2] + (char) lineBuffer[3]));
}
}
ru.setForceUpdate(rp.isAllowNonFastForwards());
ru.setExpectedOldObjectId(getOldId());
ru.setNewObjectId(getNewId());
- ru.setRefLogMessage("push", true);
+ ru.setRefLogMessage("push", true); //$NON-NLS-1$
setResult(ru.update(rp.getRevWalk()));
break;
}
JGitText.get().lockError, err.getMessage()));
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return getType().name() + ": " + getOldId().name() + " "
if (echoCommandFailures && msgOut != null) {
sendStatusReport(false, unpackError, new Reporter() {
void sendString(final String s) throws IOException {
- msgOut.write(Constants.encode(s + "\n"));
+ msgOut.write(Constants.encode(s + "\n")); //$NON-NLS-1$
}
});
msgOut.flush();
}
sendStatusReport(true, unpackError, new Reporter() {
void sendString(final String s) throws IOException {
- pckOut.writeString(s + "\n");
+ pckOut.writeString(s + "\n"); //$NON-NLS-1$
}
});
pckOut.end();
} else if (msgOut != null) {
sendStatusReport(false, unpackError, new Reporter() {
void sendString(final String s) throws IOException {
- msgOut.write(Constants.encode(s + "\n"));
+ msgOut.write(Constants.encode(s + "\n")); //$NON-NLS-1$
}
});
}
@Override
protected String getLockMessageProcessName() {
- return "jgit receive-pack";
+ return "jgit receive-pack"; //$NON-NLS-1$
}
}
}
if (ref.getPeeledObjectId() != null)
- advertiseAny(ref.getPeeledObjectId(), ref.getName() + "^{}");
+ advertiseAny(ref.getPeeledObjectId(), ref.getName() + "^{}"); //$NON-NLS-1$
}
return sent;
}
* advertisement record.
*/
public void advertiseHave(AnyObjectId id) throws IOException {
- advertiseAnyOnce(id, ".have");
+ advertiseAnyOnce(id, ".have"); //$NON-NLS-1$
}
/** @return true if no advertisements have been sent yet. */
* Suffix for wildcard ref spec component, that indicate matching all refs
* with specified prefix.
*/
- public static final String WILDCARD_SUFFIX = "/*";
+ public static final String WILDCARD_SUFFIX = "/*"; //$NON-NLS-1$
/**
* Check whether provided string is a wildcard ref spec component.
*/
public RefSpec(final String spec) {
String s = spec;
- if (s.startsWith("+")) {
+ if (s.startsWith("+")) { //$NON-NLS-1$
force = true;
s = s.substring(1);
}
public class RemoteConfig implements Serializable {
private static final long serialVersionUID = 1L;
- private static final String SECTION = "remote";
+ private static final String SECTION = "remote"; //$NON-NLS-1$
- private static final String KEY_URL = "url";
+ private static final String KEY_URL = "url"; //$NON-NLS-1$
- private static final String KEY_PUSHURL = "pushurl";
+ private static final String KEY_PUSHURL = "pushurl"; //$NON-NLS-1$
- private static final String KEY_FETCH = "fetch";
+ private static final String KEY_FETCH = "fetch"; //$NON-NLS-1$
- private static final String KEY_PUSH = "push";
+ private static final String KEY_PUSH = "push"; //$NON-NLS-1$
- private static final String KEY_UPLOADPACK = "uploadpack";
+ private static final String KEY_UPLOADPACK = "uploadpack"; //$NON-NLS-1$
- private static final String KEY_RECEIVEPACK = "receivepack";
+ private static final String KEY_RECEIVEPACK = "receivepack"; //$NON-NLS-1$
- private static final String KEY_TAGOPT = "tagopt";
+ private static final String KEY_TAGOPT = "tagopt"; //$NON-NLS-1$
- private static final String KEY_MIRROR = "mirror";
+ private static final String KEY_MIRROR = "mirror"; //$NON-NLS-1$
- private static final String KEY_TIMEOUT = "timeout";
+ private static final String KEY_TIMEOUT = "timeout"; //$NON-NLS-1$
- private static final String KEY_INSTEADOF = "insteadof";
+ private static final String KEY_INSTEADOF = "insteadof"; //$NON-NLS-1$
- private static final String KEY_PUSHINSTEADOF = "pushinsteadof";
+ private static final String KEY_PUSHINSTEADOF = "pushinsteadof"; //$NON-NLS-1$
private static final boolean DEFAULT_MIRROR = false;
/** Default value for {@link #getUploadPack()} if not specified. */
- public static final String DEFAULT_UPLOAD_PACK = "git-upload-pack";
+ public static final String DEFAULT_UPLOAD_PACK = "git-upload-pack"; //$NON-NLS-1$
/** Default value for {@link #getReceivePack()} if not specified. */
- public static final String DEFAULT_RECEIVE_PACK = "git-receive-pack";
+ public static final String DEFAULT_RECEIVE_PACK = "git-receive-pack"; //$NON-NLS-1$
/**
* Parse all remote blocks in an existing configuration file, looking for
if (localName != null && localDb != null) {
localUpdate = localDb.updateRef(localName);
localUpdate.setForceUpdate(true);
- localUpdate.setRefLogMessage("push", true);
+ localUpdate.setRefLogMessage("push", true); //$NON-NLS-1$
localUpdate.setNewObjectId(newObjectId);
trackingRefUpdate = new TrackingRefUpdate(
true,
trackingRefUpdate.setResult(localUpdate.update(walk));
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
- return "RemoteRefUpdate[remoteName=" + remoteName + ", " + status
- + ", " + (expectedOldObjectId!=null ? expectedOldObjectId.name() : "(null)")
- + "..." + (newObjectId != null ? newObjectId.name() : "(null)")
+ return "RemoteRefUpdate[remoteName="
+ + remoteName
+ + ", "
+ + status
+ + ", "
+ + (expectedOldObjectId != null ? expectedOldObjectId.name()
+ : "(null)") + "..."
+ + (newObjectId != null ? newObjectId.name() : "(null)")
+ (fastForward ? ", fastForward" : "")
- + ", srcRef=" + srcRef + (forceUpdate ? ", forceUpdate" : "") + ", message=" + (message != null ? "\""
- + message + "\"" : "null") + "]";
+ + ", srcRef=" + srcRef
+ + (forceUpdate ? ", forceUpdate" : "") + ", message="
+ + (message != null ? "\"" + message + "\"" : "null") + "]";
}
}
static final int CH_ERROR = 3;
private static Pattern P_UNBOUNDED = Pattern
- .compile("^([\\w ]+): +(\\d+)(?:, done\\.)? *[\r\n]$");
+ .compile("^([\\w ]+): +(\\d+)(?:, done\\.)? *[\r\n]$"); //$NON-NLS-1$
private static Pattern P_BOUNDED = Pattern
- .compile("^([\\w ]+): +\\d+% +\\( *(\\d+)/ *(\\d+)\\)(?:, done\\.)? *[\r\n]$");
+ .compile("^([\\w ]+): +\\d+% +\\( *(\\d+)/ *(\\d+)\\)(?:, done\\.)? *[\r\n]$"); //$NON-NLS-1$
private final InputStream rawIn;
private final Writer messages;
- private String progressBuffer = "";
+ private String progressBuffer = ""; //$NON-NLS-1$
private String currentTask;
pckIn = new PacketLineIn(rawIn);
monitor = progress;
messages = messageStream;
- currentTask = "";
+ currentTask = ""; //$NON-NLS-1$
}
@Override
protected void onUpdate(String taskName, int workCurr) {
StringBuilder s = new StringBuilder();
format(s, taskName, workCurr);
- s.append(" \r");
+ s.append(" \r"); //$NON-NLS-1$
send(s);
}
protected void onEndTask(String taskName, int workCurr) {
StringBuilder s = new StringBuilder();
format(s, taskName, workCurr);
- s.append(", done\n");
+ s.append(", done\n"); //$NON-NLS-1$
send(s);
}
private void format(StringBuilder s, String taskName, int workCurr) {
s.append(taskName);
- s.append(": ");
+ s.append(": "); //$NON-NLS-1$
s.append(workCurr);
}
protected void onUpdate(String taskName, int cmp, int totalWork, int pcnt) {
StringBuilder s = new StringBuilder();
format(s, taskName, cmp, totalWork, pcnt);
- s.append(" \r");
+ s.append(" \r"); //$NON-NLS-1$
send(s);
}
protected void onEndTask(String taskName, int cmp, int totalWork, int pcnt) {
StringBuilder s = new StringBuilder();
format(s, taskName, cmp, totalWork, pcnt);
- s.append("\n");
+ s.append("\n"); //$NON-NLS-1$
send(s);
}
private void format(StringBuilder s, String taskName, int cmp,
int totalWork, int pcnt) {
s.append(taskName);
- s.append(": ");
+ s.append(": "); //$NON-NLS-1$
if (pcnt < 100)
s.append(' ');
if (pcnt < 10)
s.append(' ');
s.append(pcnt);
- s.append("% (");
+ s.append("% ("); //$NON-NLS-1$
s.append(cmp);
- s.append("/");
+ s.append("/"); //$NON-NLS-1$
s.append(totalWork);
- s.append(")");
+ s.append(")"); //$NON-NLS-1$
}
private void send(StringBuilder s) {
* prove that we already have (or will have when the fetch completes) the
* object the annotated tag peels (dereferences) to.
*/
- AUTO_FOLLOW(""),
+ AUTO_FOLLOW(""), //$NON-NLS-1$
/**
* Never fetch tags, even if we have the thing it points at.
* publishes annotated tags, but you are not interested in the tags and only
* want their branches.
*/
- NO_TAGS("--no-tags"),
+ NO_TAGS("--no-tags"), //$NON-NLS-1$
/**
* Always fetch tags, even if we do not have the thing it points at.
* hundreds of megabytes of objects to be fetched if the receiving
* repository does not yet have the necessary dependencies.
*/
- FETCH_TAGS("--tags");
+ FETCH_TAGS("--tags"); //$NON-NLS-1$
private final String option;
}
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
private final boolean fsckObjects;
private TransferConfig(final Config rc) {
- fsckObjects = rc.getBoolean("receive", "fsckobjects", false);
+ fsckObjects = rc.getBoolean("receive", "fsckobjects", false); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
private static Enumeration<URL> catalogs(ClassLoader ldr) {
try {
- String prefix = "META-INF/services/";
+ String prefix = "META-INF/services/"; //$NON-NLS-1$
String name = prefix + Transport.class.getName();
return ldr.getResources(name);
} catch (IOException err) {
BufferedReader br;
try {
InputStream urlIn = url.openStream();
- br = new BufferedReader(new InputStreamReader(urlIn, "UTF-8"));
+ br = new BufferedReader(new InputStreamReader(urlIn, "UTF-8")); //$NON-NLS-1$
} catch (IOException err) {
// If we cannot read from the service list, go to the next.
//
* Acts as --tags.
*/
public static final RefSpec REFSPEC_TAGS = new RefSpec(
- "refs/tags/*:refs/tags/*");
+ "refs/tags/*:refs/tags/*"); //$NON-NLS-1$
/**
* Specification for push operation, to push all refs under refs/heads. Acts
* as --all.
*/
public static final RefSpec REFSPEC_PUSH_ALL = new RefSpec(
- "refs/heads/*:refs/heads/*");
+ "refs/heads/*:refs/heads/*"); //$NON-NLS-1$
/** The repository this transport fetches into, or pushes out of. */
protected final Repository local;
* @see WalkPushConnection
*/
public class TransportAmazonS3 extends HttpTransport implements WalkTransport {
- static final String S3_SCHEME = "amazon-s3";
+ static final String S3_SCHEME = "amazon-s3"; //$NON-NLS-1$
static final TransportProtocol PROTO_S3 = new TransportProtocol() {
public String getName() {
- return "Amazon S3";
+ return "Amazon S3"; //$NON-NLS-1$
}
public Set<String> getSchemes() {
bucket = uri.getHost();
String p = uri.getPath();
- if (p.startsWith("/"))
+ if (p.startsWith("/")) //$NON-NLS-1$
p = p.substring(1);
- if (p.endsWith("/"))
+ if (p.endsWith("/")) //$NON-NLS-1$
p = p.substring(0, p.length() - 1);
keyPrefix = p;
}
return loadPropertiesFile(propsFile);
Properties props = new Properties();
- props.setProperty("accesskey", uri.getUser());
- props.setProperty("secretkey", uri.getPass());
+ props.setProperty("accesskey", uri.getUser()); //$NON-NLS-1$
+ props.setProperty("secretkey", uri.getPass()); //$NON-NLS-1$
return props;
}
@Override
public FetchConnection openFetch() throws TransportException {
- final DatabaseS3 c = new DatabaseS3(bucket, keyPrefix + "/objects");
+ final DatabaseS3 c = new DatabaseS3(bucket, keyPrefix + "/objects"); //$NON-NLS-1$
final WalkFetchConnection r = new WalkFetchConnection(this, c);
r.available(c.readAdvertisedRefs());
return r;
@Override
public PushConnection openPush() throws TransportException {
- final DatabaseS3 c = new DatabaseS3(bucket, keyPrefix + "/objects");
+ final DatabaseS3 c = new DatabaseS3(bucket, keyPrefix + "/objects"); //$NON-NLS-1$
final WalkPushConnection r = new WalkPushConnection(this, c);
r.available(c.readAdvertisedRefs());
return r;
}
private String resolveKey(String subpath) {
- if (subpath.endsWith("/"))
+ if (subpath.endsWith("/")) //$NON-NLS-1$
subpath = subpath.substring(0, subpath.length() - 1);
String k = objectsKey;
while (subpath.startsWith(ROOT_DIR)) {
k = k.substring(0, k.lastIndexOf('/'));
subpath = subpath.substring(3);
}
- return k + "/" + subpath;
+ return k + "/" + subpath; //$NON-NLS-1$
}
@Override
URIish u = new URIish();
u = u.setScheme(S3_SCHEME);
u = u.setHost(bucketName);
- u = u.setPath("/" + objectsKey);
+ u = u.setPath("/" + objectsKey); //$NON-NLS-1$
return u;
}
@Override
Collection<String> getPackNames() throws IOException {
final HashSet<String> have = new HashSet<String>();
- have.addAll(s3.list(bucket, resolveKey("pack")));
+ have.addAll(s3.list(bucket, resolveKey("pack"))); //$NON-NLS-1$
final Collection<String> packs = new ArrayList<String>();
for (final String n : have) {
- if (!n.startsWith("pack-") || !n.endsWith(".pack"))
+ if (!n.startsWith("pack-") || !n.endsWith(".pack")) //$NON-NLS-1$ //$NON-NLS-2$
continue;
- final String in = n.substring(0, n.length() - 5) + ".idx";
+ final String in = n.substring(0, n.length() - 5) + ".idx"; //$NON-NLS-1$
if (have.contains(in))
packs.add(n);
}
throws TransportException {
try {
for (final String n : s3.list(bucket, resolveKey(ROOT_DIR
- + "refs")))
- readRef(avail, "refs/" + n);
+ + "refs"))) //$NON-NLS-1$
+ readRef(avail, "refs/" + n); //$NON-NLS-1$
} catch (IOException e) {
throw new TransportException(getURI(), JGitText.get().cannotListRefs, e);
}
if (s == null)
throw new TransportException(getURI(), MessageFormat.format(JGitText.get().transportExceptionEmptyRef, rn));
- if (s.startsWith("ref: ")) {
- final String target = s.substring("ref: ".length());
+ if (s.startsWith("ref: ")) { //$NON-NLS-1$
+ final String target = s.substring("ref: ".length()); //$NON-NLS-1$
Ref r = avail.get(target);
if (r == null)
r = readRef(avail, target);
/**
* Bundle signature
*/
- public static final String V2_BUNDLE_SIGNATURE = "# v2 git bundle";
+ public static final String V2_BUNDLE_SIGNATURE = "# v2 git bundle"; //$NON-NLS-1$
}
@Override
public Transport open(URIish uri, Repository local, String remoteName)
throws NotSupportedException, TransportException {
- if ("bundle".equals(uri.getScheme())) {
- File path = local.getFS().resolve(new File("."), uri.getPath());
+ if ("bundle".equals(uri.getScheme())) { //$NON-NLS-1$
+ File path = local.getFS().resolve(new File("."), uri.getPath()); //$NON-NLS-1$
return new TransportBundleFile(local, uri, path);
}
cmd.append(' ');
cmd.append(uri.getPath());
cmd.append('\0');
- cmd.append("host=");
+ cmd.append("host="); //$NON-NLS-1$
cmd.append(uri.getHost());
if (uri.getPort() > 0 && uri.getPort() != GIT_PORT) {
- cmd.append(":");
+ cmd.append(":"); //$NON-NLS-1$
cmd.append(uri.getPort());
}
cmd.append('\0');
sOut = new SafeBufferedOutputStream(sOut);
init(sIn, sOut);
- service("git-upload-pack", pckOut);
+ service("git-upload-pack", pckOut); //$NON-NLS-1$
} catch (IOException err) {
close();
throw new TransportException(uri,
sOut = new SafeBufferedOutputStream(sOut);
init(sIn, sOut);
- service("git-receive-pack", pckOut);
+ service("git-receive-pack", pckOut); //$NON-NLS-1$
} catch (IOException err) {
close();
throw new TransportException(uri,
String commandFor(final String exe) {
String path = uri.getPath();
- if (uri.getScheme() != null && uri.getPath().startsWith("/~"))
+ if (uri.getScheme() != null && uri.getPath().startsWith("/~")) //$NON-NLS-1$
path = (uri.getPath().substring(1));
final StringBuilder cmd = new StringBuilder();
return nf;
String path = uri.getPath();
- if (uri.getScheme() != null && uri.getPath().startsWith("/~"))
+ if (uri.getScheme() != null && uri.getPath().startsWith("/~")) //$NON-NLS-1$
path = uri.getPath().substring(1);
final StringBuilder pfx = new StringBuilder();
- pfx.append("fatal: ");
+ pfx.append("fatal: "); //$NON-NLS-1$
pfx.append(QuotedString.BOURNE.quote(path));
- pfx.append(": ");
+ pfx.append(": "); //$NON-NLS-1$
if (why.startsWith(pfx.toString()))
why = why.substring(pfx.length());
}
private static boolean useExtSession() {
- return SystemReader.getInstance().getenv("GIT_SSH") != null;
+ return SystemReader.getInstance().getenv("GIT_SSH") != null; //$NON-NLS-1$
}
private class ExtSession implements RemoteSession {
public Process exec(String command, int timeout)
throws TransportException {
- String ssh = SystemReader.getInstance().getenv("GIT_SSH");
- boolean putty = ssh.toLowerCase().contains("plink");
+ String ssh = SystemReader.getInstance().getenv("GIT_SSH"); //$NON-NLS-1$
+ boolean putty = ssh.toLowerCase().contains("plink"); //$NON-NLS-1$
List<String> args = new ArrayList<String>();
args.add(ssh);
- if (putty && !ssh.toLowerCase().contains("tortoiseplink"))
- args.add("-batch");
+ if (putty && !ssh.toLowerCase().contains("tortoiseplink")) //$NON-NLS-1$
+ args.add("-batch"); //$NON-NLS-1$
if (0 < getURI().getPort()) {
- args.add(putty ? "-P" : "-p");
+ args.add(putty ? "-P" : "-p"); //$NON-NLS-1$ //$NON-NLS-2$
args.add(String.valueOf(getURI().getPort()));
}
if (getURI().getUser() != null)
- args.add(getURI().getUser() + "@" + getURI().getHost());
+ args.add(getURI().getUser() + "@" + getURI().getHost()); //$NON-NLS-1$
else
args.add(getURI().getHost());
args.add(command);
HttpConfig(final Config rc) {
postBuffer = rc.getInt("http", "postbuffer", 1 * 1024 * 1024); //$NON-NLS-1$ //$NON-NLS-2$
- sslVerify = rc.getBoolean("http", "sslVerify", true);
+ sslVerify = rc.getBoolean("http", "sslVerify", true); //$NON-NLS-1$ //$NON-NLS-2$
}
private HttpConfig() {
final Proxy proxy = HttpSupport.proxyFor(proxySelector, u);
HttpURLConnection conn = (HttpURLConnection) u.openConnection(proxy);
- if (!http.sslVerify && "https".equals(u.getProtocol())) {
+ if (!http.sslVerify && "https".equals(u.getProtocol())) { //$NON-NLS-1$
disableSslVerify(conn);
}
throws IOException {
final TrustManager[] trustAllCerts = new TrustManager[] { new DummyX509TrustManager() };
try {
- SSLContext ctx = SSLContext.getInstance("SSL");
+ SSLContext ctx = SSLContext.getInstance("SSL"); //$NON-NLS-1$
ctx.init(null, trustAllCerts, null);
final HttpsURLConnection sslConn = (HttpsURLConnection) conn;
sslConn.setSSLSocketFactory(ctx.getSocketFactory());
@Override
public FetchConnection openFetch() throws TransportException {
final String up = getOptionUploadPack();
- if ("git-upload-pack".equals(up) || "git upload-pack".equals(up))
+ if ("git-upload-pack".equals(up) || "git upload-pack".equals(up)) //$NON-NLS-1$ //$NON-NLS-2$
return new InternalLocalFetchConnection();
return new ForkLocalFetchConnection();
}
public PushConnection openPush() throws NotSupportedException,
TransportException {
final String rp = getOptionReceivePack();
- if ("git-receive-pack".equals(rp) || "git receive-pack".equals(rp))
+ if ("git-receive-pack".equals(rp) || "git receive-pack".equals(rp)) //$NON-NLS-1$ //$NON-NLS-2$
return new InternalLocalPushConnection();
return new ForkLocalPushConnection();
}
protected Process spawn(final String cmd)
throws TransportException {
try {
- String[] args = { "." };
+ String[] args = { "." }; //$NON-NLS-1$
ProcessBuilder proc = local.getFS().runInShell(cmd, args);
proc.directory(remoteGitDir);
// Remove the same variables CGit does.
Map<String, String> env = proc.environment();
- env.remove("GIT_ALTERNATE_OBJECT_DIRECTORIES");
- env.remove("GIT_CONFIG");
- env.remove("GIT_CONFIG_PARAMETERS");
- env.remove("GIT_DIR");
- env.remove("GIT_WORK_TREE");
- env.remove("GIT_GRAFT_FILE");
- env.remove("GIT_INDEX_FILE");
- env.remove("GIT_NO_REPLACE_OBJECTS");
+ env.remove("GIT_ALTERNATE_OBJECT_DIRECTORIES"); //$NON-NLS-1$
+ env.remove("GIT_CONFIG"); //$NON-NLS-1$
+ env.remove("GIT_CONFIG_PARAMETERS"); //$NON-NLS-1$
+ env.remove("GIT_DIR"); //$NON-NLS-1$
+ env.remove("GIT_WORK_TREE"); //$NON-NLS-1$
+ env.remove("GIT_GRAFT_FILE"); //$NON-NLS-1$
+ env.remove("GIT_INDEX_FILE"); //$NON-NLS-1$
+ env.remove("GIT_NO_REPLACE_OBJECTS"); //$NON-NLS-1$
return proc.start();
} catch (IOException err) {
throw new TransportException(uri, JGitText.get().cannotConnectPipes, err);
}
- worker = new Thread("JGit-Upload-Pack") {
+ worker = new Thread("JGit-Upload-Pack") { //$NON-NLS-1$
public void run() {
try {
final UploadPack rp = createUploadPack(dst);
throw new TransportException(uri, JGitText.get().cannotConnectPipes, err);
}
- worker = new Thread("JGit-Receive-Pack") {
+ worker = new Thread("JGit-Receive-Pack") { //$NON-NLS-1$
public void run() {
try {
final ReceivePack rp = createReceivePack(dst);
private ChannelSftp ftp;
SftpObjectDB(String path) throws TransportException {
- if (path.startsWith("/~"))
+ if (path.startsWith("/~")) //$NON-NLS-1$
path = path.substring(1);
- if (path.startsWith("~/"))
+ if (path.startsWith("~/")) //$NON-NLS-1$
path = path.substring(2);
try {
ftp = newSftp();
ftp.cd(path);
- ftp.cd("objects");
+ ftp.cd("objects"); //$NON-NLS-1$
objectsPath = ftp.pwd();
} catch (TransportException err) {
close();
Collection<String> getPackNames() throws IOException {
final List<String> packs = new ArrayList<String>();
try {
- final Collection<ChannelSftp.LsEntry> list = ftp.ls("pack");
+ final Collection<ChannelSftp.LsEntry> list = ftp.ls("pack"); //$NON-NLS-1$
final HashMap<String, ChannelSftp.LsEntry> files;
final HashMap<String, Integer> mtimes;
files.put(ent.getFilename(), ent);
for (final ChannelSftp.LsEntry ent : list) {
final String n = ent.getFilename();
- if (!n.startsWith("pack-") || !n.endsWith(".pack"))
+ if (!n.startsWith("pack-") || !n.endsWith(".pack")) //$NON-NLS-1$
continue;
- final String in = n.substring(0, n.length() - 5) + ".idx";
+ final String in = n.substring(0, n.length() - 5) + ".idx"; //$NON-NLS-1$
if (!files.containsKey(in))
continue;
@Override
void writeFile(final String path, final byte[] data) throws IOException {
- final String lock = path + ".lock";
+ final String lock = path + ".lock"; //$NON-NLS-1$
try {
super.writeFile(lock, data);
try {
final TreeMap<String, Ref> avail = new TreeMap<String, Ref>();
readPackedRefs(avail);
readRef(avail, ROOT_DIR + Constants.HEAD, Constants.HEAD);
- readLooseRefs(avail, ROOT_DIR + "refs", "refs/");
+ readLooseRefs(avail, ROOT_DIR + "refs", "refs/"); //$NON-NLS-1$ //$NON-NLS-2$
return avail;
}
for (final ChannelSftp.LsEntry ent : list) {
final String n = ent.getFilename();
- if (".".equals(n) || "..".equals(n))
+ if (".".equals(n) || "..".equals(n)) //$NON-NLS-1$ //$NON-NLS-2$
continue;
- final String nPath = dir + "/" + n;
+ final String nPath = dir + "/" + n; //$NON-NLS-1$
if (ent.getAttrs().isDir())
- readLooseRefs(avail, nPath, prefix + n + "/");
+ readLooseRefs(avail, nPath, prefix + n + "/"); //$NON-NLS-1$
else
readRef(avail, nPath, prefix + n);
}
if (line == null)
throw new TransportException("Empty ref: " + name);
- if (line.startsWith("ref: ")) {
- final String target = line.substring("ref: ".length());
+ if (line.startsWith("ref: ")) { //$NON-NLS-1$
+ final String target = line.substring("ref: ".length()); //$NON-NLS-1$
Ref r = avail.get(target);
if (r == null)
r = readRef(avail, ROOT_DIR + target, target);
* URI. Defines one capturing group containing the scheme without the
* trailing colon and slashes
*/
- private static final String SCHEME_P = "([a-z][a-z0-9+-]+)://";
+ private static final String SCHEME_P = "([a-z][a-z0-9+-]+)://"; //$NON-NLS-1$
/**
* Part of a pattern which matches the optional user/password part (e.g.
* capturing groups: the first containing the user and the second containing
* the password
*/
- private static final String OPT_USER_PWD_P = "(?:([^/:@]+)(?::([^\\\\/]+))?@)?";
+ private static final String OPT_USER_PWD_P = "(?:([^/:@]+)(?::([^\\\\/]+))?@)?"; //$NON-NLS-1$
/**
* Part of a pattern which matches the host part of URIs. Defines one
* capturing group containing the host name.
*/
- private static final String HOST_P = "([^\\\\/:]+)";
+ private static final String HOST_P = "([^\\\\/:]+)"; //$NON-NLS-1$
/**
* Part of a pattern which matches the optional port part of URIs. Defines
* one capturing group containing the port without the preceding colon.
*/
- private static final String OPT_PORT_P = "(?::(\\d+))?";
+ private static final String OPT_PORT_P = "(?::(\\d+))?"; //$NON-NLS-1$
/**
* Part of a pattern which matches the ~username part (e.g. /~root in
* git://host.xyz/~root/a.git) of URIs. Defines no capturing group.
*/
- private static final String USER_HOME_P = "(?:/~(?:[^\\\\/]+))";
+ private static final String USER_HOME_P = "(?:/~(?:[^\\\\/]+))"; //$NON-NLS-1$
/**
* Part of a pattern which matches the optional drive letter in paths (e.g.
* D: in file:///D:/a.txt). Defines no capturing group.
*/
- private static final String OPT_DRIVE_LETTER_P = "(?:[A-Za-z]:)?";
+ private static final String OPT_DRIVE_LETTER_P = "(?:[A-Za-z]:)?"; //$NON-NLS-1$
/**
* Part of a pattern which matches a relative path. Relative paths don't
* start with slash or drive letters. Defines no capturing group.
*/
- private static final String RELATIVE_PATH_P = "(?:(?:[^\\\\/]+[\\\\/])*[^\\\\/]+[\\\\/]?)";
+ private static final String RELATIVE_PATH_P = "(?:(?:[^\\\\/]+[\\\\/])*[^\\\\/]+[\\\\/]?)"; //$NON-NLS-1$
/**
* Part of a pattern which matches a relative or absolute path. Defines no
* capturing group.
*/
- private static final String PATH_P = "(" + OPT_DRIVE_LETTER_P + "[\\\\/]?"
- + RELATIVE_PATH_P + ")";
+ private static final String PATH_P = "(" + OPT_DRIVE_LETTER_P + "[\\\\/]?" //$NON-NLS-1$ //$NON-NLS-2$
+ + RELATIVE_PATH_P + ")"; //$NON-NLS-1$
private static final long serialVersionUID = 1L;
* A pattern matching standard URI: </br>
* <code>scheme "://" user_password? hostname? portnumber? path</code>
*/
- private static final Pattern FULL_URI = Pattern.compile("^" //
+ private static final Pattern FULL_URI = Pattern.compile("^" // //$NON-NLS-1$
+ SCHEME_P //
- + "(?:" // start a group containing hostname and all options only
+ + "(?:" // start a group containing hostname and all options only //$NON-NLS-1$
// availabe when a hostname is there
+ OPT_USER_PWD_P //
+ HOST_P //
+ OPT_PORT_P //
- + "(" // open a catpuring group the the user-home-dir part
- + (USER_HOME_P + "?") //
- + "[\\\\/])" //
- + ")?" // close the optional group containing hostname
- + "(.+)?" //
- + "$");
+ + "(" // open a catpuring group the the user-home-dir part //$NON-NLS-1$
+ + (USER_HOME_P + "?") // //$NON-NLS-1$
+ + "[\\\\/])" // //$NON-NLS-1$
+ + ")?" // close the optional group containing hostname //$NON-NLS-1$
+ + "(.+)?" // //$NON-NLS-1$
+ + "$"); //$NON-NLS-1$
/**
* A pattern matching the reference to a local file. This may be an absolute
* path (maybe even containing windows drive-letters) or a relative path.
*/
- private static final Pattern LOCAL_FILE = Pattern.compile("^" //
- + "([\\\\/]?" + PATH_P + ")" //
- + "$");
+ private static final Pattern LOCAL_FILE = Pattern.compile("^" // //$NON-NLS-1$
+ + "([\\\\/]?" + PATH_P + ")" // //$NON-NLS-1$ //$NON-NLS-2$
+ + "$"); //$NON-NLS-1$
/**
* A pattern matching a URI for the scheme 'file' which has only ':/' as
* separator between scheme and path. Standard file URIs have '://' as
* separator, but java.io.File.toURI() constructs those URIs.
*/
- private static final Pattern SINGLE_SLASH_FILE_URI = Pattern.compile("^" //
- + "(file):([\\\\/](?![\\\\/])" //
+ private static final Pattern SINGLE_SLASH_FILE_URI = Pattern.compile("^" // //$NON-NLS-1$
+ + "(file):([\\\\/](?![\\\\/])" // //$NON-NLS-1$
+ PATH_P //
- + ")$");
+ + ")$"); //$NON-NLS-1$
/**
* A pattern matching a SCP URI's of the form user@host:path/to/repo.git
*/
- private static final Pattern RELATIVE_SCP_URI = Pattern.compile("^" //
+ private static final Pattern RELATIVE_SCP_URI = Pattern.compile("^" // //$NON-NLS-1$
+ OPT_USER_PWD_P //
+ HOST_P //
- + ":(" //
- + ("(?:" + USER_HOME_P + "[\\\\/])?") //
+ + ":(" // //$NON-NLS-1$
+ + ("(?:" + USER_HOME_P + "[\\\\/])?") // //$NON-NLS-1$ //$NON-NLS-2$
+ RELATIVE_PATH_P //
- + ")$");
+ + ")$"); //$NON-NLS-1$
/**
* A pattern matching a SCP URI's of the form user@host:/path/to/repo.git
*/
- private static final Pattern ABSOLUTE_SCP_URI = Pattern.compile("^" //
+ private static final Pattern ABSOLUTE_SCP_URI = Pattern.compile("^" // //$NON-NLS-1$
+ OPT_USER_PWD_P //
- + "([^\\\\/:]{2,})" //
- + ":(" //
- + "[\\\\/]" + RELATIVE_PATH_P //
- + ")$");
+ + "([^\\\\/:]{2,})" // //$NON-NLS-1$
+ + ":(" // //$NON-NLS-1$
+ + "[\\\\/]" + RELATIVE_PATH_P // //$NON-NLS-1$
+ + ")$"); //$NON-NLS-1$
private String scheme;
*/
public URIish(String s) throws URISyntaxException {
if (StringUtils.isEmptyOrNull(s)) {
- throw new URISyntaxException("The uri was empty or null",
+ throw new URISyntaxException("The uri was empty or null", //$NON-NLS-1$
JGitText.get().cannotParseGitURIish);
}
Matcher matcher = SINGLE_SLASH_FILE_URI.matcher(s);
private static final BitSet reservedChars = new BitSet(127);
static {
- for (byte b : Constants.encodeASCII("!*'();:@&=+$,/?#[]"))
+ for (byte b : Constants.encodeASCII("!*'();:@&=+$,/?#[]")) //$NON-NLS-1$
reservedChars.set(b);
}
if (b <= 32 || (encodeNonAscii && b > 127) || b == '%'
|| (escapeReservedChars && reservedChars.get(b))) {
os.write('%');
- byte[] tmp = Constants.encodeASCII(String.format("%02x",
+ byte[] tmp = Constants.encodeASCII(String.format("%02x", //$NON-NLS-1$
Integer.valueOf(b)));
os.write(tmp[0]);
os.write(tmp[1]);
private String n2e(String s) {
if (s == null)
- return "";
+ return ""; //$NON-NLS-1$
else
return s;
}
final StringBuilder r = new StringBuilder();
if (getScheme() != null) {
r.append(getScheme());
- r.append("://");
+ r.append("://"); //$NON-NLS-1$
}
if (getUser() != null) {
if (getPath() != null) {
if (getScheme() != null) {
- if (!getPath().startsWith("/"))
+ if (!getPath().startsWith("/")) //$NON-NLS-1$
r.append('/');
} else if (getHost() != null)
r.append(':');
* @see #getPath
*/
public String getHumanishName() throws IllegalArgumentException {
- if ("".equals(getPath()) || getPath() == null)
+ if ("".equals(getPath()) || getPath() == null) //$NON-NLS-1$
throw new IllegalArgumentException();
String s = getPath();
String[] elements;
- if ("file".equals(scheme) || LOCAL_FILE.matcher(s).matches())
- elements = s.split("[\\" + File.separatorChar + "/]");
+ if ("file".equals(scheme) || LOCAL_FILE.matcher(s).matches()) //$NON-NLS-1$
+ elements = s.split("[\\" + File.separatorChar + "/]"); //$NON-NLS-1$ //$NON-NLS-2$
else
- elements = s.split("/");
+ elements = s.split("/"); //$NON-NLS-1$
if (elements.length == 0)
throw new IllegalArgumentException();
String result = elements[elements.length - 1];
if (line.length() > 45) {
final HashSet<String> opts = new HashSet<String>();
String opt = line.substring(45);
- if (opt.startsWith(" "))
+ if (opt.startsWith(" ")) //$NON-NLS-1$
opt = opt.substring(1);
- for (String c : opt.split(" "))
+ for (String c : opt.split(" ")) //$NON-NLS-1$
opts.add(c);
this.line = line.substring(0, 45);
this.options = Collections.unmodifiableSet(opts);
walk = new RevWalk(db);
walk.setRetainBody(false);
- WANT = walk.newFlag("WANT");
- PEER_HAS = walk.newFlag("PEER_HAS");
- COMMON = walk.newFlag("COMMON");
- SATISFIED = walk.newFlag("SATISFIED");
+ WANT = walk.newFlag("WANT"); //$NON-NLS-1$
+ PEER_HAS = walk.newFlag("PEER_HAS"); //$NON-NLS-1$
+ COMMON = walk.newFlag("COMMON"); //$NON-NLS-1$
+ SATISFIED = walk.newFlag("SATISFIED"); //$NON-NLS-1$
walk.carry(PEER_HAS);
SAVE = new RevFlagSet();
if (timeout > 0) {
final Thread caller = Thread.currentThread();
- timer = new InterruptTimer(caller.getName() + "-Timer");
+ timer = new InterruptTimer(caller.getName() + "-Timer"); //$NON-NLS-1$
TimeoutInputStream i = new TimeoutInputStream(rawIn, timer);
TimeoutOutputStream o = new TimeoutOutputStream(rawOut, timer);
i.setTimeout(timeout * 1000);
} catch (ServiceMayNotContinueException err) {
if (!err.isOutput() && err.getMessage() != null) {
try {
- pckOut.writeString("ERR " + err.getMessage() + "\n");
+ pckOut.writeString("ERR " + err.getMessage() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
err.setOutput();
} catch (Throwable err2) {
// Ignore this secondary failure (and not mark output).
private void reportErrorDuringNegotiate(String msg) {
try {
- pckOut.writeString("ERR " + msg + "\n");
+ pckOut.writeString("ERR " + msg + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
} catch (Throwable err) {
// Ignore this secondary failure.
}
// Commits at the boundary which aren't already shallow in
// the client need to be marked as such
if (c.getDepth() == depth && !clientShallowCommits.contains(c))
- pckOut.writeString("shallow " + o.name());
+ pckOut.writeString("shallow " + o.name()); //$NON-NLS-1$
// Commits not on the boundary which are shallow in the client
// need to become unshallowed
if (c.getDepth() < depth && clientShallowCommits.contains(c)) {
unshallowCommits.add(c.copy());
- pckOut.writeString("unshallow " + c.name());
+ pckOut.writeString("unshallow " + c.name()); //$NON-NLS-1$
}
}
advertiseRefsHook.advertiseRefs(this);
} catch (ServiceMayNotContinueException fail) {
if (fail.getMessage() != null) {
- adv.writeOne("ERR " + fail.getMessage());
+ adv.writeOne("ERR " + fail.getMessage()); //$NON-NLS-1$
fail.setOutput();
}
throw fail;
if (line == PacketLineIn.END)
break;
- if (line.startsWith("deepen ")) {
+ if (line.startsWith("deepen ")) { //$NON-NLS-1$
depth = Integer.parseInt(line.substring(7));
continue;
}
- if (line.startsWith("shallow ")) {
+ if (line.startsWith("shallow ")) { //$NON-NLS-1$
clientShallowCommits.add(ObjectId.fromString(line.substring(8)));
continue;
}
- if (!line.startsWith("want ") || line.length() < 45)
- throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedGot, "want", line));
+ if (!line.startsWith("want ") || line.length() < 45) //$NON-NLS-1$
+ throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedGot, "want", line)); //$NON-NLS-1$
if (isFirst && line.length() > 45) {
final FirstLine firstLine = new FirstLine(line);
if (line == PacketLineIn.END) {
last = processHaveLines(peerHas, last);
if (commonBase.isEmpty() || multiAck != MultiAck.OFF)
- pckOut.writeString("NAK\n");
+ pckOut.writeString("NAK\n"); //$NON-NLS-1$
if (noDone && sentReady) {
- pckOut.writeString("ACK " + last.name() + "\n");
+ pckOut.writeString("ACK " + last.name() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
return true;
}
if (!biDirectionalPipe)
return false;
pckOut.flush();
- } else if (line.startsWith("have ") && line.length() == 45) {
+ } else if (line.startsWith("have ") && line.length() == 45) { //$NON-NLS-1$
peerHas.add(ObjectId.fromString(line.substring(5)));
- } else if (line.equals("done")) {
+ } else if (line.equals("done")) { //$NON-NLS-1$
last = processHaveLines(peerHas, last);
if (commonBase.isEmpty())
- pckOut.writeString("NAK\n");
+ pckOut.writeString("NAK\n"); //$NON-NLS-1$
else if (multiAck != MultiAck.OFF)
- pckOut.writeString("ACK " + last.name() + "\n");
+ pckOut.writeString("ACK " + last.name() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
return true;
} else {
- throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedGot, "have", line));
+ throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedGot, "have", line)); //$NON-NLS-1$
}
}
}
switch (multiAck) {
case OFF:
if (commonBase.size() == 1)
- pckOut.writeString("ACK " + obj.name() + "\n");
+ pckOut.writeString("ACK " + obj.name() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
break;
case CONTINUE:
- pckOut.writeString("ACK " + obj.name() + " continue\n");
+ pckOut.writeString("ACK " + obj.name() + " continue\n"); //$NON-NLS-1$ //$NON-NLS-2$
break;
case DETAILED:
- pckOut.writeString("ACK " + obj.name() + " common\n");
+ pckOut.writeString("ACK " + obj.name() + " common\n"); //$NON-NLS-1$ //$NON-NLS-2$
break;
}
}
case OFF:
break;
case CONTINUE:
- pckOut.writeString("ACK " + id.name() + " continue\n");
+ pckOut.writeString("ACK " + id.name() + " continue\n"); //$NON-NLS-1$ //$NON-NLS-2$
break;
case DETAILED:
- pckOut.writeString("ACK " + id.name() + " ready\n");
+ pckOut.writeString("ACK " + id.name() + " ready\n"); //$NON-NLS-1$ //$NON-NLS-2$
sentReady = true;
break;
}
if (multiAck == MultiAck.DETAILED && !didOkToGiveUp && okToGiveUp()) {
ObjectId id = peerHas.get(peerHas.size() - 1);
sentReady = true;
- pckOut.writeString("ACK " + id.name() + " ready\n");
+ pckOut.writeString("ACK " + id.name() + " ready\n"); //$NON-NLS-1$ //$NON-NLS-2$
sentReady = true;
}
if (0 <= eof)
throw new CorruptObjectException(MessageFormat.format(
JGitText.get().expectedEOFReceived,
- "\\x" + Integer.toHexString(eof)));
+ "\\x" + Integer.toHexString(eof))); //$NON-NLS-1$
}
if (sideband) {
continue;
}
if (i instanceof CredentialItem.StringType) {
- if (i.getPromptText().equals("Password: ")) {
+ if (i.getPromptText().equals("Password: ")) { //$NON-NLS-1$
((CredentialItem.StringType) i).setValue(new String(
password));
continue;
}
}
throw new UnsupportedCredentialItem(uri, i.getClass().getName()
- + ":" + i.getPromptText());
+ + ":" + i.getPromptText()); //$NON-NLS-1$
}
return true;
}
abstract class WalkEncryption {
static final WalkEncryption NONE = new NoEncryption();
- static final String JETS3T_CRYPTO_VER = "jets3t-crypto-ver";
+ static final String JETS3T_CRYPTO_VER = "jets3t-crypto-ver"; //$NON-NLS-1$
- static final String JETS3T_CRYPTO_ALG = "jets3t-crypto-alg";
+ static final String JETS3T_CRYPTO_ALG = "jets3t-crypto-alg"; //$NON-NLS-1$
abstract OutputStream encrypt(OutputStream os) throws IOException;
v = u.getHeaderField(p + JETS3T_CRYPTO_VER);
if (v == null)
- v = "";
+ v = ""; //$NON-NLS-1$
if (!version.equals(v))
throw new IOException(MessageFormat.format(JGitText.get().unsupportedEncryptionVersion, v));
v = u.getHeaderField(p + JETS3T_CRYPTO_ALG);
if (v == null)
- v = "";
+ v = ""; //$NON-NLS-1$
if (!name.equals(v))
throw new IOException(JGitText.get().unsupportedEncryptionAlgorithm + v);
}
@Override
void validate(final HttpURLConnection u, final String p)
throws IOException {
- validateImpl(u, p, "", "");
+ validateImpl(u, p, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
@Override
void request(final HttpURLConnection u, final String prefix) {
- u.setRequestProperty(prefix + JETS3T_CRYPTO_VER, "2");
+ u.setRequestProperty(prefix + JETS3T_CRYPTO_VER, "2"); //$NON-NLS-1$
u.setRequestProperty(prefix + JETS3T_CRYPTO_ALG, algorithmName);
}
@Override
void validate(final HttpURLConnection u, final String p)
throws IOException {
- validateImpl(u, p, "2", algorithmName);
+ validateImpl(u, p, "2", algorithmName); //$NON-NLS-1$
}
@Override
revWalk = new RevWalk(reader);
revWalk.setRetainBody(false);
treeWalk = new TreeWalk(reader);
- COMPLETE = revWalk.newFlag("COMPLETE");
- IN_WORK_QUEUE = revWalk.newFlag("IN_WORK_QUEUE");
- LOCALLY_SEEN = revWalk.newFlag("LOCALLY_SEEN");
+ COMPLETE = revWalk.newFlag("COMPLETE"); //$NON-NLS-1$
+ IN_WORK_QUEUE = revWalk.newFlag("IN_WORK_QUEUE"); //$NON-NLS-1$
+ LOCALLY_SEEN = revWalk.newFlag("LOCALLY_SEEN"); //$NON-NLS-1$
localCommitQueue = new DateRevQueue();
workQueue = new LinkedList<ObjectId>();
final String idStr = id.name();
final String subdir = idStr.substring(0, 2);
final String file = idStr.substring(2);
- final String looseName = subdir + "/" + file;
+ final String looseName = subdir + "/" + file; //$NON-NLS-1$
for (int i = lastRemoteIdx; i < remotes.size(); i++) {
if (downloadLooseObject(id, looseName, remotes.get(i))) {
RemotePack(final WalkRemoteObjectDatabase c, final String pn) {
connection = c;
packName = pn;
- idxName = packName.substring(0, packName.length() - 5) + ".idx";
+ idxName = packName.substring(0, packName.length() - 5) + ".idx"; //$NON-NLS-1$
String tn = idxName;
- if (tn.startsWith("pack-"))
+ if (tn.startsWith("pack-")) //$NON-NLS-1$
tn = tn.substring(5);
- if (tn.endsWith(".idx"))
+ if (tn.endsWith(".idx")) //$NON-NLS-1$
tn = tn.substring(0, tn.length() - 4);
if (local.getObjectDatabase() instanceof ObjectDirectory) {
tmpIdx = new File(((ObjectDirectory) local.getObjectDatabase())
- .getDirectory(), "walk-" + tn + ".walkidx");
+ .getDirectory(),
+ "walk-" + tn + ".walkidx"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
if (index != null)
return;
if (tmpIdx == null)
- tmpIdx = File.createTempFile("jgit-walk-", ".idx");
+ tmpIdx = File.createTempFile("jgit-walk-", ".idx"); //$NON-NLS-1$ //$NON-NLS-2$
else if (tmpIdx.isFile()) {
try {
index = PackIndex.open(tmpIdx);
}
final WalkRemoteObjectDatabase.FileStream s;
- s = connection.open("pack/" + idxName);
- pm.beginTask("Get " + idxName.substring(0, 12) + "..idx",
+ s = connection.open("pack/" + idxName); //$NON-NLS-1$
+ pm.beginTask("Get " + idxName.substring(0, 12) + "..idx", //$NON-NLS-1$ //$NON-NLS-2$
s.length < 0 ? ProgressMonitor.UNKNOWN
: (int) (s.length / 1024));
try {
}
void downloadPack(final ProgressMonitor monitor) throws IOException {
- String name = "pack/" + packName;
+ String name = "pack/" + packName; //$NON-NLS-1$
WalkRemoteObjectDatabase.FileStream s = connection.open(name);
PackParser parser = inserter.newPackParser(s.in);
parser.setAllowThin(false);
final List<RemoteRefUpdate> updates = new ArrayList<RemoteRefUpdate>();
for (final RemoteRefUpdate u : refUpdates.values()) {
final String n = u.getRemoteName();
- if (!n.startsWith("refs/") || !Repository.isValidRefName(n)) {
+ if (!n.startsWith("refs/") || !Repository.isValidRefName(n)) { //$NON-NLS-1$
u.setStatus(Status.REJECTED_OTHER_REASON);
u.setMessage(JGitText.get().funnyRefname);
continue;
for (final String n : dest.getPackNames())
packNames.put(n, n);
- final String base = "pack-" + writer.computeName().name();
- final String packName = base + ".pack";
- pathPack = "pack/" + packName;
- pathIdx = "pack/" + base + ".idx";
+ final String base = "pack-" + writer.computeName().name(); //$NON-NLS-1$
+ final String packName = base + ".pack"; //$NON-NLS-1$
+ pathPack = "pack/" + packName; //$NON-NLS-1$
+ pathIdx = "pack/" + base + ".idx"; //$NON-NLS-1$ //$NON-NLS-2$
if (packNames.remove(packName) != null) {
// The remote already contains this pack. We should
// Write the pack file, then the index, as readers look the
// other direction (index, then pack file).
//
- final String wt = "Put " + base.substring(0, 12);
- OutputStream os = dest.writeFile(pathPack, monitor, wt + "..pack");
+ final String wt = "Put " + base.substring(0, 12); //$NON-NLS-1$
+ OutputStream os = dest.writeFile(pathPack, monitor, wt + "..pack"); //$NON-NLS-1$
try {
os = new SafeBufferedOutputStream(os);
writer.writePack(monitor, monitor, os);
os.close();
}
- os = dest.writeFile(pathIdx, monitor, wt + "..idx");
+ os = dest.writeFile(pathIdx, monitor, wt + "..idx"); //$NON-NLS-1$
try {
os = new SafeBufferedOutputStream(os);
writer.writeIndex(os);
private void createNewRepository(final List<RemoteRefUpdate> updates)
throws TransportException {
try {
- final String ref = "ref: " + pickHEAD(updates) + "\n";
+ final String ref = "ref: " + pickHEAD(updates) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
final byte[] bytes = Constants.encode(ref);
dest.writeFile(ROOT_DIR + Constants.HEAD, bytes);
} catch (IOException e) {
}
try {
- final String config = "[core]\n"
- + "\trepositoryformatversion = 0\n";
+ final String config = "[core]\n" //$NON-NLS-1$
+ + "\trepositoryformatversion = 0\n"; //$NON-NLS-1$
final byte[] bytes = Constants.encode(config);
dest.writeFile(ROOT_DIR + Constants.CONFIG, bytes);
} catch (IOException e) {
* independent {@link WalkFetchConnection}.
*/
abstract class WalkRemoteObjectDatabase {
- static final String ROOT_DIR = "../";
+ static final String ROOT_DIR = "../"; //$NON-NLS-1$
- static final String INFO_PACKS = "info/packs";
+ static final String INFO_PACKS = "info/packs"; //$NON-NLS-1$
- static final String INFO_ALTERNATES = "info/alternates";
+ static final String INFO_ALTERNATES = "info/alternates"; //$NON-NLS-1$
- static final String INFO_HTTP_ALTERNATES = "info/http-alternates";
+ static final String INFO_HTTP_ALTERNATES = "info/http-alternates"; //$NON-NLS-1$
static final String INFO_REFS = ROOT_DIR + Constants.INFO_REFS;
* deletion is not supported, or deletion failed.
*/
void deleteRefLog(final String name) throws IOException {
- deleteFile(ROOT_DIR + Constants.LOGS + "/" + name);
+ deleteFile(ROOT_DIR + Constants.LOGS + "/" + name); //$NON-NLS-1$
}
/**
void writeInfoPacks(final Collection<String> packNames) throws IOException {
final StringBuilder w = new StringBuilder();
for (final String n : packNames) {
- w.append("P ");
+ w.append("P "); //$NON-NLS-1$
w.append(n);
w.append('\n');
}
String line = br.readLine();
if (line == null)
break;
- if (!line.endsWith("/"))
- line += "/";
+ if (!line.endsWith("/")) //$NON-NLS-1$
+ line += "/"; //$NON-NLS-1$
alts.add(openAlternate(line));
}
return alts;
if (isExportAll())
return true;
else if (db.getDirectory() != null)
- return new File(db.getDirectory(), "git-daemon-export-ok").exists();
+ return new File(db.getDirectory(), "git-daemon-export-ok").exists(); //$NON-NLS-1$
else
return false;
}
if (new File(name).isAbsolute())
return true; // no absolute paths
- if (name.startsWith("../"))
- return true; // no "l../etc/passwd"
- if (name.contains("/../"))
- return true; // no "foo/../etc/passwd"
- if (name.contains("/./"))
- return true; // "foo/./foo" is insane to ask
- if (name.contains("//"))
+ if (name.startsWith("../")) //$NON-NLS-1$
+ return true; // no "l../etc/passwd"
+ if (name.contains("/../")) //$NON-NLS-1$
+ return true; // no "foo/../etc/passwd"
+ if (name.contains("/./")) //$NON-NLS-1$
+ return true; // "foo/./foo" is insane to ask
+ if (name.contains("//")) //$NON-NLS-1$
return true; // double slashes is sloppy, don't use it
return false; // is a reasonable name
System.arraycopy(path, pathOffset, buffer, offset, pathLen - pathOffset);
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
- return getClass().getSimpleName() + "[" + getEntryPathString() + "]";
+ return getClass().getSimpleName() + "[" + getEntryPathString() + "]"; //$NON-NLS-1$
}
}
if (e == null)
continue;
final String name = e.getName();
- if (".".equals(name) || "..".equals(name))
+ if (".".equals(name) || "..".equals(name)) //$NON-NLS-1$ //$NON-NLS-2$
continue;
if (Constants.DOT_GIT.equals(name))
continue;
}
public String toString() {
- return getMode().toString() + " " + getName();
+ return getMode().toString() + " " + getName(); //$NON-NLS-1$
}
/**
.getExcludesFile();
if (path != null) {
File excludesfile;
- if (path.startsWith("~/"))
+ if (path.startsWith("~/")) //$NON-NLS-1$
excludesfile = fs.resolve(fs.userHome(), path.substring(2));
else
excludesfile = fs.resolve(null, path);
}
File exclude = fs
- .resolve(repository.getDirectory(), "info/exclude");
+ .resolve(repository.getDirectory(), "info/exclude"); //$NON-NLS-1$
loadRulesFromFile(r, exclude);
return r.getRules().isEmpty() ? null : r;
return new Binary(a.clone(), b.clone());
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "(" + a.toString() + " AND " + b.toString() + ")";
return new List(s);
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
final StringBuilder r = new StringBuilder();
String pathToBeSaved = null;
while (!untrackedParentFolders.isEmpty()
&& !currentPath.startsWith(untrackedParentFolders.getFirst()
- + "/"))
+ + "/")) //$NON-NLS-1$
pathToBeSaved = untrackedParentFolders.removeFirst();
if (pathToBeSaved != null) {
while (!untrackedFolders.isEmpty()
@Override
public String toString() {
- return "INDEX_DIFF_FILTER";
+ return "INDEX_DIFF_FILTER"; //$NON-NLS-1$
}
/**
return this;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "NotIgnored(" + index + ")";
@Override
public String toString() {
- return "NOT " + a.toString();
+ return "NOT " + a.toString(); //$NON-NLS-1$
}
}
return new Binary(a.clone(), b.clone());
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "(" + a.toString() + " OR " + b.toString() + ")";
@Override
public String toString() {
final StringBuilder r = new StringBuilder();
- r.append("(");
+ r.append("("); //$NON-NLS-1$
for (int i = 0; i < subfilters.length; i++) {
if (i > 0)
- r.append(" OR ");
+ r.append(" OR "); //$NON-NLS-1$
r.append(subfilters[i].toString());
}
- r.append(")");
+ r.append(")"); //$NON-NLS-1$
return r.toString();
}
}
* the path supplied was the empty string.
*/
public static PathFilter create(String path) {
- while (path.endsWith("/"))
+ while (path.endsWith("/")) //$NON-NLS-1$
path = path.substring(0, path.length() - 1);
if (path.length() == 0)
throw new IllegalArgumentException(JGitText.get().emptyPathNotPermitted);
return this;
}
+ @SuppressWarnings("nls")
public String toString() {
return "PATH(\"" + pathStr + "\")";
}
}
public String toString() {
- return "FAST_" + path.toString();
+ return "FAST_" + path.toString(); //$NON-NLS-1$
}
}
public String toString() {
final StringBuilder r = new StringBuilder();
- r.append("FAST(");
+ r.append("FAST("); //$NON-NLS-1$
for (int i = 0; i < paths.length; i++) {
if (i > 0)
- r.append(" OR ");
+ r.append(" OR "); //$NON-NLS-1$
r.append(paths[i].toString());
}
- r.append(")");
+ r.append(")"); //$NON-NLS-1$
return r.toString();
}
}
return this;
}
+ @SuppressWarnings("nls")
@Override
public String toString() {
return "SkipWorkTree(" + treeIdx + ")";
@Override
public String toString() {
- return "ALL";
+ return "ALL"; //$NON-NLS-1$
}
}
@Override
public String toString() {
- return "ANY_DIFF";
+ return "ANY_DIFF"; //$NON-NLS-1$
}
}
private final static byte INVALID_DEC = -3;
/** Preferred encoding. */
- private final static String UTF_8 = "UTF-8";
+ private final static String UTF_8 = "UTF-8"; //$NON-NLS-1$
/** The 64 valid Base64 values. */
private final static byte[] ENC;
static {
try {
- ENC = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" //
- + "abcdefghijklmnopqrstuvwxyz" //
- + "0123456789" //
- + "+/" //
+ ENC = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" // //$NON-NLS-1$
+ + "abcdefghijklmnopqrstuvwxyz" // //$NON-NLS-1$
+ + "0123456789" // //$NON-NLS-1$
+ + "+/" // //$NON-NLS-1$
).getBytes(UTF_8);
} catch (UnsupportedEncodingException uee) {
throw new RuntimeException(uee.getMessage(), uee);
*/
public class ChangeIdUtil {
- static final String CHANGE_ID = "Change-Id:";
+ static final String CHANGE_ID = "Change-Id:"; //$NON-NLS-1$
// package-private so the unit test can test this part only
+ @SuppressWarnings("nls")
static String clean(String msg) {
return msg.//
- replaceAll("(?i)(?m)^Signed-off-by:.*$\n?", "").//
- replaceAll("(?m)^#.*$\n?", "").//
- replaceAll("(?m)\n\n\n+", "\\\n").//
- replaceAll("\\n*$", "").//
- replaceAll("(?s)\ndiff --git.*", "").//
+ replaceAll("(?i)(?m)^Signed-off-by:.*$\n?", "").// //$NON-NLS-1$
+ replaceAll("(?m)^#.*$\n?", "").// //$NON-NLS-1$
+ replaceAll("(?m)\n\n\n+", "\\\n").// //$NON-NLS-1$
+ replaceAll("\\n*$", "").// //$NON-NLS-1$
+ replaceAll("(?s)\ndiff --git.*", "").// //$NON-NLS-1$
trim();
}
if (cleanMessage.length() == 0)
return null;
StringBuilder b = new StringBuilder();
- b.append("tree ");
+ b.append("tree "); //$NON-NLS-1$
b.append(ObjectId.toString(treeId));
- b.append("\n");
+ b.append("\n"); //$NON-NLS-1$
if (firstParentId != null) {
- b.append("parent ");
+ b.append("parent "); //$NON-NLS-1$
b.append(ObjectId.toString(firstParentId));
- b.append("\n");
+ b.append("\n"); //$NON-NLS-1$
}
- b.append("author ");
+ b.append("author "); //$NON-NLS-1$
b.append(author.toExternalString());
- b.append("\n");
- b.append("committer ");
+ b.append("\n"); //$NON-NLS-1$
+ b.append("committer "); //$NON-NLS-1$
b.append(committer.toExternalString());
- b.append("\n\n");
+ b.append("\n\n"); //$NON-NLS-1$
b.append(cleanMessage);
return new ObjectInserter.Formatter().idFor(Constants.OBJ_COMMIT, //
b.toString().getBytes(Constants.CHARACTER_ENCODING));
}
private static final Pattern issuePattern = Pattern
- .compile("^(Bug|Issue)[a-zA-Z0-9-]*:.*$");
+ .compile("^(Bug|Issue)[a-zA-Z0-9-]*:.*$"); //$NON-NLS-1$
private static final Pattern footerPattern = Pattern
- .compile("(^[a-zA-Z0-9-]+:(?!//).*$)");
+ .compile("(^[a-zA-Z0-9-]+:(?!//).*$)"); //$NON-NLS-1$
private static final Pattern includeInFooterPattern = Pattern
- .compile("^[ \\[].*$");
+ .compile("^[ \\[].*$"); //$NON-NLS-1$
/**
* Find the right place to insert a Change-Id and return it.
i++;
String oldId = message.length() == (i + 40) ?
message.substring(i) : message.substring(i, i + 41);
- message = message.replace(oldId, "I" + changeId.getName());
+ message = message.replace(oldId, "I" + changeId.getName()); //$NON-NLS-1$
}
return message;
}
- String[] lines = message.split("\n");
+ String[] lines = message.split("\n"); //$NON-NLS-1$
int footerFirstLine = lines.length;
for (int i = lines.length - 1; i > 1; --i) {
if (footerPattern.matcher(lines[i]).matches()) {
int i = 0;
for (; i < insertAfter; ++i) {
ret.append(lines[i]);
- ret.append("\n");
+ ret.append("\n"); //$NON-NLS-1$
}
if (insertAfter == lines.length && insertAfter == footerFirstLine)
- ret.append("\n");
+ ret.append("\n"); //$NON-NLS-1$
ret.append(CHANGE_ID);
- ret.append(" I");
+ ret.append(" I"); //$NON-NLS-1$
ret.append(ObjectId.toString(changeId));
- ret.append("\n");
+ ret.append("\n"); //$NON-NLS-1$
for (; i < lines.length; ++i) {
ret.append(lines[i]);
- ret.append("\n");
+ ret.append("\n"); //$NON-NLS-1$
}
return ret.toString();
}
final String home = AccessController
.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return System.getProperty("user.home");
+ return System.getProperty("user.home"); //$NON-NLS-1$
}
});
if (home == null || home.length() == 0)
*/
protected static String readPipe(File dir, String[] command, String encoding) {
final boolean debug = Boolean.parseBoolean(SystemReader.getInstance()
- .getProperty("jgit.fs.debug"));
+ .getProperty("jgit.fs.debug")); //$NON-NLS-1$
try {
if (debug)
- System.err.println("readpipe " + Arrays.asList(command) + ","
+ System.err.println("readpipe " + Arrays.asList(command) + "," //$NON-NLS-1$ //$NON-NLS-2$
+ dir);
final Process p = Runtime.getRuntime().exec(command, null, dir);
final BufferedReader lineRead = new BufferedReader(
try {
r = lineRead.readLine();
if (debug) {
- System.err.println("readpipe may return '" + r + "'");
- System.err.println("(ignoring remaing output:");
+ System.err.println("readpipe may return '" + r + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.err.println("(ignoring remaing output:"); //$NON-NLS-1$
}
String l;
while ((l = lineRead.readLine()) != null) {
&& !gooblerFail.get())
return r;
if (debug)
- System.err.println("readpipe rc=" + rc);
+ System.err.println("readpipe rc=" + rc); //$NON-NLS-1$
break;
} catch (InterruptedException ie) {
// Stop bothering me, I have a zombie to reap.
// Ignore error (but report)
}
if (debug)
- System.err.println("readpipe returns null");
+ System.err.println("readpipe returns null"); //$NON-NLS-1$
return null;
}
Holder<File> p = gitPrefix;
if (p == null) {
String overrideGitPrefix = SystemReader.getInstance().getProperty(
- "jgit.gitprefix");
+ "jgit.gitprefix"); //$NON-NLS-1$
if (overrideGitPrefix != null)
p = new Holder<File>(new File(overrideGitPrefix));
else
abstract class FS_POSIX extends FS {
@Override
protected File discoverGitPrefix() {
- String path = SystemReader.getInstance().getenv("PATH");
- File gitExe = searchPath(path, "git");
+ String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$
+ File gitExe = searchPath(path, "git"); //$NON-NLS-1$
if (gitExe != null)
return gitExe.getParentFile().getParentFile();
// login shell and search using that.
//
String w = readPipe(userHome(), //
- new String[] { "bash", "--login", "-c", "which git" }, //
+ new String[] { "bash", "--login", "-c", "which git" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Charset.defaultCharset().name());
if (w == null || w.length() == 0)
return null;
@Override
public ProcessBuilder runInShell(String cmd, String[] args) {
List<String> argv = new ArrayList<String>(4 + args.length);
- argv.add("sh");
- argv.add("-c");
- argv.add(cmd + " \"$@\"");
+ argv.add("sh"); //$NON-NLS-1$
+ argv.add("-c"); //$NON-NLS-1$
+ argv.add(cmd + " \"$@\""); //$NON-NLS-1$
argv.add(cmd);
argv.addAll(Arrays.asList(args));
ProcessBuilder proc = new ProcessBuilder();
private static final Method setExecute;
static {
- canExecute = needMethod(File.class, "canExecute");
- setExecute = needMethod(File.class, "setExecutable", Boolean.TYPE);
+ canExecute = needMethod(File.class, "canExecute"); //$NON-NLS-1$
+ setExecute = needMethod(File.class, "setExecutable", Boolean.TYPE); //$NON-NLS-1$
}
static boolean hasExecute() {
@Override
protected File discoverGitPrefix() {
- String path = SystemReader.getInstance().getenv("PATH");
- File gitExe = searchPath(path, "git.exe", "git.cmd");
+ String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$
+ File gitExe = searchPath(path, "git.exe", "git.cmd"); //$NON-NLS-1$ //$NON-NLS-2$
if (gitExe != null)
return gitExe.getParentFile().getParentFile();
// also be in $PATH. But its worth trying.
//
String w = readPipe(userHome(), //
- new String[] { "bash", "--login", "-c", "which git" }, //
+ new String[] { "bash", "--login", "-c", "which git" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Charset.defaultCharset().name());
if (w != null) {
// The path may be in cygwin/msys notation so resolve it right away
@Override
protected File userHomeImpl() {
- String home = SystemReader.getInstance().getenv("HOME");
+ String home = SystemReader.getInstance().getenv("HOME"); //$NON-NLS-1$
if (home != null)
return resolve(null, home);
- String homeDrive = SystemReader.getInstance().getenv("HOMEDRIVE");
+ String homeDrive = SystemReader.getInstance().getenv("HOMEDRIVE"); //$NON-NLS-1$
if (homeDrive != null) {
- String homePath = SystemReader.getInstance().getenv("HOMEPATH");
+ String homePath = SystemReader.getInstance().getenv("HOMEPATH"); //$NON-NLS-1$
return new File(homeDrive, homePath);
}
- String homeShare = SystemReader.getInstance().getenv("HOMESHARE");
+ String homeShare = SystemReader.getInstance().getenv("HOMESHARE"); //$NON-NLS-1$
if (homeShare != null)
return new File(homeShare);
@Override
public ProcessBuilder runInShell(String cmd, String[] args) {
List<String> argv = new ArrayList<String>(3 + args.length);
- argv.add("cmd.exe");
- argv.add("/c");
+ argv.add("cmd.exe"); //$NON-NLS-1$
+ argv.add("/c"); //$NON-NLS-1$
argv.add(cmd);
argv.addAll(Arrays.asList(args));
ProcessBuilder proc = new ProcessBuilder();
final String path = AccessController
.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return System.getProperty("java.library.path");
+ return System.getProperty("java.library.path"); //$NON-NLS-1$
}
});
if (path == null)
return false;
- File found = FS.searchPath(path, "cygpath.exe");
+ File found = FS.searchPath(path, "cygpath.exe"); //$NON-NLS-1$
if (found != null)
cygpath = found.getPath();
return cygpath != null;
}
public File resolve(final File dir, final String pn) {
- String useCygPath = System.getProperty("jgit.usecygpath");
- if (useCygPath != null && useCygPath.equals("true")) {
+ String useCygPath = System.getProperty("jgit.usecygpath"); //$NON-NLS-1$
+ if (useCygPath != null && useCygPath.equals("true")) { //$NON-NLS-1$
String w = readPipe(dir, //
- new String[] { cygpath, "--windows", "--absolute", pn }, //
- "UTF-8");
+ new String[] { cygpath, "--windows", "--absolute", pn }, // //$NON-NLS-1$ //$NON-NLS-2$
+ "UTF-8"); //$NON-NLS-1$
if (w != null)
return new File(w);
}
final String home = AccessController
.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return System.getenv("HOME");
+ return System.getenv("HOME"); //$NON-NLS-1$
}
});
if (home == null || home.length() == 0)
return super.userHomeImpl();
- return resolve(new File("."), home);
+ return resolve(new File("."), home); //$NON-NLS-1$
}
@Override
public ProcessBuilder runInShell(String cmd, String[] args) {
List<String> argv = new ArrayList<String>(4 + args.length);
- argv.add("sh.exe");
- argv.add("-c");
- argv.add(cmd + " \"$@\"");
+ argv.add("sh.exe"); //$NON-NLS-1$
+ argv.add("-c"); //$NON-NLS-1$
+ argv.add(cmd + " \"$@\""); //$NON-NLS-1$
argv.add(cmd);
argv.addAll(Arrays.asList(args));
ProcessBuilder proc = new ProcessBuilder();
break;
case DEFAULT: // Not default:
dateTimeInstance = new SimpleDateFormat(
- "EEE MMM dd HH:mm:ss yyyy Z", Locale.US);
+ "EEE MMM dd HH:mm:ss yyyy Z", Locale.US); //$NON-NLS-1$
break;
case ISO:
- dateTimeInstance = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z",
+ dateTimeInstance = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", //$NON-NLS-1$
Locale.US);
break;
case LOCAL:
break;
case RFC:
dateTimeInstance = new SimpleDateFormat(
- "EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
+ "EEE, dd MMM yyyy HH:mm:ss Z", Locale.US); //$NON-NLS-1$
break;
case SHORT:
- dateTimeInstance = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
+ dateTimeInstance = new SimpleDateFormat("yyyy-MM-dd", Locale.US); //$NON-NLS-1$
break;
case LOCALE:
case LOCALELOCAL:
SystemReader systemReader = SystemReader.getInstance();
dateTimeInstance = systemReader.getDateTimeInstance(
DateFormat.DEFAULT, DateFormat.DEFAULT);
- dateTimeInstance2 = systemReader.getSimpleDateFormat("Z");
+ dateTimeInstance2 = systemReader.getSimpleDateFormat("Z"); //$NON-NLS-1$
break;
}
}
switch (format) {
case RAW:
int offset = ident.getTimeZoneOffset();
- String sign = offset < 0 ? "-" : "+";
+ String sign = offset < 0 ? "-" : "+"; //$NON-NLS-1$ //$NON-NLS-2$
int offset2;
if (offset < 0)
offset2 = -offset;
offset2 = offset;
int hours = offset2 / 60;
int minutes = offset2 % 60;
- return String.format("%d %s%02d%02d",
+ return String.format("%d %s%02d%02d", //$NON-NLS-1$
ident.getWhen().getTime() / 1000, sign, hours, minutes);
case RELATIVE:
return RelativeDateFormatter.format(ident.getWhen());
tz = SystemReader.getInstance().getTimeZone();
dateTimeInstance.setTimeZone(tz);
dateTimeInstance2.setTimeZone(tz);
- return dateTimeInstance.format(ident.getWhen()) + " "
+ return dateTimeInstance.format(ident.getWhen()) + " " //$NON-NLS-1$
+ dateTimeInstance2.format(ident.getWhen());
default:
tz = ident.getTimeZone();
// are not listed here because they are parsed without the help of a
// SimpleDateFormat.
enum ParseableSimpleDateFormat {
- ISO("yyyy-MM-dd HH:mm:ss Z"), //
- RFC("EEE, dd MMM yyyy HH:mm:ss Z"), //
- SHORT("yyyy-MM-dd"), //
- SHORT_WITH_DOTS_REVERSE("dd.MM.yyyy"), //
- SHORT_WITH_DOTS("yyyy.MM.dd"), //
- SHORT_WITH_SLASH("MM/dd/yyyy"), //
- DEFAULT("EEE MMM dd HH:mm:ss yyyy Z"), //
+ ISO("yyyy-MM-dd HH:mm:ss Z"), // //$NON-NLS-1$
+ RFC("EEE, dd MMM yyyy HH:mm:ss Z"), // //$NON-NLS-1$
+ SHORT("yyyy-MM-dd"), // //$NON-NLS-1$
+ SHORT_WITH_DOTS_REVERSE("dd.MM.yyyy"), // //$NON-NLS-1$
+ SHORT_WITH_DOTS("yyyy.MM.dd"), // //$NON-NLS-1$
+ SHORT_WITH_SLASH("MM/dd/yyyy"), // //$NON-NLS-1$
+ DEFAULT("EEE MMM dd HH:mm:ss yyyy Z"), // //$NON-NLS-1$
LOCAL("EEE MMM dd HH:mm:ss yyyy");
String formatStr;
dateStr = dateStr.trim();
Date ret;
- if ("never".equalsIgnoreCase(dateStr))
+ if ("never".equalsIgnoreCase(dateStr)) //$NON-NLS-1$
return NEVER;
ret = parse_relative(dateStr, now);
if (ret != null)
}
}
ParseableSimpleDateFormat[] values = ParseableSimpleDateFormat.values();
- StringBuilder allFormats = new StringBuilder("\"")
+ StringBuilder allFormats = new StringBuilder("\"") //$NON-NLS-1$
.append(values[0].formatStr);
for (int i = 1; i < values.length; i++)
- allFormats.append("\", \"").append(values[i].formatStr);
- allFormats.append("\"");
+ allFormats.append("\", \"").append(values[i].formatStr); //$NON-NLS-1$
+ allFormats.append("\""); //$NON-NLS-1$
throw new ParseException(MessageFormat.format(
JGitText.get().cannotParseDate, dateStr, allFormats.toString()), 0);
}
SystemReader sysRead = SystemReader.getInstance();
// check for the static words "yesterday" or "now"
- if ("now".equals(dateStr)) {
+ if ("now".equals(dateStr)) { //$NON-NLS-1$
return ((now == null) ? new Date(sysRead.getCurrentTime()) : now
.getTime());
}
} else
cal = (Calendar) now.clone();
- if ("yesterday".equals(dateStr)) {
+ if ("yesterday".equals(dateStr)) { //$NON-NLS-1$
cal.add(Calendar.DATE, -1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
}
// parse constructs like "3 days ago", "5.week.2.day.ago"
- String[] parts = dateStr.split("\\.| ");
+ String[] parts = dateStr.split("\\.| "); //$NON-NLS-1$
int partsLength = parts.length;
// check we have an odd number of parts (at least 3) and that the last
// part is "ago"
if (partsLength < 3 || (partsLength & 1) == 0
- || !"ago".equals(parts[parts.length - 1]))
+ || !"ago".equals(parts[parts.length - 1])) //$NON-NLS-1$
return null;
int number;
for (int i = 0; i < parts.length - 2; i += 2) {
} catch (NumberFormatException e) {
return null;
}
- if ("year".equals(parts[i + 1]) || "years".equals(parts[i + 1]))
+ if ("year".equals(parts[i + 1]) || "years".equals(parts[i + 1])) //$NON-NLS-1$ //$NON-NLS-2$
cal.add(Calendar.YEAR, -number);
- else if ("month".equals(parts[i + 1])
- || "months".equals(parts[i + 1]))
+ else if ("month".equals(parts[i + 1]) //$NON-NLS-1$
+ || "months".equals(parts[i + 1])) //$NON-NLS-1$
cal.add(Calendar.MONTH, -number);
- else if ("week".equals(parts[i + 1])
- || "weeks".equals(parts[i + 1]))
+ else if ("week".equals(parts[i + 1]) //$NON-NLS-1$
+ || "weeks".equals(parts[i + 1])) //$NON-NLS-1$
cal.add(Calendar.WEEK_OF_YEAR, -number);
- else if ("day".equals(parts[i + 1]) || "days".equals(parts[i + 1]))
+ else if ("day".equals(parts[i + 1]) || "days".equals(parts[i + 1])) //$NON-NLS-1$ //$NON-NLS-2$
cal.add(Calendar.DATE, -number);
- else if ("hour".equals(parts[i + 1])
- || "hours".equals(parts[i + 1]))
+ else if ("hour".equals(parts[i + 1]) //$NON-NLS-1$
+ || "hours".equals(parts[i + 1])) //$NON-NLS-1$
cal.add(Calendar.HOUR_OF_DAY, -number);
- else if ("minute".equals(parts[i + 1])
- || "minutes".equals(parts[i + 1]))
+ else if ("minute".equals(parts[i + 1]) //$NON-NLS-1$
+ || "minutes".equals(parts[i + 1])) //$NON-NLS-1$
cal.add(Calendar.MINUTE, -number);
- else if ("second".equals(parts[i + 1])
- || "seconds".equals(parts[i + 1]))
+ else if ("second".equals(parts[i + 1]) //$NON-NLS-1$
+ || "seconds".equals(parts[i + 1])) //$NON-NLS-1$
cal.add(Calendar.SECOND, -number);
else
return null;
/** Extra utilities to support usage of HTTP. */
public class HttpSupport {
/** The {@code GET} HTTP method. */
- public static final String METHOD_GET = "GET";
+ public static final String METHOD_GET = "GET"; //$NON-NLS-1$
/** The {@code POST} HTTP method. */
- public static final String METHOD_POST = "POST";
+ public static final String METHOD_POST = "POST"; //$NON-NLS-1$
/** The {@code Cache-Control} header. */
- public static final String HDR_CACHE_CONTROL = "Cache-Control";
+ public static final String HDR_CACHE_CONTROL = "Cache-Control"; //$NON-NLS-1$
/** The {@code Pragma} header. */
- public static final String HDR_PRAGMA = "Pragma";
+ public static final String HDR_PRAGMA = "Pragma"; //$NON-NLS-1$
/** The {@code User-Agent} header. */
- public static final String HDR_USER_AGENT = "User-Agent";
+ public static final String HDR_USER_AGENT = "User-Agent"; //$NON-NLS-1$
/** The {@code Date} header. */
- public static final String HDR_DATE = "Date";
+ public static final String HDR_DATE = "Date"; //$NON-NLS-1$
/** The {@code Expires} header. */
- public static final String HDR_EXPIRES = "Expires";
+ public static final String HDR_EXPIRES = "Expires"; //$NON-NLS-1$
/** The {@code ETag} header. */
- public static final String HDR_ETAG = "ETag";
+ public static final String HDR_ETAG = "ETag"; //$NON-NLS-1$
/** The {@code If-None-Match} header. */
- public static final String HDR_IF_NONE_MATCH = "If-None-Match";
+ public static final String HDR_IF_NONE_MATCH = "If-None-Match"; //$NON-NLS-1$
/** The {@code Last-Modified} header. */
- public static final String HDR_LAST_MODIFIED = "Last-Modified";
+ public static final String HDR_LAST_MODIFIED = "Last-Modified"; //$NON-NLS-1$
/** The {@code If-Modified-Since} header. */
- public static final String HDR_IF_MODIFIED_SINCE = "If-Modified-Since";
+ public static final String HDR_IF_MODIFIED_SINCE = "If-Modified-Since"; //$NON-NLS-1$
/** The {@code Accept} header. */
- public static final String HDR_ACCEPT = "Accept";
+ public static final String HDR_ACCEPT = "Accept"; //$NON-NLS-1$
/** The {@code Content-Type} header. */
- public static final String HDR_CONTENT_TYPE = "Content-Type";
+ public static final String HDR_CONTENT_TYPE = "Content-Type"; //$NON-NLS-1$
/** The {@code Content-Length} header. */
- public static final String HDR_CONTENT_LENGTH = "Content-Length";
+ public static final String HDR_CONTENT_LENGTH = "Content-Length"; //$NON-NLS-1$
/** The {@code Content-Encoding} header. */
- public static final String HDR_CONTENT_ENCODING = "Content-Encoding";
+ public static final String HDR_CONTENT_ENCODING = "Content-Encoding"; //$NON-NLS-1$
/** The {@code Content-Range} header. */
- public static final String HDR_CONTENT_RANGE = "Content-Range";
+ public static final String HDR_CONTENT_RANGE = "Content-Range"; //$NON-NLS-1$
/** The {@code Accept-Ranges} header. */
- public static final String HDR_ACCEPT_RANGES = "Accept-Ranges";
+ public static final String HDR_ACCEPT_RANGES = "Accept-Ranges"; //$NON-NLS-1$
/** The {@code If-Range} header. */
- public static final String HDR_IF_RANGE = "If-Range";
+ public static final String HDR_IF_RANGE = "If-Range"; //$NON-NLS-1$
/** The {@code Range} header. */
- public static final String HDR_RANGE = "Range";
+ public static final String HDR_RANGE = "Range"; //$NON-NLS-1$
/** The {@code Accept-Encoding} header. */
- public static final String HDR_ACCEPT_ENCODING = "Accept-Encoding";
+ public static final String HDR_ACCEPT_ENCODING = "Accept-Encoding"; //$NON-NLS-1$
/** The {@code gzip} encoding value for {@link #HDR_ACCEPT_ENCODING}. */
- public static final String ENCODING_GZIP = "gzip";
+ public static final String ENCODING_GZIP = "gzip"; //$NON-NLS-1$
/** The standard {@code text/plain} MIME type. */
- public static final String TEXT_PLAIN = "text/plain";
+ public static final String TEXT_PLAIN = "text/plain"; //$NON-NLS-1$
/** The {@code Authorization} header. */
- public static final String HDR_AUTHORIZATION = "Authorization";
+ public static final String HDR_AUTHORIZATION = "Authorization"; //$NON-NLS-1$
/** The {@code WWW-Authenticate} header. */
- public static final String HDR_WWW_AUTHENTICATE = "WWW-Authenticate";
+ public static final String HDR_WWW_AUTHENTICATE = "WWW-Authenticate"; //$NON-NLS-1$
/**
* URL encode a value string into an output buffer.
if (key == null || key.length() == 0)
return;
try {
- urlstr.append(URLEncoder.encode(key, "UTF-8"));
+ urlstr.append(URLEncoder.encode(key, "UTF-8")); //$NON-NLS-1$
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(JGitText.get().couldNotURLEncodeToUTF8, e);
}
//
if ("Connection timed out: connect".equals(ce.getMessage()))
throw new ConnectException(MessageFormat.format(JGitText.get().connectionTimeOut, host));
- throw new ConnectException(ce.getMessage() + " " + host);
+ throw new ConnectException(ce.getMessage() + " " + host); //$NON-NLS-1$
}
}
r.append('[');
for (int i = 0; i < count; i++) {
if (i > 0)
- r.append(", ");
+ r.append(", "); //$NON-NLS-1$
r.append(entries[i]);
}
r.append(']');
r.append('[');
for (int i = 0; i < count; i++) {
if (i > 0)
- r.append(", ");
+ r.append(", "); //$NON-NLS-1$
r.append(entries[i]);
}
r.append(']');
public static class BourneUserPathStyle extends BourneStyle {
@Override
public String quote(final String in) {
- if (in.matches("^~[A-Za-z0-9_-]+$")) {
+ if (in.matches("^~[A-Za-z0-9_-]+$")) { //$NON-NLS-1$
// If the string is just "~user" we can assume they
// mean "~user/".
//
- return in + "/";
+ return in + "/"; //$NON-NLS-1$
}
- if (in.matches("^~[A-Za-z0-9_-]*/.*$")) {
+ if (in.matches("^~[A-Za-z0-9_-]*/.*$")) { //$NON-NLS-1$
// If the string is of "~/path" or "~user/path"
// we must not escape ~/ or ~user/ from the shell.
//
@Override
public String quote(final String instr) {
if (instr.length() == 0)
- return "\"\"";
+ return "\"\""; //$NON-NLS-1$
boolean reuse = true;
final byte[] in = Constants.encode(instr);
final StringBuilder r = new StringBuilder(2 + in.length);
*
* @since 2.2
*/
- public static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
+ public static final Charset UTF8_CHARSET = Charset.forName("UTF-8"); //$NON-NLS-1$
private static final byte[] digits10;
static {
encodingAliases = new HashMap<String, Charset>();
- encodingAliases.put("latin-1", Charset.forName("ISO-8859-1"));
+ encodingAliases.put("latin-1", Charset.forName("ISO-8859-1")); //$NON-NLS-1$ //$NON-NLS-2$
digits10 = new byte['9' + 1];
Arrays.fill(digits10, (byte) -1);
if (emailE < stop) {
email = decode(raw, emailB, emailE - 1);
} else {
- email = "invalid";
+ email = "invalid"; //$NON-NLS-1$
}
if (emailB < stop)
name = decode(raw, nameB, emailB - 2);
if (cnt > 0) {
r.append(list[0]);
for (int i = 1; i < cnt; i++) {
- r.append(", ");
+ r.append(", "); //$NON-NLS-1$
r.append(list[i]);
}
}
/** Construct an empty map with a small initial capacity. */
public RefMap() {
- prefix = "";
+ prefix = ""; //$NON-NLS-1$
packed = RefList.emptyList();
loose = RefList.emptyList();
resolved = RefList.emptyList();
if (first)
first = false;
else
- r.append(", ");
+ r.append(", "); //$NON-NLS-1$
r.append(ref);
}
r.append(']');
if (stringValue == null)
return null;
- if (equalsIgnoreCase("yes", stringValue)
- || equalsIgnoreCase("true", stringValue)
- || equalsIgnoreCase("1", stringValue)
- || equalsIgnoreCase("on", stringValue))
+ if (equalsIgnoreCase("yes", stringValue) //$NON-NLS-1$
+ || equalsIgnoreCase("true", stringValue) //$NON-NLS-1$
+ || equalsIgnoreCase("1", stringValue) //$NON-NLS-1$
+ || equalsIgnoreCase("on", stringValue)) //$NON-NLS-1$
return Boolean.TRUE;
- else if (equalsIgnoreCase("no", stringValue)
- || equalsIgnoreCase("false", stringValue)
- || equalsIgnoreCase("0", stringValue)
- || equalsIgnoreCase("off", stringValue))
+ else if (equalsIgnoreCase("no", stringValue) //$NON-NLS-1$
+ || equalsIgnoreCase("false", stringValue) //$NON-NLS-1$
+ || equalsIgnoreCase("0", stringValue) //$NON-NLS-1$
+ || equalsIgnoreCase("off", stringValue)) //$NON-NLS-1$
return Boolean.FALSE;
else
return null;
}
};
}
- File etc = fs.resolve(prefix, "etc");
- File config = fs.resolve(etc, "gitconfig");
+ File etc = fs.resolve(prefix, "etc"); //$NON-NLS-1$
+ File config = fs.resolve(etc, "gitconfig"); //$NON-NLS-1$
return new FileBasedConfig(parent, config, fs);
}
public FileBasedConfig openUserConfig(Config parent, FS fs) {
final File home = fs.userHome();
- return new FileBasedConfig(parent, new File(home, ".gitconfig"), fs);
+ return new FileBasedConfig(parent, new File(home, ".gitconfig"), fs); //$NON-NLS-1$
}
public String getHostname() {
hostname = localMachine.getCanonicalHostName();
} catch (UnknownHostException e) {
// we do nothing
- hostname = "localhost";
+ hostname = "localhost"; //$NON-NLS-1$
}
assert hostname != null;
}
String osDotName = AccessController
.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return getProperty("os.name");
+ return getProperty("os.name"); //$NON-NLS-1$
}
});
- return osDotName.startsWith("Windows");
+ return osDotName.startsWith("Windows"); //$NON-NLS-1$
}
/**
String osDotName = AccessController
.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return getProperty("os.name");
+ return getProperty("os.name"); //$NON-NLS-1$
}
});
- return "Mac OS X".equals(osDotName) || "Darwin".equals(osDotName);
+ return "Mac OS X".equals(osDotName) || "Darwin".equals(osDotName); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
protected OutputStream overflow() throws IOException {
- onDiskFile = File.createTempFile("jgit_", ".buf", directory);
+ onDiskFile = File.createTempFile("jgit_", ".buf", directory); //$NON-NLS-1$ //$NON-NLS-2$
return new FileOutputStream(onDiskFile);
}
/** Create a new timer with a default thread name. */
public InterruptTimer() {
- this("JGit-InterruptTimer");
+ this("JGit-InterruptTimer"); //$NON-NLS-1$
}
/**
* closed when the thread terminates.
*/
public StreamCopyThread(final InputStream i, final OutputStream o) {
- setName(Thread.currentThread().getName() + "-StreamCopy");
+ setName(Thread.currentThread().getName() + "-StreamCopy"); //$NON-NLS-1$
src = i;
dst = o;
}
this.out = out;
LF = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return SystemReader.getInstance().getProperty("line.separator");
+ return SystemReader.getInstance().getProperty("line.separator"); //$NON-NLS-1$
}
});
}