Browse Source

Mark non-externalizable strings as such

A few classes such as Constanrs are marked with @SuppressWarnings, as are
toString() methods with many liternal, but otherwise $NLS-n$ is used for
string containing text that should not be translated. A few literals may
fall into the gray zone, but mostly I've tried to only tag the obvious
ones.

Change-Id: I22e50a77e2bf9e0b842a66bdf674e8fa1692f590
tags/v2.3.0.201302130906
Robin Rosenberg 11 years ago
parent
commit
c310fa0c80
100 changed files with 429 additions and 411 deletions
  1. 4
    4
      org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java
  2. 6
    6
      org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java
  3. 4
    4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
  4. 4
    4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java
  5. 31
    31
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java
  6. 3
    3
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java
  7. 3
    3
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
  8. 3
    3
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
  9. 3
    3
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java
  10. 1
    1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
  11. 3
    3
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
  12. 8
    8
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java
  13. 1
    1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java
  14. 12
    12
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java
  15. 1
    1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
  16. 12
    12
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
  17. 4
    4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
  18. 5
    5
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
  19. 5
    5
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java
  20. 11
    11
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java
  21. 1
    1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
  22. 5
    5
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
  23. 1
    1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java
  24. 3
    4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java
  25. 3
    3
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java
  26. 1
    1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java
  27. 6
    6
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
  28. 1
    1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java
  29. 1
    1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java
  30. 4
    4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java
  31. 1
    1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java
  32. 2
    2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java
  33. 2
    2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java
  34. 1
    1
      org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AWTPlotRenderer.java
  35. 3
    3
      org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AwtAuthenticator.java
  36. 7
    6
      org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java
  37. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java
  38. 3
    3
      org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java
  39. 3
    3
      org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
  40. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java
  41. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java
  42. 2
    1
      org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
  43. 12
    12
      org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
  44. 13
    13
      org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java
  45. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteBranchCommand.java
  46. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java
  47. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java
  48. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java
  49. 7
    7
      org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
  50. 1
    0
      org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
  51. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java
  52. 1
    0
      org.eclipse.jgit/src/org/eclipse/jgit/api/PullResult.java
  53. 42
    38
      org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
  54. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java
  55. 3
    3
      org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
  56. 5
    5
      org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java
  57. 3
    3
      org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java
  58. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java
  59. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/ConcurrentRefUpdateException.java
  60. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
  61. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameResult.java
  62. 3
    2
      org.eclipse.jgit/src/org/eclipse/jgit/blame/Candidate.java
  63. 8
    8
      org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java
  64. 2
    1
      org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java
  65. 28
    28
      org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
  66. 1
    0
      org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
  67. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/diff/EditList.java
  68. 3
    3
      org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
  69. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java
  70. 3
    3
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
  71. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheBuilder.java
  72. 6
    6
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
  73. 1
    0
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
  74. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/errors/CheckoutConflictException.java
  75. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.java
  76. 3
    3
      org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java
  77. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java
  78. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.java
  79. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/errors/RevisionSyntaxException.java
  80. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationBundleLoadingException.java
  81. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationStringMissingException.java
  82. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/errors/TransportException.java
  83. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/errors/UnsupportedCredentialItem.java
  84. 1
    0
      org.eclipse.jgit/src/org/eclipse/jgit/events/ListenerHandle.java
  85. 1
    0
      org.eclipse.jgit/src/org/eclipse/jgit/events/RepositoryEvent.java
  86. 5
    5
      org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java
  87. 17
    17
      org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/GroupHead.java
  88. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java
  89. 12
    12
      org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreRule.java
  90. 2
    1
      org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java
  91. 1
    0
      org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java
  92. 3
    3
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
  93. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java
  94. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchingProgressMonitor.java
  95. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
  96. 6
    5
      org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java
  97. 19
    19
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
  98. 1
    0
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
  99. 1
    0
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java
  100. 0
    0
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigSnapshot.java

+ 4
- 4
org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java View File

@Override @Override
protected PasswordAuthentication promptPasswordAuthentication() { protected PasswordAuthentication promptPasswordAuthentication() {
final String realm = formatRealm(); 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()) { if (username == null || username.isEmpty()) {
return null; return null;
} }
char[] password = cons.readPassword(ConsoleText.get().password + " ");
char[] password = cons.readPassword(ConsoleText.get().password + " "); //$NON-NLS-1$
if (password == null) { if (password == null) {
password = new char[0]; password = new char[0];
} }
final StringBuilder realm = new StringBuilder(); final StringBuilder realm = new StringBuilder();
if (getRequestorType() == RequestorType.PROXY) { if (getRequestorType() == RequestorType.PROXY) {
realm.append(getRequestorType()); realm.append(getRequestorType());
realm.append(" ");
realm.append(" "); //$NON-NLS-1$
realm.append(getRequestingHost()); realm.append(getRequestingHost());
if (getRequestingPort() > 0) { if (getRequestingPort() > 0) {
realm.append(":");
realm.append(":"); //$NON-NLS-1$
realm.append(getRequestingPort()); realm.append(getRequestingPort());
} }
} else { } else {

+ 6
- 6
org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java View File



private boolean get(CredentialItem.StringType item) { private boolean get(CredentialItem.StringType item) {
if (item.isValueSecure()) { if (item.isValueSecure()) {
char[] v = cons.readPassword("%s: ", item.getPromptText());
char[] v = cons.readPassword("%s: ", item.getPromptText()); //$NON-NLS-1$
if (v != null) { if (v != null) {
item.setValue(new String(v)); item.setValue(new String(v));
return true; return true;
return false; return false;
} }
} else { } else {
String v = cons.readLine("%s: ", item.getPromptText());
String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
if (v != null) { if (v != null) {
item.setValue(v); item.setValue(v);
return true; return true;


private boolean get(CredentialItem.CharArrayType item) { private boolean get(CredentialItem.CharArrayType item) {
if (item.isValueSecure()) { if (item.isValueSecure()) {
char[] v = cons.readPassword("%s: ", item.getPromptText());
char[] v = cons.readPassword("%s: ", item.getPromptText()); //$NON-NLS-1$
if (v != null) { if (v != null) {
item.setValueNoCopy(v); item.setValueNoCopy(v);
return true; return true;
return false; return false;
} }
} else { } else {
String v = cons.readLine("%s: ", item.getPromptText());
String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
if (v != null) { if (v != null) {
item.setValueNoCopy(v.toCharArray()); item.setValueNoCopy(v.toCharArray());
return true; return true;
} }


private boolean get(CredentialItem.InformationalMessage item) { private boolean get(CredentialItem.InformationalMessage item) {
cons.printf("%s\n", item.getPromptText());
cons.printf("%s\n", item.getPromptText()); //$NON-NLS-1$
cons.flush(); cons.flush();
return true; return true;
} }


private boolean get(CredentialItem.YesNoType item) { 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); ConsoleText.get().answerYes, ConsoleText.get().answerNo);
if (r != null) { if (r != null) {
item.setValue(ConsoleText.get().answerYes.equalsIgnoreCase(r)); item.setValue(ConsoleText.get().answerYes.equalsIgnoreCase(r));

+ 4
- 4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java View File

shownURI = true; 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); src, dst);
outw.println(); outw.println();
} }
if (r == RefUpdate.Result.FORCED) { if (r == RefUpdate.Result.FORCED) {
final String aOld = safeAbbreviate(reader, u.getOldObjectId()); final String aOld = safeAbbreviate(reader, u.getOldObjectId());
final String aNew = safeAbbreviate(reader, u.getNewObjectId()); final String aNew = safeAbbreviate(reader, u.getNewObjectId());
return aOld + "..." + aNew;
return aOld + "..." + aNew; //$NON-NLS-1$
} }


if (r == RefUpdate.Result.FAST_FORWARD) { if (r == RefUpdate.Result.FAST_FORWARD) {
final String aOld = safeAbbreviate(reader, u.getOldObjectId()); final String aOld = safeAbbreviate(reader, u.getOldObjectId());
final String aNew = safeAbbreviate(reader, u.getNewObjectId()); final String aNew = safeAbbreviate(reader, u.getNewObjectId());
return aOld + ".." + aNew;
return aOld + ".." + aNew; //$NON-NLS-1$
} }


if (r == RefUpdate.Result.NO_CHANGE) if (r == RefUpdate.Result.NO_CHANGE)
return "[up to date]"; return "[up to date]";
return "[" + r.name() + "]";
return "[" + r.name() + "]"; //$NON-NLS-1$//$NON-NLS-2$
} }


private String safeAbbreviate(ObjectReader reader, ObjectId id) { private String safeAbbreviate(ObjectReader reader, ObjectId id) {

+ 4
- 4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java View File

protected void run() throws Exception { protected void run() throws Exception {
final AmazonS3 s3 = new AmazonS3(properties()); final AmazonS3 s3 = new AmazonS3(properties());


if ("get".equals(op)) {
if ("get".equals(op)) { //$NON-NLS-1$
final URLConnection c = s3.get(bucket, key); final URLConnection c = s3.get(bucket, key);
int len = c.getContentLength(); int len = c.getContentLength();
final InputStream in = c.getInputStream(); final InputStream in = c.getInputStream();
in.close(); 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)) for (final String k : s3.list(bucket, key))
outw.println(k); 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); 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 OutputStream os = s3.beginPut(bucket, key, null, null);
final byte[] tmp = new byte[2048]; final byte[] tmp = new byte[2048];
int n; int n;

+ 31
- 31
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java View File

} }


if (abbrev == 0) 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) if (!showBlankBoundary)
root = db.getConfig().getBoolean("blame", "blankboundary", false);
root = db.getConfig().getBoolean("blame", "blankboundary", false); //$NON-NLS-1$ //$NON-NLS-2$
if (!root) if (!root)
root = db.getConfig().getBoolean("blame", "showroot", false);
root = db.getConfig().getBoolean("blame", "showroot", false); //$NON-NLS-1$ //$NON-NLS-2$


if (showRawTimestamp) if (showRawTimestamp)
dateFmt = new SimpleDateFormat("ZZZZ");
dateFmt = new SimpleDateFormat("ZZZZ"); //$NON-NLS-1$
else 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); BlameGenerator generator = new BlameGenerator(db, file);
reader = db.newObjectReader(); reader = db.newObjectReader();
} }
generator.reverse(rangeStart, rangeEnd); generator.reverse(rangeStart, rangeEnd);
} else if (revision != null) { } else if (revision != null) {
generator.push(null, db.resolve(revision + "^{commit}"));
generator.push(null, db.resolve(revision + "^{commit}")); //$NON-NLS-1$
} else { } else {
generator.push(null, db.resolve(Constants.HEAD)); generator.push(null, db.resolve(Constants.HEAD));
if (!db.isBare()) { if (!db.isBare()) {
maxSourceLine = Math.max(maxSourceLine, blame.getSourceLine(line)); 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))); 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))); 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)); valueOf(authorWidth), valueOf(dateWidth));


for (int line = begin; line < end; line++) { for (int line = begin; line < end; line++) {


private void parseLineRangeOption() { private void parseLineRangeOption() {
String beginStr, endStr; 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) { if (c < 0) {
beginStr = rangeString; beginStr = rangeString;
endStr = String.valueOf(end); endStr = String.valueOf(end);
beginStr = rangeString; beginStr = rangeString;
endStr = String.valueOf(end); endStr = String.valueOf(end);
} else if (c == 0) { } else if (c == 0) {
beginStr = "0";
beginStr = "0"; //$NON-NLS-1$
endStr = rangeString.substring(1); endStr = rangeString.substring(1);
} else { } else {
beginStr = rangeString.substring(0, c); beginStr = rangeString.substring(0, c);
} }
} }


if (beginStr.equals(""))
if (beginStr.equals("")) //$NON-NLS-1$
begin = 0; begin = 0;
else if (beginStr.startsWith("/"))
else if (beginStr.startsWith("/")) //$NON-NLS-1$
begin = findLine(0, beginStr); begin = findLine(0, beginStr);
else else
begin = Math.max(0, Integer.parseInt(beginStr) - 1); begin = Math.max(0, Integer.parseInt(beginStr) - 1);


if (endStr.equals(""))
if (endStr.equals("")) //$NON-NLS-1$
end = blame.getResultContents().size(); end = blame.getResultContents().size();
else if (endStr.startsWith("/"))
else if (endStr.startsWith("/")) //$NON-NLS-1$
end = findLine(begin, endStr); end = findLine(begin, endStr);
else if (endStr.startsWith("-"))
else if (endStr.startsWith("-")) //$NON-NLS-1$
end = begin + Integer.parseInt(endStr); end = begin + Integer.parseInt(endStr);
else if (endStr.startsWith("+"))
else if (endStr.startsWith("+")) //$NON-NLS-1$
end = begin + Integer.parseInt(endStr.substring(1)); end = begin + Integer.parseInt(endStr.substring(1));
else else
end = Math.max(0, Integer.parseInt(endStr) - 1); end = Math.max(0, Integer.parseInt(endStr) - 1);


private int findLine(int b, String regex) { private int findLine(int b, String regex) {
String re = regex.substring(1, regex.length() - 1); 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); Pattern p = Pattern.compile(re);
RawText text = blame.getResultContents(); RawText text = blame.getResultContents();
for (int line = b; line < text.size(); line++) { for (int line = b; line < text.size(); line++) {


private String path(int line) { private String path(int line) {
String p = blame.getSourcePath(line); String p = blame.getSourcePath(line);
return p != null ? p : "";
return p != null ? p : ""; //$NON-NLS-1$
} }


private String author(int line) { private String author(int line) {
PersonIdent author = blame.getSourceAuthor(line); PersonIdent author = blame.getSourceAuthor(line);
if (author == null) if (author == null)
return "";
return ""; //$NON-NLS-1$
String name = showAuthorEmail ? author.getEmailAddress() : author String name = showAuthorEmail ? author.getEmailAddress() : author
.getName(); .getName();
return name != null ? name : "";
return name != null ? name : ""; //$NON-NLS-1$
} }


private String date(int line) { private String date(int line) {
if (blame.getSourceCommit(line) == null) if (blame.getSourceCommit(line) == null)
return "";
return ""; //$NON-NLS-1$


PersonIdent author = blame.getSourceAuthor(line); PersonIdent author = blame.getSourceAuthor(line);
if (author == null) if (author == null)
return "";
return ""; //$NON-NLS-1$


dateFmt.setTimeZone(author.getTimeZone()); dateFmt.setTimeZone(author.getTimeZone());
if (!showRawTimestamp) if (!showRawTimestamp)
return dateFmt.format(author.getWhen()); return dateFmt.format(author.getWhen());
return String.format("%d %s",
return String.format("%d %s", //$NON-NLS-1$
valueOf(author.getWhen().getTime() / 1000L), valueOf(author.getWhen().getTime() / 1000L),
dateFmt.format(author.getWhen())); dateFmt.format(author.getWhen()));
} }


} else if (!root && commit.getParentCount() == 0) { } else if (!root && commit.getParentCount() == 0) {
if (showLongRevision) 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 else
r = "^" + reader.abbreviate(commit, abbrev).name();
r = "^" + reader.abbreviate(commit, abbrev).name(); //$NON-NLS-1$
} else { } else {
if (showLongRevision) if (showLongRevision)
r = commit.name(); r = commit.name();

+ 3
- 3
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java View File

else else
startBranch = Constants.HEAD; startBranch = Constants.HEAD;
Ref startRef = db.getRef(startBranch); Ref startRef = db.getRef(startBranch);
ObjectId startAt = db.resolve(startBranch + "^0");
ObjectId startAt = db.resolve(startBranch + "^0"); //$NON-NLS-1$
if (startRef != null) if (startRef != null)
startBranch = startRef.getName(); startBranch = startRef.getName();
else else
if (head != null) { if (head != null) {
String current = head.getLeaf().getName(); String current = head.getLeaf().getName();
if (current.equals(Constants.HEAD)) 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_HEADS, !remote);
addRefs(refs, Constants.R_REMOTES, remote); addRefs(refs, Constants.R_REMOTES, remote);


outw.print(ref); outw.print(ref);
if (verbose) { if (verbose) {
final int spaces = maxNameLength - ref.length() + 1; 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(); final ObjectId objectId = refObj.getObjectId();
outw.print(reader.abbreviate(objectId).name()); outw.print(reader.abbreviate(objectId).name());
outw.print(' '); outw.print(' ');

+ 3
- 3
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java View File

dst = new FileRepository(gitdir); dst = new FileRepository(gitdir);
dst.create(); dst.create();
final FileBasedConfig dstcfg = dst.getConfig(); 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(); dstcfg.save();
db = dst; db = dst;


final RemoteConfig rc = new RemoteConfig(dstcfg, remoteName); final RemoteConfig rc = new RemoteConfig(dstcfg, remoteName);
rc.addURI(uri); rc.addURI(uri);
rc.addFetchRefSpec(new RefSpec().setForceUpdate(true) 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); rc.update(dstcfg);
dstcfg.save(); dstcfg.save();
} }

+ 3
- 3
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java View File



private Enumeration<URL> catalogs() { private Enumeration<URL> catalogs() {
try { try {
final String pfx = "META-INF/services/";
final String pfx = "META-INF/services/"; //$NON-NLS-1$
return ldr.getResources(pfx + TextBuiltin.class.getName()); return ldr.getResources(pfx + TextBuiltin.class.getName());
} catch (IOException err) { } catch (IOException err) {
return new Vector<URL>().elements(); return new Vector<URL>().elements();
final BufferedReader cIn; final BufferedReader cIn;
try { try {
final InputStream in = cUrl.openStream(); 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) { } catch (IOException err) {
// If we cannot read from the service list, go to the next. // If we cannot read from the service list, go to the next.
// //
try { try {
String line; String line;
while ((line = cIn.readLine()) != null) { while ((line = cIn.readLine()) != null) {
if (line.length() > 0 && !line.startsWith("#"))
if (line.length() > 0 && !line.startsWith("#")) //$NON-NLS-1$
load(line); load(line);
} }
} catch (IOException err) { } catch (IOException err) {

+ 3
- 3
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java View File

private CommandRef(final Class<? extends TextBuiltin> clazz, final String cn) { private CommandRef(final Class<? extends TextBuiltin> clazz, final String cn) {
impl = clazz; impl = clazz;
name = cn; name = cn;
usage = "";
usage = ""; //$NON-NLS-1$
} }


private static String guessName(final Class<? extends TextBuiltin> clazz) { private static String guessName(final Class<? extends TextBuiltin> clazz) {
final StringBuilder s = new StringBuilder(); 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; boolean lastWasDash = true;
for (final char c : clazz.getSimpleName().toCharArray()) { for (final char c : clazz.getSimpleName().toCharArray()) {

+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java View File

if (branchName.startsWith(Constants.R_HEADS)) if (branchName.startsWith(Constants.R_HEADS))
branchName = branchName.substring(Constants.R_HEADS.length()); 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()); + commit.getShortMessage());
} }
} }

+ 3
- 3
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java View File

Set<String> names = config.getNames(section); Set<String> names = config.getNames(section);
for (String name : names) { for (String name : names) {
for (String value : config.getStringList(section, null, name)) 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()) { if (names.isEmpty()) {
for (String subsection : config.getSubsections(section)) { for (String subsection : config.getSubsections(section)) {
for (String name : names) { for (String name : names) {
for (String value : config.getStringList(section, for (String value : config.getStringList(section,
subsection, name)) subsection, name))
outw.println(section + "." + subsection + "."
+ name + "=" + value);
outw.println(section + "." + subsection + "." //$NON-NLS-1$ //$NON-NLS-2$
+ name + "=" + value); //$NON-NLS-1$
} }
} }
} }

+ 8
- 8
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java View File



@Option(name = "--no-prefix", usage = "usage_noPrefix") @Option(name = "--no-prefix", usage = "usage_noPrefix")
void noPrefix(@SuppressWarnings("unused") boolean on) { 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 // END -- Options shared with Log
try { try {
if (cached) { if (cached) {
if (oldTree == null) { if (oldTree == null) {
ObjectId head = db.resolve(HEAD + "^{tree}");
ObjectId head = db.resolve(HEAD + "^{tree}"); //$NON-NLS-1$
if (head == null) if (head == null)
die(MessageFormat.format(CLIText.get().notATree, HEAD)); die(MessageFormat.format(CLIText.get().notATree, HEAD));
CanonicalTreeParser p = new CanonicalTreeParser(); CanonicalTreeParser p = new CanonicalTreeParser();
for (DiffEntry ent : files) { for (DiffEntry ent : files) {
switch (ent.getChangeType()) { switch (ent.getChangeType()) {
case ADD: case ADD:
out.println("A\t" + ent.getNewPath());
out.println("A\t" + ent.getNewPath()); //$NON-NLS-1$
break; break;
case DELETE: case DELETE:
out.println("D\t" + ent.getOldPath());
out.println("D\t" + ent.getOldPath()); //$NON-NLS-1$
break; break;
case MODIFY: case MODIFY:
out.println("M\t" + ent.getNewPath());
out.println("M\t" + ent.getNewPath()); //$NON-NLS-1$
break; break;
case COPY: 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()); ent.getOldPath(), ent.getNewPath());
out.println(); out.println();
break; break;
case RENAME: 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()); ent.getOldPath(), ent.getNewPath());
out.println(); out.println();
break; break;

+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java View File

graphPane.getCommitList().source(walk); graphPane.getCommitList().source(walk);
graphPane.getCommitList().fillTo(Integer.MAX_VALUE); graphPane.getCommitList().fillTo(Integer.MAX_VALUE);


frame.setTitle("[" + repoName() + "]");
frame.setTitle("[" + repoName() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
frame.pack(); frame.pack();
frame.setVisible(true); frame.setVisible(true);
return graphPane.getCommitList().size(); return graphPane.getCommitList().size();

+ 12
- 12
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java View File



@Option(name = "--no-prefix", usage = "usage_noPrefix") @Option(name = "--no-prefix", usage = "usage_noPrefix")
void noPrefix(@SuppressWarnings("unused") boolean on) { 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 // END -- Options shared with Diff
@Override @Override
protected void show(final RevCommit c) throws Exception { protected void show(final RevCommit c) throws Exception {
outw.print(CLIText.get().commitLabel); outw.print(CLIText.get().commitLabel);
outw.print(" ");
outw.print(" "); //$NON-NLS-1$
c.getId().copyTo(outbuffer, outw); c.getId().copyTo(outbuffer, outw);
if (decorate) { if (decorate) {
Collection<Ref> list = allRefsByPeeledObjectId.get(c); Collection<Ref> list = allRefsByPeeledObjectId.get(c);
if (list != null) { if (list != null) {
outw.print(" (");
outw.print(" ("); //$NON-NLS-1$
for (Iterator<Ref> i = list.iterator(); i.hasNext(); ) { for (Iterator<Ref> i = list.iterator(); i.hasNext(); ) {
outw.print(i.next().getName()); outw.print(i.next().getName());
if (i.hasNext()) if (i.hasNext())
outw.print(" ");
outw.print(" "); //$NON-NLS-1$
} }
outw.print(")");
outw.print(")"); //$NON-NLS-1$
} }
} }
outw.println(); outw.println();
dateFormatter.formatDate(author))); dateFormatter.formatDate(author)));


outw.println(); outw.println();
final String[] lines = c.getFullMessage().split("\n");
final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
for (final String s : lines) { for (final String s : lines) {
outw.print(" ");
outw.print(" "); //$NON-NLS-1$
outw.print(s); outw.print(s);
outw.println(); outw.println();
} }
outw.println(); outw.println();
outw.print("Notes"); outw.print("Notes");
if (label != null) { if (label != null) {
outw.print(" (");
outw.print(" ("); //$NON-NLS-1$
outw.print(label); outw.print(label);
outw.print(")");
outw.print(")"); //$NON-NLS-1$
} }
outw.println(":");
outw.println(":"); //$NON-NLS-1$
try { try {
RawText rawText = new RawText(argWalk.getObjectReader() RawText rawText = new RawText(argWalk.getObjectReader()
.open(blobId).getCachedBytes(Integer.MAX_VALUE)); .open(blobId).getCachedBytes(Integer.MAX_VALUE));
for (int i = 0; i < rawText.size(); i++) { for (int i = 0; i < rawText.size(); i++) {
outw.print(" ");
outw.print(" "); //$NON-NLS-1$
outw.println(rawText.getString(i)); outw.println(rawText.getString(i));
} }
} catch (LargeObjectException e) { } catch (LargeObjectException e) {

+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java View File

for (final Ref r : c.getRefs()) { for (final Ref r : c.getRefs()) {
show(r.getObjectId(), r.getName()); show(r.getObjectId(), r.getName());
if (r.getPeeledObjectId() != null) if (r.getPeeledObjectId() != null)
show(r.getPeeledObjectId(), r.getName() + "^{}");
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
} }
} finally { } finally {
c.close(); c.close();

+ 12
- 12
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java View File

&& err instanceof TransportException) && err instanceof TransportException)
System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getCause().getMessage())); 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())); System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
if (showStackTrace) if (showStackTrace)
err.printStackTrace(); err.printStackTrace();


if (argv.length == 0 || help) { if (argv.length == 0 || help) {
final String ex = clp.printExample(ExampleMode.ALL, CLIText.get().resourceBundle()); 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) { if (help) {
writer.println(); writer.println();
clp.printUsage(writer, CLIText.get().resourceBundle()); clp.printUsage(writer, CLIText.get().resourceBundle());


private static boolean installConsole() { private static boolean installConsole() {
try { 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; return true;
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
return false; return false;
throws IllegalAccessException, InvocationTargetException, throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException, ClassNotFoundException { NoSuchMethodException, ClassNotFoundException {
try { try {
Class.forName(name).getMethod("install").invoke(null);
Class.forName(name).getMethod("install").invoke(null); //$NON-NLS-1$
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (e.getCause() instanceof RuntimeException) if (e.getCause() instanceof RuntimeException)
throw (RuntimeException) e.getCause(); throw (RuntimeException) e.getCause();
* the value in <code>http_proxy</code> is unsupportable. * the value in <code>http_proxy</code> is unsupportable.
*/ */
private static void configureHttpProxy() throws MalformedURLException { 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; 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)); throw new MalformedURLException(MessageFormat.format(CLIText.get().invalidHttpProxyOnlyHttpSupported, s));


final String proxyHost = u.getHost(); final String proxyHost = u.getHost();
final int proxyPort = u.getPort(); final int proxyPort = u.getPort();


System.setProperty("http.proxyHost", proxyHost);
System.setProperty("http.proxyHost", proxyHost); //$NON-NLS-1$
if (proxyPort > 0) 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(); final String userpass = u.getUserInfo();
if (userpass != null && userpass.contains(":")) {
if (userpass != null && userpass.contains(":")) { //$NON-NLS-1$
final int c = userpass.indexOf(':'); final int c = userpass.indexOf(':');
final String user = userpass.substring(0, c); final String user = userpass.substring(0, c);
final String pass = userpass.substring(c + 1); final String pass = userpass.substring(c + 1);

+ 4
- 4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java View File



// determine the other revision we want to merge with HEAD // determine the other revision we want to merge with HEAD
final Ref srcRef = db.getRef(ref); 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) if (src == null)
throw die(MessageFormat.format( throw die(MessageFormat.format(
CLIText.get().refDoesNotExistOrNoCommit, ref)); CLIText.get().refDoesNotExistOrNoCommit, ref));
case DIRTY_WORKTREE: case DIRTY_WORKTREE:
case DIRTY_INDEX: case DIRTY_INDEX:
outw.println(CLIText.get().dontOverwriteLocalChanges); outw.println(CLIText.get().dontOverwriteLocalChanges);
outw.println(" " + entry.getKey());
outw.println(" " + entry.getKey()); //$NON-NLS-1$
break; break;
case COULD_NOT_DELETE: case COULD_NOT_DELETE:
outw.println(CLIText.get().cannotDeleteFile); outw.println(CLIText.get().cannotDeleteFile);
outw.println(" " + entry.getKey());
outw.println(" " + entry.getKey()); //$NON-NLS-1$
break; break;
} }
break; break;
if (!isMergedInto(oldHead, src)) if (!isMergedInto(oldHead, src))
name = mergeStrategy.getName(); name = mergeStrategy.getName();
else else
name = "recursive";
name = "recursive"; //$NON-NLS-1$
outw.println(MessageFormat.format(CLIText.get().mergeMadeBy, name)); outw.println(MessageFormat.format(CLIText.get().mergeMadeBy, name));
break; break;
case MERGED_SQUASHED: case MERGED_SQUASHED:

+ 5
- 5
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java View File

final char flag = fastForward ? ' ' : '+'; final char flag = fastForward ? ' ' : '+';
final String summary = safeAbbreviate(reader, oldRef final String summary = safeAbbreviate(reader, oldRef
.getObjectId()) .getObjectId())
+ (fastForward ? ".." : "...")
+ (fastForward ? ".." : "...") //$NON-NLS-1$ //$NON-NLS-2$
+ safeAbbreviate(reader, rru.getNewObjectId()); + safeAbbreviate(reader, rru.getNewObjectId());
final String message = fastForward ? null : CLIText.get().forcedUpdate; final String message = fastForward ? null : CLIText.get().forcedUpdate;
printUpdateLine(flag, summary, srcRef, remoteName, message); printUpdateLine(flag, summary, srcRef, remoteName, message);
private void printUpdateLine(final char flag, final String summary, private void printUpdateLine(final char flag, final String summary,
final String srcRef, final String destRef, final String message) final String srcRef, final String destRef, final String message)
throws IOException { throws IOException {
outw.format(" %c %-17s", valueOf(flag), summary);
outw.format(" %c %-17s", valueOf(flag), summary); //$NON-NLS-1$


if (srcRef != null) 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) if (message != null)
outw.format(" (%s)", message);
outw.format(" (%s)", message); //$NON-NLS-1$


outw.println(); outw.println();
} }

+ 5
- 5
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java View File

private String toString(ReflogEntry entry, int i) { private String toString(ReflogEntry entry, int i) {
final StringBuilder s = new StringBuilder(); final StringBuilder s = new StringBuilder();
s.append(entry.getNewId().abbreviate(7).name()); s.append(entry.getNewId().abbreviate(7).name());
s.append(" ");
s.append(" "); //$NON-NLS-1$
s.append(ref == null ? Constants.HEAD : Repository.shortenRefName(ref)); s.append(ref == null ? Constants.HEAD : Repository.shortenRefName(ref));
s.append("@{" + i + "}:");
s.append(" ");
s.append("@{" + i + "}:"); //$NON-NLS-1$ //$NON-NLS-2$
s.append(" "); //$NON-NLS-1$
// temporary workaround for bug 393463 // temporary workaround for bug 393463
if (entry.getOldId().equals(ObjectId.zeroId())) if (entry.getOldId().equals(ObjectId.zeroId()))
s.append(entry.getComment().replaceFirst("^commit:",
"commit (initial):"));
s.append(entry.getComment().replaceFirst("^commit:", //$NON-NLS-1$
"commit (initial):")); //$NON-NLS-1$
else else
s.append(entry.getComment()); s.append(entry.getComment());
return s.toString(); return s.toString();

+ 11
- 11
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java View File



@Option(name = "--no-prefix", usage = "usage_noPrefix") @Option(name = "--no-prefix", usage = "usage_noPrefix")
void noPrefix(@SuppressWarnings("unused") boolean on) { 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 // END -- Options shared with Diff


Show() { 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") @SuppressWarnings("boxing")
break; break;


case Constants.OBJ_TREE: case Constants.OBJ_TREE:
outw.print("tree ");
outw.print("tree "); //$NON-NLS-1$
outw.print(objectName); outw.print(objectName);
outw.println(); outw.println();
outw.println(); outw.println();


private void show(RevTag tag) throws IOException { private void show(RevTag tag) throws IOException {
outw.print(CLIText.get().tagLabel); outw.print(CLIText.get().tagLabel);
outw.print(" ");
outw.print(" "); //$NON-NLS-1$
outw.print(tag.getTagName()); outw.print(tag.getTagName());
outw.println(); outw.println();


} }


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) { for (final String s : lines) {
outw.print(" ");
outw.print(" "); //$NON-NLS-1$
outw.print(s); outw.print(s);
outw.println(); outw.println();
} }
outw.print(walk.getPathString()); outw.print(walk.getPathString());
final FileMode mode = walk.getFileMode(0); final FileMode mode = walk.getFileMode(0);
if (mode == FileMode.TREE) if (mode == FileMode.TREE)
outw.print("/");
outw.print("/"); //$NON-NLS-1$
outw.println(); outw.println();
} }
} }
char[] outbuffer = new char[Constants.OBJECT_ID_LENGTH * 2]; char[] outbuffer = new char[Constants.OBJECT_ID_LENGTH * 2];


outw.print(CLIText.get().commitLabel); outw.print(CLIText.get().commitLabel);
outw.print(" ");
outw.print(" "); //$NON-NLS-1$
c.getId().copyTo(outbuffer, outw); c.getId().copyTo(outbuffer, outw);
outw.println(); outw.println();


fmt.format(author.getWhen()))); fmt.format(author.getWhen())));


outw.println(); outw.println();
final String[] lines = c.getFullMessage().split("\n");
final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
for (final String s : lines) { for (final String s : lines) {
outw.print(" ");
outw.print(" "); //$NON-NLS-1$
outw.print(s); outw.print(s);
outw.println(); outw.println();
} }

+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java View File

for (final Ref r : getSortedRefs()) { for (final Ref r : getSortedRefs()) {
show(r.getObjectId(), r.getName()); show(r.getObjectId(), r.getName());
if (r.getPeeledObjectId() != null) if (r.getPeeledObjectId() != null)
show(r.getPeeledObjectId(), r.getName() + "^{}");
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
} }
} }



+ 5
- 5
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java View File

int nbNotStagedForCommit = notStagedForCommit.size(); int nbNotStagedForCommit = notStagedForCommit.size();
if (nbNotStagedForCommit > 0) { if (nbNotStagedForCommit > 0) {
if (!firstHeader) if (!firstHeader)
printSectionHeader("");
printSectionHeader(""); //$NON-NLS-1$
printSectionHeader(CLIText.get().changesNotStagedForCommit); printSectionHeader(CLIText.get().changesNotStagedForCommit);
printList(CLIText.get().statusModified, printList(CLIText.get().statusModified,
CLIText.get().statusRemoved, null, notStagedForCommit, CLIText.get().statusRemoved, null, notStagedForCommit,
int nbUnmerged = unmerged.size(); int nbUnmerged = unmerged.size();
if (nbUnmerged > 0) { if (nbUnmerged > 0) {
if (!firstHeader) if (!firstHeader)
printSectionHeader("");
printSectionHeader(""); //$NON-NLS-1$
printSectionHeader(CLIText.get().unmergedPaths); printSectionHeader(CLIText.get().unmergedPaths);
printList(unmerged); printList(unmerged);
firstHeader = false; firstHeader = false;
int nbUntracked = untracked.size(); int nbUntracked = untracked.size();
if (nbUntracked > 0) { if (nbUntracked > 0) {
if (!firstHeader) if (!firstHeader)
printSectionHeader("");
printSectionHeader(""); //$NON-NLS-1$
printSectionHeader(CLIText.get().untrackedFiles); printSectionHeader(CLIText.get().untrackedFiles);
printList(untracked); printList(untracked);
} }
throws IOException { throws IOException {
outw.println(CLIText.formatLine(MessageFormat outw.println(CLIText.formatLine(MessageFormat
.format(pattern, arguments))); .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(); outw.flush();
} }



+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java View File

private boolean force; private boolean force;


@Option(name = "-m", metaVar = "metaVar_message", usage = "usage_tagMessage") @Option(name = "-m", metaVar = "metaVar_message", usage = "usage_tagMessage")
private String message = "";
private String message = ""; //$NON-NLS-1$


@Argument(index = 0, metaVar = "metaVar_name") @Argument(index = 0, metaVar = "metaVar_name")
private String tagName; private String tagName;

+ 3
- 4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java View File

protected void init(final Repository repository, final String gitDir) { protected void init(final Repository repository, final String gitDir) {
try { try {
final String outputEncoding = repository != null ? repository 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) if (outs == null)
outs = new FileOutputStream(FileDescriptor.out); outs = new FileOutputStream(FileDescriptor.out);
BufferedWriter bufw; BufferedWriter bufw;
* @param clp * @param clp
*/ */
public void printUsageAndExit(final CmdLineParser clp) { public void printUsageAndExit(final CmdLineParser clp) {
printUsageAndExit("", clp);
printUsageAndExit("", clp); //$NON-NLS-1$
} }


/** /**
public void printUsageAndExit(final String message, final CmdLineParser clp) { public void printUsageAndExit(final String message, final CmdLineParser clp) {
PrintWriter writer = new PrintWriter(System.err); PrintWriter writer = new PrintWriter(System.err);
writer.println(message); writer.println(message);
writer.print("jgit ");
writer.print("jgit "); //$NON-NLS-1$
writer.print(commandName); writer.print(commandName);
clp.printSingleLineUsage(writer, getResourceBundle()); clp.printSingleLineUsage(writer, getResourceBundle());
writer.println(); writer.println();

+ 3
- 3
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java View File

"Algorithm", "Time(ns)", "Time(ns) on", "Time(ns) on"); "Algorithm", "Time(ns)", "Time(ns) on", "Time(ns) on");
outw.format("%-25s %12s ( %12s %12s )\n", // outw.format("%-25s %12s ( %12s %12s )\n", //
"", "", "N=" + minN, "N=" + maxN); "", "", "N=" + minN, "N=" + maxN);
outw.println("-----------------------------------------------------"
+ "----------------");
outw.println("-----------------------------------------------------" //$NON-NLS-1$
+ "----------------"); //$NON-NLS-1$


for (Test test : all) { for (Test test : all) {
outw.format("%-25s %12d ( %12d %12d )", //
outw.format("%-25s %12d ( %12d %12d )", // //$NON-NLS-1$
test.algorithm.name, // test.algorithm.name, //
valueOf(test.runningTimeNanos), // valueOf(test.runningTimeNanos), //
valueOf(test.minN.runningTimeNanos), // valueOf(test.minN.runningTimeNanos), //

+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java View File

for (int i = 0; i < cnt; i++) for (int i = 0; i < cnt; i++)
db.readDirCache(); db.readDirCache();
final long end = System.currentTimeMillis(); final long end = System.currentTimeMillis();
outw.print(" ");
outw.print(" "); //$NON-NLS-1$
outw.println(MessageFormat.format(CLIText.get().averageMSPerRead, outw.println(MessageFormat.format(CLIText.get().averageMSPerRead,
valueOf((end - start) / cnt))); valueOf((end - start) / cnt)));
} }

+ 6
- 6
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java View File

* <p> * <p>
*/ */
class RebuildCommitGraph extends TextBuiltin { 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") @Option(name = REALLY, usage = "usage_approveDestructionOfRepository")
boolean really; boolean really;
try { try {
String line; String line;
while ((line = br.readLine()) != null) { 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]); final ObjectId oldId = ObjectId.fromString(parts[0]);
try { try {
rw.parseCommit(oldId); rw.parseCommit(oldId);
pm.beginTask("Rewriting commits", queue.size()); pm.beginTask("Rewriting commits", queue.size());
final ObjectInserter oi = db.newObjectInserter(); final ObjectInserter oi = db.newObjectInserter();
final ObjectId emptyTree = oi.insert(Constants.OBJ_TREE, new byte[] {}); 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()) { while (!queue.isEmpty()) {
final ListIterator<ToRewrite> itr = queue final ListIterator<ToRewrite> itr = queue
.listIterator(queue.size()); .listIterator(queue.size());
newc.setAuthor(new PersonIdent(me, new Date(t.commitTime))); newc.setAuthor(new PersonIdent(me, new Date(t.commitTime)));
newc.setCommitter(newc.getAuthor()); newc.setCommitter(newc.getAuthor());
newc.setParentIds(newParents); 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); t.newId = oi.insert(newc);
rewrites.put(t.oldId, t.newId); rewrites.put(t.oldId, t.newId);
pm.update(1); pm.update(1);
try { try {
String line; String line;
while ((line = br.readLine()) != null) { 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 ObjectId origId = ObjectId.fromString(parts[0]);
final String type = parts[1]; final String type = parts[1];
final String name = parts[2]; final String name = parts[2];

+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java View File

final ClassLoader ldr = c.getImplementationClassLoader(); final ClassLoader ldr = c.getImplementationClassLoader();


String cn = c.getImplementationClassName(); String cn = c.getImplementationClassName();
cn = cn.replace('.', '/') + ".class";
cn = cn.replace('.', '/') + ".class"; //$NON-NLS-1$


final URL url = ldr.getResource(cn); final URL url = ldr.getResource(cn);
if (url == null) { if (url == null) {

+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java View File

final int stage = ent.getStage(); final int stage = ent.getStage();


outw.print(mode); outw.print(mode);
outw.format(" %6d", valueOf(len));
outw.format(" %6d", valueOf(len)); //$NON-NLS-1$
outw.print(' '); outw.print(' ');
outw.print(fmt.format(mtime)); outw.print(fmt.format(mtime));
outw.print(' '); outw.print(' ');

+ 4
- 4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java View File

File parent = db.getDirectory().getParentFile(); File parent = db.getDirectory().getParentFile();
if (name.equals(Constants.DOT_GIT) && parent != null) if (name.equals(Constants.DOT_GIT) && parent != null)
name = parent.getName(); name = parent.getName();
outw.println(name + ":");
outw.println(name + ":"); //$NON-NLS-1$
} }
outw.format(" %6d files; %5d avg. unique lines/file\n", // outw.format(" %6d files; %5d avg. unique lines/file\n", //
valueOf(fileCnt), // valueOf(fileCnt), //
valueOf(lineCnt / fileCnt)); valueOf(lineCnt / fileCnt));
outw.format("%-20s %-15s %9s\n", "Hash", "Fold", "Max Len"); outw.format("%-20s %-15s %9s\n", "Hash", "Fold", "Max Len");
outw.println("-----------------------------------------------");
outw.println("-----------------------------------------------"); //$NON-NLS-1$
String lastHashName = null; String lastHashName = null;
for (Function fun : all) { for (Function fun : all) {
String hashName = fun.hash.name; String hashName = fun.hash.name;
if (hashName.equals(lastHashName)) 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, // hashName, //
fun.fold.name, // fun.fold.name, //
valueOf(fun.maxChainLength)); valueOf(fun.maxChainLength));

+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java View File

@Command(name = "eclipse-ipzilla", common = false, usage = "usage_synchronizeIPZillaData") @Command(name = "eclipse-ipzilla", common = false, usage = "usage_synchronizeIPZillaData")
class Ipzilla extends TextBuiltin { class Ipzilla extends TextBuiltin {
@Option(name = "--url", metaVar = "metaVar_url", usage = "usage_IPZillaURL") @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") @Option(name = "--username", metaVar = "metaVar_user", usage = "usage_IPZillaUsername")
private String username; private String username;

+ 2
- 2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java View File

final ArrayList<String> tmp = new ArrayList<String>(args.length); final ArrayList<String> tmp = new ArrayList<String>(args.length);
for (int argi = 0; argi < args.length; argi++) { for (int argi = 0; argi < args.length; argi++) {
final String str = args[argi]; final String str = args[argi];
if (str.equals("--")) {
if (str.equals("--")) { //$NON-NLS-1$
while (argi < args.length) while (argi < args.length)
tmp.add(args[argi++]); tmp.add(args[argi++]);
break; break;
} }


if (str.startsWith("--")) {
if (str.startsWith("--")) { //$NON-NLS-1$
final int eq = str.indexOf('='); final int eq = str.indexOf('=');
if (eq > 0) { if (eq > 0) {
tmp.add(str.substring(0, eq)); tmp.add(str.substring(0, eq));

+ 2
- 2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java View File

String name = params.getParameter(0); String name = params.getParameter(0);


boolean interesting = true; boolean interesting = true;
if (name.startsWith("^")) {
if (name.startsWith("^")) { //$NON-NLS-1$
name = name.substring(1); name = name.substring(1);
interesting = false; interesting = false;
} }


final int dot2 = name.indexOf("..");
final int dot2 = name.indexOf(".."); //$NON-NLS-1$
if (dot2 != -1) { if (dot2 != -1) {
if (!option.isMultiValued()) if (!option.isMultiValued())
throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn

+ 1
- 1
org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AWTPlotRenderer.java View File

g.setBackground(new Color(colorComponents[0],colorComponents[1],colorComponents[2])); g.setBackground(new Color(colorComponents[0],colorComponents[1],colorComponents[2]));
} }
if (txt.length() > 12) 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(); final int texth = g.getFontMetrics().getHeight();
int textw = g.getFontMetrics().stringWidth(txt); int textw = g.getFontMetrics().stringWidth(txt);

+ 3
- 3
org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AwtAuthenticator.java View File



final StringBuilder instruction = new StringBuilder(); final StringBuilder instruction = new StringBuilder();
instruction.append(UIText.get().enterUsernameAndPasswordFor); instruction.append(UIText.get().enterUsernameAndPasswordFor);
instruction.append(" ");
instruction.append(" "); //$NON-NLS-1$
if (getRequestorType() == RequestorType.PROXY) { if (getRequestorType() == RequestorType.PROXY) {
instruction.append(getRequestorType()); instruction.append(getRequestorType());
instruction.append(" ");
instruction.append(" "); //$NON-NLS-1$
instruction.append(getRequestingHost()); instruction.append(getRequestingHost());
if (getRequestingPort() > 0) { if (getRequestingPort() > 0) {
instruction.append(":");
instruction.append(":"); //$NON-NLS-1$
instruction.append(getRequestingPort()); instruction.append(getRequestingPort());
} }
} else { } else {

+ 7
- 6
org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java View File

int h = 0; int h = 0;
for (int i = 0; i<getColumnCount(); ++i) { for (int i = 0; i<getColumnCount(); ++i) {
TableCellRenderer renderer = getDefaultRenderer(getColumnClass(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); h = Math.max(h, c.getPreferredSize().height);
} }
setRowHeight(h + getRowMargin()); setRowHeight(h + getRowMargin());
final TableColumn author = cols.getColumn(1); final TableColumn author = cols.getColumn(1);
final TableColumn date = cols.getColumn(2); final TableColumn date = cols.getColumn(2);


graph.setHeaderValue("");
graph.setHeaderValue(""); //$NON-NLS-1$
author.setHeaderValue(UIText.get().author); author.setHeaderValue(UIText.get().author);
date.setHeaderValue(UIText.get().date); date.setHeaderValue(UIText.get().date);




final String valueStr; final String valueStr;
if (pi != null) if (pi != null)
valueStr = pi.getName() + " <" + pi.getEmailAddress() + ">";
valueStr = pi.getName() + " <" + pi.getEmailAddress() + ">"; //$NON-NLS-1$ //$NON-NLS-2$
else else
valueStr = "";
valueStr = ""; //$NON-NLS-1$
return super.getTableCellRendererComponent(table, valueStr, return super.getTableCellRendererComponent(table, valueStr,
isSelected, hasFocus, row, column); isSelected, hasFocus, row, column);
} }
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;


private final DateFormat fmt = new SimpleDateFormat( 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, public Component getTableCellRendererComponent(final JTable table,
final Object value, final boolean isSelected, final Object value, final boolean isSelected,
if (pi != null) if (pi != null)
valueStr = fmt.format(pi.getWhen()); valueStr = fmt.format(pi.getWhen());
else else
valueStr = "";
valueStr = ""; //$NON-NLS-1$
return super.getTableCellRendererComponent(table, valueStr, return super.getTableCellRendererComponent(table, valueStr,
isSelected, hasFocus, row, column); isSelected, hasFocus, row, column);
} }

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java View File

checkCallable(); checkCallable();
DirCache dc = null; DirCache dc = null;
boolean addAll = false; boolean addAll = false;
if (filepatterns.contains("."))
if (filepatterns.contains(".")) //$NON-NLS-1$
addAll = true; addAll = true;


ObjectInserter inserter = repo.newObjectInserter(); ObjectInserter inserter = repo.newObjectInserter();

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java View File

} }
} }
if (!isNoNewlineAtEndOfFile(fh)) if (!isNoNewlineAtEndOfFile(fh))
newLines.add("");
newLines.add(""); //$NON-NLS-1$
if (!rt.isMissingNewlineAtEnd()) if (!rt.isMissingNewlineAtEnd())
oldLines.add("");
oldLines.add(""); //$NON-NLS-1$
if (!isChanged(oldLines, newLines)) if (!isChanged(oldLines, newLines))
return; // don't touch the file return; // don't touch the file
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
final String eol = rt.size() == 0 final String eol = rt.size() == 0
|| (rt.size() == 1 && rt.isMissingNewlineAtEnd()) ? "\n" : rt
|| (rt.size() == 1 && rt.isMissingNewlineAtEnd()) ? "\n" : rt //$NON-NLS-1$
.getLineDelimiter(); .getLineDelimiter();
for (String l : newLines) { for (String l : newLines) {
sb.append(l); sb.append(l);

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java View File



Ref headRef = repo.getRef(Constants.HEAD); Ref headRef = repo.getRef(Constants.HEAD);
String shortHeadRef = getShortBranchName(headRef); String shortHeadRef = getShortBranchName(headRef);
String refLogMessage = "checkout: moving from " + shortHeadRef;
String refLogMessage = "checkout: moving from " + shortHeadRef; //$NON-NLS-1$
ObjectId branch = repo.resolve(name); ObjectId branch = repo.resolve(name);
if (branch == null) if (branch == null)
throw new RefNotFoundException(MessageFormat.format(JGitText throw new RefNotFoundException(MessageFormat.format(JGitText
String toName = Repository.shortenRefName(name); String toName = Repository.shortenRefName(name);
RefUpdate refUpdate = repo.updateRef(Constants.HEAD, ref == null); RefUpdate refUpdate = repo.updateRef(Constants.HEAD, ref == null);
refUpdate.setForceUpdate(force); refUpdate.setForceUpdate(force);
refUpdate.setRefLogMessage(refLogMessage + " to " + toName, false);
refUpdate.setRefLogMessage(refLogMessage + " to " + toName, false); //$NON-NLS-1$
Result updateResult; Result updateResult;
if (ref != null) if (ref != null)
updateResult = refUpdate.link(ref.getName()); updateResult = refUpdate.link(ref.getName());
&& (name == null || !Repository && (name == null || !Repository
.isValidRefName(Constants.R_HEADS + name))) .isValidRefName(Constants.R_HEADS + name)))
throw new InvalidRefNameException(MessageFormat.format(JGitText throw new InvalidRefNameException(MessageFormat.format(JGitText
.get().branchNameInvalid, name == null ? "<null>" : name));
.get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$
} }


/** /**

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java View File



String ourName = calculateOurName(headRef); String ourName = calculateOurName(headRef);
String cherryPickName = srcCommit.getId().abbreviate(7).name() String cherryPickName = srcCommit.getId().abbreviate(7).name()
+ " " + srcCommit.getShortMessage();
+ " " + srcCommit.getShortMessage(); //$NON-NLS-1$


ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE
.newMerger(repo); .newMerger(repo);
newHead = new Git(getRepository()).commit() newHead = new Git(getRepository()).commit()
.setMessage(srcCommit.getFullMessage()) .setMessage(srcCommit.getFullMessage())
.setReflogComment( .setReflogComment(
"cherry-pick: "
"cherry-pick: " //$NON-NLS-1$
+ srcCommit.getShortMessage()) + srcCommit.getShortMessage())
.setAuthor(srcCommit.getAuthorIdent()).call(); .setAuthor(srcCommit.getAuthorIdent()).call();
cherryPickedRefs.add(src); cherryPickedRefs.add(src);

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java View File

if (!dryRun) if (!dryRun)
FileUtils.delete(new File(repo.getWorkTree(), dir), FileUtils.delete(new File(repo.getWorkTree(), dir),
FileUtils.RECURSIVE); FileUtils.RECURSIVE);
files.add(dir + "/");
files.add(dir + "/"); //$NON-NLS-1$
} }
} catch (IOException e) { } catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e); throw new JGitInternalException(e.getMessage(), e);

+ 2
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java View File

+ config.getName(); + config.getName();
RefSpec refSpec = new RefSpec(); RefSpec refSpec = new RefSpec();
refSpec = refSpec.setForceUpdate(true); 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.addFetchRefSpec(refSpec);
config.update(clonedRepo.getConfig()); config.update(clonedRepo.getConfig());

+ 12
- 12
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java View File

Git git = new Git(repo); Git git = new Git(repo);
try { try {
git.add() git.add()
.addFilepattern(".")
.addFilepattern(".") //$NON-NLS-1$
.setUpdate(true).call(); .setUpdate(true).call();
} catch (NoFilepatternException e) { } catch (NoFilepatternException e) {
// should really not happen // should really not happen
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);


// determine the current HEAD and the commit it is referring to // 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) if (headId == null && amend)
throw new WrongRepositoryStateException( throw new WrongRepositoryStateException(
JGitText.get().commitAmendOnInitialNotPossible); JGitText.get().commitAmendOnInitialNotPossible);
if (reflogComment != null) { if (reflogComment != null) {
ru.setRefLogMessage(reflogComment, false); ru.setRefLogMessage(reflogComment, false);
} else { } else {
String prefix = amend ? "commit (amend): "
String prefix = amend ? "commit (amend): " //$NON-NLS-1$
: "commit: "; : "commit: ";
ru.setRefLogMessage( ru.setRefLogMessage(
prefix + revCommit.getShortMessage(), false); prefix + revCommit.getShortMessage(), false);
author, committer, message); author, committer, message);
message = ChangeIdUtil.insertId(message, changeId); message = ChangeIdUtil.insertId(message, changeId);
if (changeId != null) 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) private DirCache createTemporaryIndex(ObjectId headId, DirCache index)
while (true) { while (true) {
if (p.equals(o)) if (p.equals(o))
return i; return i;
int l = p.lastIndexOf("/");
int l = p.lastIndexOf("/"); //$NON-NLS-1$
if (l < 1) if (l < 1)
break; break;
p = p.substring(0, l); p = p.substring(0, l);
checkCallable(); checkCallable();
if (!only.isEmpty()) if (!only.isEmpty())
throw new JGitInternalException(MessageFormat.format( throw new JGitInternalException(MessageFormat.format(
JGitText.get().illegalCombinationOfArguments, "--all",
"--only"));
JGitText.get().illegalCombinationOfArguments, "--all", //$NON-NLS-1$
"--only")); //$NON-NLS-1$
this.all = all; this.all = all;
return this; return this;
} }
checkCallable(); checkCallable();
if (all) if (all)
throw new JGitInternalException(MessageFormat.format( 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; : only;
// ignore duplicates // ignore duplicates
if (!this.only.contains(o)) if (!this.only.contains(o))

+ 13
- 13
org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java View File

// determine whether we are based on a commit, // determine whether we are based on a commit,
// a branch, or a tag and compose the reflog message // a branch, or a tag and compose the reflog message
String refLogMessage; String refLogMessage;
String baseBranch = "";
String baseBranch = ""; //$NON-NLS-1$
if (startPointFullName == null) { if (startPointFullName == null) {
String baseCommit; String baseCommit;
if (startCommit != null) if (startCommit != null)
baseCommit = commit.getShortMessage(); baseCommit = commit.getShortMessage();
} }
if (exists) if (exists)
refLogMessage = "branch: Reset start-point to commit "
refLogMessage = "branch: Reset start-point to commit " //$NON-NLS-1$
+ baseCommit; + baseCommit;
else else
refLogMessage = "branch: Created from commit " + baseCommit;
refLogMessage = "branch: Created from commit " + baseCommit; //$NON-NLS-1$


} else if (startPointFullName.startsWith(Constants.R_HEADS) } else if (startPointFullName.startsWith(Constants.R_HEADS)
|| startPointFullName.startsWith(Constants.R_REMOTES)) { || startPointFullName.startsWith(Constants.R_REMOTES)) {
baseBranch = startPointFullName; baseBranch = startPointFullName;
if (exists) if (exists)
refLogMessage = "branch: Reset start-point to branch "
refLogMessage = "branch: Reset start-point to branch " //$NON-NLS-1$
+ startPointFullName; // TODO + startPointFullName; // TODO
else else
refLogMessage = "branch: Created from branch " + baseBranch;
refLogMessage = "branch: Created from branch " + baseBranch; //$NON-NLS-1$
} else { } else {
startAt = revWalk.peel(revWalk.parseAny(startAt)); startAt = revWalk.peel(revWalk.parseAny(startAt));
if (exists) if (exists)
refLogMessage = "branch: Reset start-point to tag "
refLogMessage = "branch: Reset start-point to tag " //$NON-NLS-1$
+ startPointFullName; + startPointFullName;
else else
refLogMessage = "branch: Created from tag "
refLogMessage = "branch: Created from tag " //$NON-NLS-1$
+ startPointFullName; + startPointFullName;
} }


String autosetupflag = repo.getConfig().getString( String autosetupflag = repo.getConfig().getString(
ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_BRANCH_SECTION, null,
ConfigConstants.CONFIG_KEY_AUTOSETUPMERGE); ConfigConstants.CONFIG_KEY_AUTOSETUPMERGE);
if ("false".equals(autosetupflag)) {
if ("false".equals(autosetupflag)) { //$NON-NLS-1$
doConfigure = false; doConfigure = false;
} else if ("always".equals(autosetupflag)) {
} else if ("always".equals(autosetupflag)) { //$NON-NLS-1$
doConfigure = true; doConfigure = true;
} else { } else {
// in this case, the default is to configure // in this case, the default is to configure


if (doConfigure) { if (doConfigure) {
StoredConfig config = repo.getConfig(); 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) { if (isRemote) {
// refs/remotes/<remote name>/<branch> // refs/remotes/<remote name>/<branch>
String remoteName = tokens[2]; String remoteName = tokens[2];
} else { } else {
// set "." as remote // set "." as remote
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, 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, config.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
name, ConfigConstants.CONFIG_KEY_MERGE, baseBranch); name, ConfigConstants.CONFIG_KEY_MERGE, baseBranch);
} }
if (name == null if (name == null
|| !Repository.isValidRefName(Constants.R_HEADS + name)) || !Repository.isValidRefName(Constants.R_HEADS + name))
throw new InvalidRefNameException(MessageFormat.format(JGitText throw new InvalidRefNameException(MessageFormat.format(JGitText
.get().branchNameInvalid, name == null ? "<null>" : name));
.get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$
} }


/** /**

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteBranchCommand.java View File

JGitText.get().cannotDeleteCheckedOutBranch, JGitText.get().cannotDeleteCheckedOutBranch,
branchName)); branchName));
RefUpdate update = repo.updateRef(fullName); RefUpdate update = repo.updateRef(fullName);
update.setRefLogMessage("branch deleted", false);
update.setRefLogMessage("branch deleted", false); //$NON-NLS-1$
update.setForceUpdate(true); update.setForceUpdate(true);
Result deleteResult = update.delete(); Result deleteResult = update.delete();



+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java View File

try { try {
if (cached) { if (cached) {
if (oldTree == null) { if (oldTree == null) {
ObjectId head = repo.resolve(HEAD + "^{tree}");
ObjectId head = repo.resolve(HEAD + "^{tree}"); //$NON-NLS-1$
if (head == null) if (head == null)
throw new NoHeadException(JGitText.get().cannotReadTree); throw new NoHeadException(JGitText.get().cannotReadTree);
CanonicalTreeParser p = new CanonicalTreeParser(); CanonicalTreeParser p = new CanonicalTreeParser();

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java View File

d = new File(d, Constants.DOT_GIT); d = new File(d, Constants.DOT_GIT);
builder.setGitDir(d); builder.setGitDir(d);
} else if (builder.getGitDir() == null) { } else if (builder.getGitDir() == null) {
File d = new File(".");
File d = new File("."); //$NON-NLS-1$
if (d.getParentFile() != null) if (d.getParentFile() != null)
d = d.getParentFile(); d = d.getParentFile();
if (!bare) if (!bare)

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java View File

Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1); Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);
if (tags) if (tags)
refSpecs.add(new RefSpec( refSpecs.add(new RefSpec(
"refs/tags/*:refs/remotes/origin/tags/*"));
"refs/tags/*:refs/remotes/origin/tags/*")); //$NON-NLS-1$
if (heads) 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; Collection<Ref> refs;
Map<String, Ref> refmap = new HashMap<String, Ref>(); Map<String, Ref> refmap = new HashMap<String, Ref>();
fc = transport.openFetch(); fc = transport.openFetch();

+ 7
- 7
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java View File

if (head == null) if (head == null)
throw new NoHeadException( throw new NoHeadException(
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
StringBuilder refLogMessage = new StringBuilder("merge ");
StringBuilder refLogMessage = new StringBuilder("merge "); //$NON-NLS-1$


// Check for FAST_FORWARD, ALREADY_UP_TO_DATE // Check for FAST_FORWARD, ALREADY_UP_TO_DATE
revWalk = new RevWalk(repo); revWalk = new RevWalk(repo);
.updateRef(head.getTarget().getName()); .updateRef(head.getTarget().getName());
refUpdate.setNewObjectId(objectId); refUpdate.setNewObjectId(objectId);
refUpdate.setExpectedOldObjectId(null); refUpdate.setExpectedOldObjectId(null);
refUpdate.setRefLogMessage("initial pull", false);
refUpdate.setRefLogMessage("initial pull", false); //$NON-NLS-1$
if (refUpdate.update() != Result.NEW) if (refUpdate.update() != Result.NEW)
throw new NoHeadException( throw new NoHeadException(
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
&& fastForwardMode == FastForwardMode.FF) { && fastForwardMode == FastForwardMode.FF) {
// FAST_FORWARD detected: skip doing a real merge but only // FAST_FORWARD detected: skip doing a real merge but only
// update HEAD // update HEAD
refLogMessage.append(": " + MergeStatus.FAST_FORWARD);
refLogMessage.append(": " + MergeStatus.FAST_FORWARD); //$NON-NLS-1$
dco = new DirCacheCheckout(repo, dco = new DirCacheCheckout(repo,
headCommit.getTree(), repo.lockDirCache(), headCommit.getTree(), repo.lockDirCache(),
srcCommit.getTree()); srcCommit.getTree());
new ObjectId[] { headCommit, srcCommit }, new ObjectId[] { headCommit, srcCommit },
MergeStatus.ABORTED, mergeStrategy, null, null); MergeStatus.ABORTED, mergeStrategy, null, null);
} }
String mergeMessage = "";
String mergeMessage = ""; //$NON-NLS-1$
if (!squash) { if (!squash) {
mergeMessage = new MergeMessageFormatter().format( mergeMessage = new MergeMessageFormatter().format(
commits, head); commits, head);
if (merger instanceof ResolveMerger) { if (merger instanceof ResolveMerger) {
ResolveMerger resolveMerger = (ResolveMerger) merger; ResolveMerger resolveMerger = (ResolveMerger) merger;
resolveMerger.setCommitNames(new String[] { resolveMerger.setCommitNames(new String[] {
"BASE", "HEAD", ref.getName() });
"BASE", "HEAD", ref.getName() }); //$NON-NLS-1$
resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo)); resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
noProblems = merger.merge(headCommit, srcCommit); noProblems = merger.merge(headCommit, srcCommit);
lowLevelResults = resolveMerger lowLevelResults = resolveMerger
unmergedPaths = resolveMerger.getUnmergedPaths(); unmergedPaths = resolveMerger.getUnmergedPaths();
} else } else
noProblems = merger.merge(headCommit, srcCommit); noProblems = merger.merge(headCommit, srcCommit);
refLogMessage.append(": Merge made by ");
refLogMessage.append(": Merge made by "); //$NON-NLS-1$
if (!revWalk.isMergedInto(headCommit, srcCommit)) if (!revWalk.isMergedInto(headCommit, srcCommit))
refLogMessage.append(mergeStrategy.getName()); refLogMessage.append(mergeStrategy.getName());
else else
refLogMessage.append("recursive");
refLogMessage.append("recursive"); //$NON-NLS-1$
refLogMessage.append('.'); refLogMessage.append('.');
if (noProblems) { if (noProblems) {
dco = new DirCacheCheckout(repo, dco = new DirCacheCheckout(repo,

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java View File

return base; return base;
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
boolean first = true; boolean first = true;

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java View File

*/ */
public class PullCommand extends TransportCommand<PullCommand, PullResult> { 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; private ProgressMonitor monitor = NullProgressMonitor.INSTANCE;


JGitText.get().missingConfigurationForKey, missingKey)); JGitText.get().missingConfigurationForKey, missingKey));
} }


final boolean isRemote = !remote.equals(".");
final boolean isRemote = !remote.equals("."); //$NON-NLS-1$
String remoteUri; String remoteUri;
FetchResult fetchRes; FetchResult fetchRes;
if (isRemote) { if (isRemote) {

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/api/PullResult.java View File

return true; return true;
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

+ 42
- 38
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java View File

/** /**
* The name of the "rebase-merge" folder * 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 * 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 * The available operations
for (Step step : steps) { for (Step step : steps) {
sb.setLength(0); sb.setLength(0);
sb.append(step.action.token); sb.append(step.action.token);
sb.append(" ");
sb.append(" "); //$NON-NLS-1$
sb.append(step.commit.name()); sb.append(step.commit.name());
sb.append(" ");
sb.append(" "); //$NON-NLS-1$
sb.append(RawParseUtils.decode(step.shortMessage) sb.append(RawParseUtils.decode(step.shortMessage)
.trim()); .trim());
fw.write(sb.toString()); fw.write(sb.toString());
} }


private RevCommit checkoutCurrentHead() throws IOException, NoHeadException { 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) if (headTree == null)
throw new NoHeadException( throw new NoHeadException(
JGitText.get().cannotRebaseWithoutCurrentHead); JGitText.get().cannotRebaseWithoutCurrentHead);
treeWalk.reset(); treeWalk.reset();
treeWalk.setRecursive(true); treeWalk.setRecursive(true);
treeWalk.addTree(new DirCacheIterator(dc)); 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) if (id == null)
throw new NoHeadException( throw new NoHeadException(
JGitText.get().cannotRebaseWithoutCurrentHead); JGitText.get().cannotRebaseWithoutCurrentHead);
String toAuthorScript(PersonIdent author) { String toAuthorScript(PersonIdent author) {
StringBuilder sb = new StringBuilder(100); StringBuilder sb = new StringBuilder(100);
sb.append(GIT_AUTHOR_NAME); sb.append(GIT_AUTHOR_NAME);
sb.append("='");
sb.append("='"); //$NON-NLS-1$
sb.append(author.getName()); sb.append(author.getName());
sb.append("'\n");
sb.append("'\n"); //$NON-NLS-1$
sb.append(GIT_AUTHOR_EMAIL); sb.append(GIT_AUTHOR_EMAIL);
sb.append("='");
sb.append("='"); //$NON-NLS-1$
sb.append(author.getEmailAddress()); sb.append(author.getEmailAddress());
sb.append("'\n");
sb.append("'\n"); //$NON-NLS-1$
// the command line uses the "external String" // the command line uses the "external String"
// representation for date and timezone // representation for date and timezone
sb.append(GIT_AUTHOR_DATE); 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(); String externalString = author.toExternalString();
sb sb
.append(externalString.substring(externalString .append(externalString.substring(externalString
.lastIndexOf('>') + 2)); .lastIndexOf('>') + 2));
sb.append("'\n");
sb.append("'\n"); //$NON-NLS-1$
return sb.toString(); return sb.toString();
} }


createFile(rebaseDir, HEAD_NAME, headName); createFile(rebaseDir, HEAD_NAME, headName);
createFile(rebaseDir, ONTO, upstreamCommit.name()); createFile(rebaseDir, ONTO, upstreamCommit.name());
createFile(rebaseDir, ONTO_NAME, upstreamCommitName); createFile(rebaseDir, ONTO_NAME, upstreamCommitName);
createFile(rebaseDir, INTERACTIVE, "");
createFile(rebaseDir, INTERACTIVE, ""); //$NON-NLS-1$
BufferedWriter fw = new BufferedWriter(new OutputStreamWriter( BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(new File(rebaseDir, GIT_REBASE_TODO)), new FileOutputStream(new File(rebaseDir, GIT_REBASE_TODO)),
Constants.CHARACTER_ENCODING)); Constants.CHARACTER_ENCODING));
for (RevCommit commit : cherryPickList) { for (RevCommit commit : cherryPickList) {
sb.setLength(0); sb.setLength(0);
sb.append(Action.PICK.toToken()); sb.append(Action.PICK.toToken());
sb.append(" ");
sb.append(" "); //$NON-NLS-1$
sb.append(reader.abbreviate(commit).name()); sb.append(reader.abbreviate(commit).name());
sb.append(" ");
sb.append(" "); //$NON-NLS-1$
sb.append(commit.getShortMessage()); sb.append(commit.getShortMessage());
fw.write(sb.toString()); fw.write(sb.toString());
fw.newLine(); fw.newLine();
RefUpdate rup = repo.updateRef(headName); RefUpdate rup = repo.updateRef(headName);
rup.setExpectedOldObjectId(oldCommit); rup.setExpectedOldObjectId(oldCommit);
rup.setNewObjectId(newCommit); 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); Result res = rup.update(walk);
switch (res) { switch (res) {
case FAST_FORWARD: case FAST_FORWARD:
case FORCED: case FORCED:
break; break;
default: default:
throw new IOException("Could not fast-forward");
throw new IOException("Could not fast-forward"); //$NON-NLS-1$
} }
} }
return newCommit; return newCommit;
*/ */
public static enum Action { public static enum Action {
/** Use commit */ /** Use commit */
PICK("pick", "p"),
PICK("pick", "p"), //$NON-NLS-1$ //$NON-NLS-2$
/** Use commit, but edit the commit message */ /** 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 */ /** 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; private final String token;


return this.token; return this.token;
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
return "Action[" + token + "]"; return "Action[" + token + "]";
return shortMessage; return shortMessage;
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
return "Step[" + action + ", "
return "Step["
+ action
+ ", "
+ ((commit == null) ? "null" : commit) + ((commit == null) ? "null" : commit)
+ ", " + ", "
+ ((shortMessage == null) ? "null" : new String( + ((shortMessage == null) ? "null" : new String(


// the time is saved as <seconds since 1970> <timezone offset> // the time is saved as <seconds since 1970> <timezone offset>
int timeStart = 0; int timeStart = 0;
if (time.startsWith("@"))
if (time.startsWith("@")) //$NON-NLS-1$
timeStart = 1; timeStart = 1;
else else
timeStart = 0; timeStart = 0;

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java View File



if (newName == null) if (newName == null)
throw new InvalidRefNameException(MessageFormat.format(JGitText throw new InvalidRefNameException(MessageFormat.format(JGitText
.get().branchNameInvalid, "<null>"));
.get().branchNameInvalid, "<null>")); //$NON-NLS-1$


try { try {
String fullOldName; String fullOldName;

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java View File

// resolve the ref to a commit // resolve the ref to a commit
final ObjectId commitId; final ObjectId commitId;
try { try {
commitId = repo.resolve(ref + "^{commit}");
commitId = repo.resolve(ref + "^{commit}"); //$NON-NLS-1$
if (commitId == null) { if (commitId == null) {
// @TODO throw an InvalidRefNameException. We can't do that // @TODO throw an InvalidRefNameException. We can't do that
// now because this would break the API // now because this would break the API
if (!filepaths.isEmpty()) if (!filepaths.isEmpty())
throw new JGitInternalException(MessageFormat.format( throw new JGitInternalException(MessageFormat.format(
JGitText.get().illegalCombinationOfArguments, JGitText.get().illegalCombinationOfArguments,
"[--mixed | --soft | --hard]", "<paths>..."));
"[--mixed | --soft | --hard]", "<paths>...")); //$NON-NLS-1$
this.mode = mode; this.mode = mode;
return this; return this;
} }
if (mode != null) if (mode != null)
throw new JGitInternalException(MessageFormat.format( throw new JGitInternalException(MessageFormat.format(
JGitText.get().illegalCombinationOfArguments, "<paths>...", JGitText.get().illegalCombinationOfArguments, "<paths>...",
"[--mixed | --soft | --hard]"));
"[--mixed | --soft | --hard]")); //$NON-NLS-1$
filepaths.add(file); filepaths.add(file);
return this; return this;
} }

+ 5
- 5
org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java View File

merger.getResultTreeId()); merger.getResultTreeId());
dco.setFailOnConflict(true); dco.setFailOnConflict(true);
dco.checkout(); 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() newHead = new Git(getRepository()).commit()
.setMessage(newMessage) .setMessage(newMessage)
.setReflogComment("revert: " + shortMessage).call();
.setReflogComment("revert: " + shortMessage).call(); //$NON-NLS-1$
revertedRefs.add(src); revertedRefs.add(src);
} else { } else {
unmergedPaths = merger.getUnmergedPaths(); unmergedPaths = merger.getUnmergedPaths();

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java View File

*/ */
public class StashApplyCommand extends GitCommand<ObjectId> { 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 * Stash diff filter that looks for differences in the first three trees


@Override @Override
public String toString() { public String toString() {
return "STASH_DIFF";
return "STASH_DIFF"; //$NON-NLS-1$
} }
} }


private ObjectId getHeadTree() throws GitAPIException { private ObjectId getHeadTree() throws GitAPIException {
final ObjectId headTree; final ObjectId headTree;
try { try {
headTree = repo.resolve(Constants.HEAD + "^{tree}");
headTree = repo.resolve(Constants.HEAD + "^{tree}"); //$NON-NLS-1$
} catch (IOException e) { } catch (IOException e) {
throw new JGitInternalException(JGitText.get().cannotReadTree, e); throw new JGitInternalException(JGitText.get().cannotReadTree, e);
} }

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java View File



// if no id is set, we should attempt to use HEAD // if no id is set, we should attempt to use HEAD
if (id == null) { if (id == null) {
ObjectId objectId = repo.resolve(Constants.HEAD + "^{commit}");
ObjectId objectId = repo.resolve(Constants.HEAD + "^{commit}"); //$NON-NLS-1$
if (objectId == null) if (objectId == null)
throw new NoHeadException( throw new NoHeadException(
JGitText.get().tagOnRepoWithoutHEADCurrentlyNotSupported); JGitText.get().tagOnRepoWithoutHEADCurrentlyNotSupported);
RefUpdate tagRef = repo.updateRef(refName); RefUpdate tagRef = repo.updateRef(refName);
tagRef.setNewObjectId(tagId); tagRef.setNewObjectId(tagId);
tagRef.setForceUpdate(forceUpdate); tagRef.setForceUpdate(forceUpdate);
tagRef.setRefLogMessage("tagged " + name, false);
tagRef.setRefLogMessage("tagged " + name, false); //$NON-NLS-1$
Result updateResult = tagRef.update(revWalk); Result updateResult = tagRef.update(revWalk);
switch (updateResult) { switch (updateResult) {
case NEW: case NEW:

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/api/errors/ConcurrentRefUpdateException.java View File

*/ */
public ConcurrentRefUpdateException(String message, Ref ref, public ConcurrentRefUpdateException(String message, Ref ref,
RefUpdate.Result rc, Throwable cause) { 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); + MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc), cause);
this.rc = rc; this.rc = rc;
this.ref = ref; this.ref = ref;
*/ */
public ConcurrentRefUpdateException(String message, Ref ref, public ConcurrentRefUpdateException(String message, Ref ref,
RefUpdate.Result rc) { RefUpdate.Result rc) {
super((rc == null) ? message : message + ". "
super((rc == null) ? message : message + ". " //$NON-NLS-1$
+ MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc)); + MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc));
this.rc = rc; this.rc = rc;
this.ref = ref; this.ref = ref;

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java View File

revPool = new RevWalk(getRepository()); revPool = new RevWalk(getRepository());


revPool.setRetainBody(true); revPool.setRetainBody(true);
SEEN = revPool.newFlag("SEEN");
SEEN = revPool.newFlag("SEEN"); //$NON-NLS-1$
reader = revPool.getObjectReader(); reader = revPool.getObjectReader();
treeWalk = new TreeWalk(reader); treeWalk = new TreeWalk(reader);
treeWalk.setRecursive(true); treeWalk.setRecursive(true);

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameResult.java View File

@Override @Override
public String toString() { public String toString() {
StringBuilder r = new StringBuilder(); StringBuilder r = new StringBuilder();
r.append("BlameResult: ");
r.append("BlameResult: "); //$NON-NLS-1$
r.append(getResultPath()); r.append(getResultPath());
return r.toString(); return r.toString();
} }

+ 3
- 2
org.eclipse.jgit/src/org/eclipse/jgit/blame/Candidate.java View File

return r; return r;
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
StringBuilder r = new StringBuilder(); StringBuilder r = new StringBuilder();


@Override @Override
public String toString() { public String toString() {
return "Reverse" + super.toString();
return "Reverse" + super.toString(); //$NON-NLS-1$
} }
} }




@Override @Override
PersonIdent getAuthor() { PersonIdent getAuthor() {
return new PersonIdent(description, "");
return new PersonIdent(description, ""); //$NON-NLS-1$
} }
} }
} }

+ 8
- 8
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java View File

private final int renameLimit; private final int renameLimit;


private DiffConfig(final Config rc) { 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. */ /** @return true if the prefix "a/" and "b/" should be suppressed. */
final String renameString) { final String renameString) {
if (renameString == null) if (renameString == null)
return RenameDetectionType.FALSE; 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; return RenameDetectionType.COPY;
else { else {
final Boolean renameBoolean = StringUtils final Boolean renameBoolean = StringUtils
.toBooleanOrNull(renameString); .toBooleanOrNull(renameString);
if (renameBoolean == null) if (renameBoolean == null)
throw new IllegalArgumentException(MessageFormat.format( 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()) else if (renameBoolean.booleanValue())
return RenameDetectionType.TRUE; return RenameDetectionType.TRUE;
else else

+ 2
- 1
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java View File

.fromObjectId(ObjectId.zeroId()); .fromObjectId(ObjectId.zeroId());


/** Magical file name used for file adds or deletes. */ /** 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. */ /** General type of change a single file-level patch describes. */
public static enum ChangeType { public static enum ChangeType {
return side == Side.OLD ? getOldId() : getNewId(); return side == Side.OLD ? getOldId() : getNewId();
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();

+ 28
- 28
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java View File

public class DiffFormatter { public class DiffFormatter {
private static final int DEFAULT_BINARY_FILE_THRESHOLD = PackConfig.DEFAULT_BIG_FILE_THRESHOLD; 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. */ /** Magic return content indicating it is empty or no content present. */
private static final byte[] EMPTY = new byte[] {}; private static final byte[] EMPTY = new byte[] {};


private int binaryFileThreshold = DEFAULT_BINARY_FILE_THRESHOLD; 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; private TreeFilter pathFilter = TreeFilter.ALL;




DiffConfig dc = db.getConfig().get(DiffConfig.KEY); DiffConfig dc = db.getConfig().get(DiffConfig.KEY);
if (dc.isNoPrefix()) { if (dc.isNoPrefix()) {
setOldPrefix("");
setNewPrefix("");
setOldPrefix(""); //$NON-NLS-1$
setNewPrefix(""); //$NON-NLS-1$
} }
setDetectRenames(dc.isRenameDetectionEnabled()); setDetectRenames(dc.isRenameDetectionEnabled());


private void writeGitLinkDiffText(OutputStream o, DiffEntry ent) private void writeGitLinkDiffText(OutputStream o, DiffEntry ent)
throws IOException { throws IOException {
if (ent.getOldMode() == GITLINK) { 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) { 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 // if (aRaw == BINARY || bRaw == BINARY //
|| RawText.isBinary(aRaw) || RawText.isBinary(bRaw)) { || RawText.isBinary(aRaw) || RawText.isBinary(bRaw)) {
formatOldNewPaths(buf, ent); formatOldNewPaths(buf, ent);
buf.write(encodeASCII("Binary files differ\n"));
buf.write(encodeASCII("Binary files differ\n")); //$NON-NLS-1$
editList = new EditList(); editList = new EditList();
type = PatchType.BINARY; type = PatchType.BINARY;


final FileMode oldMode = ent.getOldMode(); final FileMode oldMode = ent.getOldMode();
final FileMode newMode = ent.getNewMode(); 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(encode(quotePath(oldPrefix + (type == ADD ? newp : oldp))));
o.write(' '); o.write(' ');
o.write(encode(quotePath(newPrefix + (type == DELETE ? oldp : newp)))); o.write(encode(quotePath(newPrefix + (type == DELETE ? oldp : newp))));


switch (type) { switch (type) {
case ADD: case ADD:
o.write(encodeASCII("new file mode "));
o.write(encodeASCII("new file mode ")); //$NON-NLS-1$
newMode.copyTo(o); newMode.copyTo(o);
o.write('\n'); o.write('\n');
break; break;


case DELETE: case DELETE:
o.write(encodeASCII("deleted file mode "));
o.write(encodeASCII("deleted file mode ")); //$NON-NLS-1$
oldMode.copyTo(o); oldMode.copyTo(o);
o.write('\n'); o.write('\n');
break; break;


case RENAME: 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('\n');


o.write(encode("rename from " + quotePath(oldp)));
o.write(encode("rename from " + quotePath(oldp))); //$NON-NLS-1$
o.write('\n'); o.write('\n');


o.write(encode("rename to " + quotePath(newp)));
o.write(encode("rename to " + quotePath(newp))); //$NON-NLS-1$
o.write('\n'); o.write('\n');
break; break;


case COPY: 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('\n');


o.write(encode("copy from " + quotePath(oldp)));
o.write(encode("copy from " + quotePath(oldp))); //$NON-NLS-1$
o.write('\n'); o.write('\n');


o.write(encode("copy to " + quotePath(newp)));
o.write(encode("copy to " + quotePath(newp))); //$NON-NLS-1$
o.write('\n'); o.write('\n');


if (!oldMode.equals(newMode)) { if (!oldMode.equals(newMode)) {
o.write(encodeASCII("new file mode "));
o.write(encodeASCII("new file mode ")); //$NON-NLS-1$
newMode.copyTo(o); newMode.copyTo(o);
o.write('\n'); o.write('\n');
} }


case MODIFY: case MODIFY:
if (0 < ent.getScore()) { 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'); o.write('\n');
} }
break; break;
} }


if ((type == MODIFY || type == RENAME) && !oldMode.equals(newMode)) { if ((type == MODIFY || type == RENAME) && !oldMode.equals(newMode)) {
o.write(encodeASCII("old mode "));
o.write(encodeASCII("old mode ")); //$NON-NLS-1$
oldMode.copyTo(o); oldMode.copyTo(o);
o.write('\n'); o.write('\n');


o.write(encodeASCII("new mode "));
o.write(encodeASCII("new mode ")); //$NON-NLS-1$
newMode.copyTo(o); newMode.copyTo(o);
o.write('\n'); o.write('\n');
} }
*/ */
protected void formatIndexLine(OutputStream o, DiffEntry ent) protected void formatIndexLine(OutputStream o, DiffEntry ent)
throws IOException { throws IOException {
o.write(encodeASCII("index " //
o.write(encodeASCII("index " // //$NON-NLS-1$
+ format(ent.getOldId()) // + format(ent.getOldId()) //
+ ".." //
+ ".." // //$NON-NLS-1$
+ format(ent.getNewId()))); + format(ent.getNewId())));
if (ent.getOldMode().equals(ent.getNewMode())) { if (ent.getOldMode().equals(ent.getNewMode())) {
o.write(' '); o.write(' ');
break; 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) { private int findCombinedEnd(final List<Edit> edits, final int i) {

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java View File

return false; return false;
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
final Type t = getType(); final Type t = getType();

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/diff/EditList.java View File



@Override @Override
public String toString() { public String toString() {
return "EditList" + super.toString();
return "EditList" + super.toString(); //$NON-NLS-1$
} }
} }

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java View File

*/ */
public String getString(int begin, int end, boolean dropLF) { public String getString(int begin, int end, boolean dropLF) {
if (begin == end) if (begin == end)
return "";
return ""; //$NON-NLS-1$


int s = getStart(begin); int s = getStart(begin);
int e = getEnd(end - 1); int e = getEnd(end - 1);
if (content[e - 1] != '\n') if (content[e - 1] != '\n')
return null; return null;
if (content.length > 1 && content[e - 2] == '\r') if (content.length > 1 && content[e - 2] == '\r')
return "\r\n";
return "\r\n"; //$NON-NLS-1$
else else
return "\n";
return "\n"; //$NON-NLS-1$
} }
} }

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java View File

} }


static int nameScore(String a, String b) { 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 dirMin = Math.min(aDirLen, bDirLen);
int dirMax = Math.max(aDirLen, bDirLen); int dirMax = Math.max(aDirLen, bDirLen);

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java View File



private static String formatExtensionName(final byte[] hdr) private static String formatExtensionName(final byte[] hdr)
throws UnsupportedEncodingException { 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) { private static boolean is_DIRC(final byte[] hdr) {
System.arraycopy(sortedEntries, 0, r, 0, sortedEntries.length); System.arraycopy(sortedEntries, 0, r, 0, sortedEntries.length);
return r; return r;
} }
if (!path.endsWith("/"))
path += "/";
if (!path.endsWith("/")) //$NON-NLS-1$
path += "/"; //$NON-NLS-1$
final byte[] p = Constants.encode(path); final byte[] p = Constants.encode(path);
final int pLen = p.length; final int pLen = p.length;



+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheBuilder.java View File



private static IllegalStateException bad(final DirCacheEntry a, private static IllegalStateException bad(final DirCacheEntry a,
final String msg) { final String msg) {
return new IllegalStateException(msg + ": " + a.getStage() + " "
return new IllegalStateException(msg + ": " + a.getStage() + " " //$NON-NLS-1$ //$NON-NLS-2$
+ a.getPathString()); + a.getPathString());
} }
} }

+ 6
- 6
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java View File

builder.finish(); builder.finish();


File file = null; File file = null;
String last = "";
String last = ""; //$NON-NLS-1$
// when deleting files process them in the opposite order as they have // when deleting files process them in the opposite order as they have
// been reported. This ensures the files are deleted before we delete // been reported. This ensures the files are deleted before we delete
// their parent folders // their parent folders
ObjectLoader ol = or.open(entry.getObjectId()); ObjectLoader ol = or.open(entry.getObjectId());
File parentDir = f.getParentFile(); File parentDir = f.getParentFile();
parentDir.mkdirs(); 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); WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY);
FileOutputStream rawChannel = new FileOutputStream(tmpFile); FileOutputStream rawChannel = new FileOutputStream(tmpFile);
OutputStream channel; OutputStream channel;


private static byte[][] forbidden; private static byte[][] forbidden;
static { 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][]; forbidden = new byte[list.length][];
for (int i = 0; i < list.length; ++i) for (int i = 0; i < list.length; ++i)
forbidden[i] = Constants.encodeASCII(list[i]); forbidden[i] = Constants.encodeASCII(list[i]);

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java View File

/** /**
* Use for debugging only ! * Use for debugging only !
*/ */
@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
return getFileMode() + " " + getLength() + " " + getLastModified() return getFileMode() + " " + getLength() + " " + getLastModified()

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/errors/CheckoutConflictException.java View File

private static String buildList(String[] files) { private static String buildList(String[] files) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (String f : files) { for (String f : files) {
builder.append("\n");
builder.append("\n"); //$NON-NLS-1$
builder.append(f); builder.append(f);
} }
return builder.toString(); return builder.toString();

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.java View File

final StringBuilder msg = new StringBuilder(); final StringBuilder msg = new StringBuilder();
msg.append(JGitText.get().failureDueToOneOfTheFollowing); msg.append(JGitText.get().failureDueToOneOfTheFollowing);
for (final Throwable c : causes) { for (final Throwable c : causes) {
msg.append(" ");
msg.append(" "); //$NON-NLS-1$
msg.append(c.getMessage()); msg.append(c.getMessage());
msg.append("\n");
msg.append("\n"); //$NON-NLS-1$
} }
return msg.toString(); return msg.toString();
} }

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java View File



private static String asAscii(byte[] bytes, int offset, int length) { private static String asAscii(byte[] bytes, int offset, int length) {
try { 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) { } catch (UnsupportedEncodingException e2) {
return "";
return ""; //$NON-NLS-1$
} catch (StringIndexOutOfBoundsException e2) { } catch (StringIndexOutOfBoundsException e2) {
return "";
return ""; //$NON-NLS-1$
} }
} }
} }

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java View File

final StringBuilder r = new StringBuilder(); final StringBuilder r = new StringBuilder();
r.append(JGitText.get().missingPrerequisiteCommits); r.append(JGitText.get().missingPrerequisiteCommits);
for (final Map.Entry<ObjectId, String> e : missingCommits.entrySet()) { for (final Map.Entry<ObjectId, String> e : missingCommits.entrySet()) {
r.append("\n ");
r.append("\n "); //$NON-NLS-1$
r.append(e.getKey().name()); r.append(e.getKey().name());
if (e.getValue() != null) if (e.getValue() != null)
r.append(" ").append(e.getValue());
r.append(" ").append(e.getValue()); //$NON-NLS-1$
} }
return r.toString(); return r.toString();
} }

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.java View File

* message * message
*/ */
public PackProtocolException(final URIish uri, final String s) { 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, public PackProtocolException(final URIish uri, final String s,
final Throwable cause) { final Throwable cause) {
this(uri + ": " + s, cause);
this(uri + ": " + s, cause); //$NON-NLS-1$
} }


/** /**

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/errors/RevisionSyntaxException.java View File



@Override @Override
public String toString() { public String toString() {
return super.toString() + ":" + revstr;
return super.toString() + ":" + revstr; //$NON-NLS-1$
} }
} }

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationBundleLoadingException.java View File

* {@link ResourceBundle#getBundle(String, Locale)} method. * {@link ResourceBundle#getBundle(String, Locale)} method.
*/ */
public TranslationBundleLoadingException(Class bundleClass, Locale locale, Exception cause) { 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); bundleClass, locale, cause);
} }
} }

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationStringMissingException.java View File

* {@link ResourceBundle#getString(String)} method. * {@link ResourceBundle#getString(String)} method.
*/ */
public TranslationStringMissingException(Class bundleClass, Locale locale, String key, Exception cause) { 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); cause);
this.key = key; this.key = key;
} }

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/errors/TransportException.java View File

* message * message
*/ */
public TransportException(final URIish uri, final String s) { 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, public TransportException(final URIish uri, final String s,
final Throwable cause) { final Throwable cause) {
this(uri.setPass(null) + ": " + s, cause);
this(uri.setPass(null) + ": " + s, cause); //$NON-NLS-1$
} }


/** /**

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/errors/UnsupportedCredentialItem.java View File

* message * message
*/ */
public UnsupportedCredentialItem(final URIish uri, final String s) { public UnsupportedCredentialItem(final URIish uri, final String s) {
super(uri.setPass(null) + ": " + s);
super(uri.setPass(null) + ": " + s); //$NON-NLS-1$
} }
} }

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/events/ListenerHandle.java View File

parent.remove(this); parent.remove(this);
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
return type.getSimpleName() + "[" + listener + "]"; return type.getSimpleName() + "[" + listener + "]";

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/events/RepositoryEvent.java View File

*/ */
public abstract void dispatch(T listener); public abstract void dispatch(T listener);


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
String type = getClass().getSimpleName(); String type = getClass().getSimpleName();

+ 5
- 5
org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java View File

static final List<Head> EMPTY_HEAD_LIST = Collections.emptyList(); static final List<Head> EMPTY_HEAD_LIST = Collections.emptyList();


private static final Pattern characterClassStartPattern = Pattern private static final Pattern characterClassStartPattern = Pattern
.compile("\\[[.:=]");
.compile("\\[[.:=]"); //$NON-NLS-1$


private List<Head> headsStartValue; private List<Head> headsStartValue;


int firstValidEndBracketIndex = indexOfStartBracket + 2; int firstValidEndBracketIndex = indexOfStartBracket + 2;


if (indexOfStartBracket + 1 >= pattern.length()) if (indexOfStartBracket + 1 >= pattern.length())
throw new NoClosingBracketException(indexOfStartBracket, "[", "]",
throw new NoClosingBracketException(indexOfStartBracket, "[", "]", //$NON-NLS-1$ //$NON-NLS-2$
pattern); pattern);


if (pattern.charAt(firstValidCharClassIndex) == '!') { if (pattern.charAt(firstValidCharClassIndex) == '!') {
final int possibleGroupEnd = pattern.indexOf(']', final int possibleGroupEnd = pattern.indexOf(']',
firstValidEndBracketIndex); firstValidEndBracketIndex);
if (possibleGroupEnd == -1) if (possibleGroupEnd == -1)
throw new NoClosingBracketException(indexOfStartBracket, "[",
"]", pattern);
throw new NoClosingBracketException(indexOfStartBracket, "[", //$NON-NLS-1$
"]", pattern); //$NON-NLS-1$


final boolean foundCharClass = charClassStartMatcher final boolean foundCharClass = charClassStartMatcher
.find(firstValidCharClassIndex); .find(firstValidCharClassIndex);
&& charClassStartMatcher.start() < possibleGroupEnd) { && charClassStartMatcher.start() < possibleGroupEnd) {


final String classStart = charClassStartMatcher.group(0); 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 classStartIndex = charClassStartMatcher.start();
final int classEndIndex = pattern.indexOf(classEnd, final int classEndIndex = pattern.indexOf(classEnd,

+ 17
- 17
org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/GroupHead.java View File

private final List<CharacterPattern> characterClasses; private final List<CharacterPattern> characterClasses;


private static final Pattern REGEX_PATTERN = Pattern private static final Pattern REGEX_PATTERN = Pattern
.compile("([^-][-][^-]|\\[[.:=].*?[.:=]\\])");
.compile("([^-][-][^-]|\\[[.:=].*?[.:=]\\])"); //$NON-NLS-1$


private final boolean inverse; private final boolean inverse;


throws InvalidPatternException { throws InvalidPatternException {
super(false); super(false);
this.characterClasses = new ArrayList<CharacterPattern>(); this.characterClasses = new ArrayList<CharacterPattern>();
this.inverse = pattern.startsWith("!");
this.inverse = pattern.startsWith("!"); //$NON-NLS-1$
if (inverse) { if (inverse) {
pattern = pattern.substring(1); pattern = pattern.substring(1);
} }
final char start = characterClass.charAt(0); final char start = characterClass.charAt(0);
final char end = characterClass.charAt(2); final char end = characterClass.charAt(2);
characterClasses.add(new CharacterRange(start, end)); 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(LetterPattern.INSTANCE);
characterClasses.add(DigitPattern.INSTANCE); characterClasses.add(DigitPattern.INSTANCE);
} else if (characterClass.equals("[:alpha:]")) {
} else if (characterClass.equals("[:alpha:]")) { //$NON-NLS-1$
characterClasses.add(LetterPattern.INSTANCE); 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(' '));
characterClasses.add(new OneCharacterPattern('\t')); 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 CharacterRange('\u0000', '\u001F'));
characterClasses.add(new OneCharacterPattern('\u007F')); characterClasses.add(new OneCharacterPattern('\u007F'));
} else if (characterClass.equals("[:digit:]")) {
} else if (characterClass.equals("[:digit:]")) { //$NON-NLS-1$
characterClasses.add(DigitPattern.INSTANCE); 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(new CharacterRange('\u0021', '\u007E'));
characterClasses.add(LetterPattern.INSTANCE); characterClasses.add(LetterPattern.INSTANCE);
characterClasses.add(DigitPattern.INSTANCE); characterClasses.add(DigitPattern.INSTANCE);
} else if (characterClass.equals("[:lower:]")) {
} else if (characterClass.equals("[:lower:]")) { //$NON-NLS-1$
characterClasses.add(LowerPattern.INSTANCE); 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(new CharacterRange('\u0020', '\u007E'));
characterClasses.add(LetterPattern.INSTANCE); characterClasses.add(LetterPattern.INSTANCE);
characterClasses.add(DigitPattern.INSTANCE); characterClasses.add(DigitPattern.INSTANCE);
} else if (characterClass.equals("[:punct:]")) {
} else if (characterClass.equals("[:punct:]")) { //$NON-NLS-1$
characterClasses.add(PunctPattern.INSTANCE); characterClasses.add(PunctPattern.INSTANCE);
} else if (characterClass.equals("[:space:]")) {
} else if (characterClass.equals("[:space:]")) { //$NON-NLS-1$
characterClasses.add(WhitespacePattern.INSTANCE); characterClasses.add(WhitespacePattern.INSTANCE);
} else if (characterClass.equals("[:upper:]")) {
} else if (characterClass.equals("[:upper:]")) { //$NON-NLS-1$
characterClasses.add(UpperPattern.INSTANCE); 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('0', '9'));
characterClasses.add(new CharacterRange('a', 'f')); characterClasses.add(new CharacterRange('a', 'f'));
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(new OneCharacterPattern('_'));
characterClasses.add(LetterPattern.INSTANCE); characterClasses.add(LetterPattern.INSTANCE);
characterClasses.add(DigitPattern.INSTANCE); characterClasses.add(DigitPattern.INSTANCE);
throw new InvalidPatternException(message, wholePattern); throw new InvalidPatternException(message, wholePattern);
} }


pattern = matcher.replaceFirst("");
pattern = matcher.replaceFirst(""); //$NON-NLS-1$
matcher.reset(pattern); matcher.reset(pattern);
} }
// pattern contains now no ranges // pattern contains now no ranges
private static final class PunctPattern implements CharacterPattern { private static final class PunctPattern implements CharacterPattern {
static final GroupHead.PunctPattern INSTANCE = new PunctPattern(); static final GroupHead.PunctPattern INSTANCE = new PunctPattern();


private static String punctCharacters = "-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~";
private static String punctCharacters = "-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~"; //$NON-NLS-1$


public boolean matches(char c) { public boolean matches(char c) {
return punctCharacters.indexOf(c) != -1; return punctCharacters.indexOf(c) != -1;

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java View File

String txt; String txt;
while ((txt = br.readLine()) != null) { while ((txt = br.readLine()) != null) {
txt = txt.trim(); txt = txt.trim();
if (txt.length() > 0 && !txt.startsWith("#"))
if (txt.length() > 0 && !txt.startsWith("#")) //$NON-NLS-1$
rules.add(new IgnoreRule(txt)); rules.add(new IgnoreRule(txt));
} }
} }

+ 12
- 12
org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreRule.java View File

private void setup() { private void setup() {
int startIndex = 0; int startIndex = 0;
int endIndex = pattern.length(); int endIndex = pattern.length();
if (pattern.startsWith("!")) {
if (pattern.startsWith("!")) { //$NON-NLS-1$
startIndex++; startIndex++;
negation = true; negation = true;
} }


if (pattern.endsWith("/")) {
if (pattern.endsWith("/")) { //$NON-NLS-1$
endIndex --; endIndex --;
dirOnly = true; dirOnly = true;
} }


pattern = pattern.substring(startIndex, endIndex); pattern = pattern.substring(startIndex, endIndex);
boolean hasSlash = pattern.contains("/");
boolean hasSlash = pattern.contains("/"); //$NON-NLS-1$


if (!hasSlash) if (!hasSlash)
nameOnly = true; nameOnly = true;
else if (!pattern.startsWith("/")) {
else if (!pattern.startsWith("/")) { //$NON-NLS-1$
//Contains "/" but does not start with one //Contains "/" but does not start with one
//Adding / to the start should not interfere with matching //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 { try {
matcher = new FileNameMatcher(pattern, Character.valueOf('/')); matcher = new FileNameMatcher(pattern, Character.valueOf('/'));
} catch (InvalidPatternException e) { } catch (InvalidPatternException e) {
* the target is ignored. Call {@link IgnoreRule#getResult() getResult()} for the result. * the target is ignored. Call {@link IgnoreRule#getResult() getResult()} for the result.
*/ */
public boolean isMatch(String target, boolean isDirectory) { 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 (matcher == null) {
if (target.equals(pattern)) { if (target.equals(pattern)) {
* "/src/new" to /src/newfile" but allows "/src/new" to match * "/src/new" to /src/newfile" but allows "/src/new" to match
* "/src/new/newfile", as is the git standard * "/src/new/newfile", as is the git standard
*/ */
if ((target).startsWith(pattern + "/"))
if ((target).startsWith(pattern + "/")) //$NON-NLS-1$
return true; return true;


if (nameOnly) { if (nameOnly) {
//Iterate through each sub-name //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++) { for (int idx = 0; idx < segments.length; idx++) {
final String segmentName = segments[idx]; final String segmentName = segments[idx];
if (segmentName.equals(pattern) && if (segmentName.equals(pattern) &&
if (matcher.isMatch()) if (matcher.isMatch())
return true; return true;


final String[] segments = target.split("/");
final String[] segments = target.split("/"); //$NON-NLS-1$
if (nameOnly) { if (nameOnly) {
for (int idx = 0; idx < segments.length; idx++) { for (int idx = 0; idx < segments.length; idx++) {
final String segmentName = segments[idx]; final String segmentName = segments[idx];
for (int idx = 0; idx < segments.length; idx++) { for (int idx = 0; idx < segments.length; idx++) {
final String segmentName = segments[idx]; final String segmentName = segments[idx];
if (segmentName.length() > 0) { if (segmentName.length() > 0) {
matcher.append("/" + segmentName);
matcher.append("/" + segmentName); //$NON-NLS-1$
} }


if (matcher.isMatch() && if (matcher.isMatch() &&

+ 2
- 1
org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java View File

return new String(b, 0, nibbles); return new String(b, 0, nibbles);
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
return "AbbreviatedObjectId[" + name() + "]";
return "AbbreviatedObjectId[" + name() + "]"; //$NON-NLS-1$
} }
} }

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java View File

dst[o--] = '0'; dst[o--] = '0';
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
return "AnyObjectId[" + name() + "]"; return "AnyObjectId[" + name() + "]";

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java View File

*/ */
public B findGitDir() { public B findGitDir() {
if (getGitDir() == null) if (getGitDir() == null)
findGitDir(new File("").getAbsoluteFile());
findGitDir(new File("").getAbsoluteFile()); //$NON-NLS-1$
return self(); return self();
} }


if (getGitDir() == null) if (getGitDir() == null)
setGitDir(getWorkTree().getParentFile()); setGitDir(getWorkTree().getParentFile());
if (getIndexFile() == null) if (getIndexFile() == null)
setIndexFile(new File(getGitDir(), "index"));
setIndexFile(new File(getGitDir(), "index")); //$NON-NLS-1$
} }
} }


*/ */
protected void setupInternals() throws IOException { protected void setupInternals() throws IOException {
if (getObjectDirectory() == null && getGitDir() != null) if (getObjectDirectory() == null && getGitDir() != null)
setObjectDirectory(safeFS().resolve(getGitDir(), "objects"));
setObjectDirectory(safeFS().resolve(getGitDir(), "objects")); //$NON-NLS-1$
} }


/** /**

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java View File

if (msg == null && !appendStatus) if (msg == null && !appendStatus)
disableRefLog(); disableRefLog();
else if (msg == null && appendStatus) { else if (msg == null && appendStatus) {
refLogMessage = "";
refLogMessage = ""; //$NON-NLS-1$
refLogIncludeResult = true; refLogIncludeResult = true;
} else { } else {
refLogMessage = msg; refLogMessage = msg;

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchingProgressMonitor.java View File



public Thread newThread(Runnable taskBody) { public Thread newThread(Runnable taskBody) {
Thread thr = baseFactory.newThread(taskBody); Thread thr = baseFactory.newThread(taskBody);
thr.setName("JGit-AlarmQueue");
thr.setName("JGit-AlarmQueue"); //$NON-NLS-1$
thr.setDaemon(true); thr.setDaemon(true);
return thr; return thr;
} }

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java View File

if (remote == null || mergeRef == null) if (remote == null || mergeRef == null)
return null; return null;


if (remote.equals("."))
if (remote.equals(".")) //$NON-NLS-1$
return mergeRef; return mergeRef;


return findRemoteTrackingBranch(remote, mergeRef); return findRemoteTrackingBranch(remote, mergeRef);

+ 6
- 5
org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java View File

public class CommitBuilder { public class CommitBuilder {
private static final ObjectId[] EMPTY_OBJECTID_LIST = new ObjectId[0]; 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; private ObjectId treeId;


return build(); return build();
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
StringBuilder r = new StringBuilder(); StringBuilder r = new StringBuilder();

+ 19
- 19
org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java View File

r.append('"'); r.append('"');
inquote = false; inquote = false;
} }
r.append("\\n\\\n");
r.append("\\n\\\n"); //$NON-NLS-1$
lineStart = r.length(); lineStart = r.length();
break; break;


case '\t': case '\t':
r.append("\\t");
r.append("\\t"); //$NON-NLS-1$
break; break;


case '\b': case '\b':
r.append("\\b");
r.append("\\b"); //$NON-NLS-1$
break; break;


case '\\': case '\\':
r.append("\\\\");
r.append("\\\\"); //$NON-NLS-1$
break; break;


case '"': case '"':
r.append("\\\"");
r.append("\\\""); //$NON-NLS-1$
break; break;


case ';': case ';':
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static <T> T[] allValuesOf(final T value) { private static <T> T[] allValuesOf(final T value) {
try { try {
return (T[]) value.getClass().getMethod("values").invoke(null);
return (T[]) value.getClass().getMethod("values").invoke(null); //$NON-NLS-1$
} catch (Exception err) { } catch (Exception err) {
String typeName = value.getClass().getName(); String typeName = value.getClass().getName();
String msg = MessageFormat.format( String msg = MessageFormat.format(
for (T e : all) { for (T e : all) {
if (StringUtils.equalsIgnoreCase(e.name(), n)) if (StringUtils.equalsIgnoreCase(e.name(), n))
return e; return e;
else if (StringUtils.equalsIgnoreCase(e.name(), "TRUE"))
else if (StringUtils.equalsIgnoreCase(e.name(), "TRUE")) //$NON-NLS-1$
trueState = e; trueState = e;
else if (StringUtils.equalsIgnoreCase(e.name(), "FALSE"))
else if (StringUtils.equalsIgnoreCase(e.name(), "FALSE")) //$NON-NLS-1$
falseState = e; falseState = e;
} }


final String s; final String s;


if (value >= GiB && (value % GiB) == 0) 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) 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) else if (value >= KiB && (value % KiB) == 0)
s = String.valueOf(value / KiB) + " k";
s = String.valueOf(value / KiB) + " k"; //$NON-NLS-1$
else else
s = String.valueOf(value); s = String.valueOf(value);


*/ */
public void setBoolean(final String section, final String subsection, public void setBoolean(final String section, final String subsection,
final String name, final boolean value) { 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(' '); out.append(' ');
String escaped = escapeValue(e.subsection); String escaped = escapeValue(e.subsection);
// make sure to avoid double quotes here // 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) if (!quoted)
out.append('"'); out.append('"');
out.append(escaped); out.append(escaped);
} }
out.append(']'); out.append(']');
} else if (e.section != null && e.name != null) { } 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('\t');
out.append(e.name); out.append(e.name);
if (MAGIC_EMPTY_VALUE != e.value) { if (MAGIC_EMPTY_VALUE != e.value) {
out.append(" =");
out.append(" ="); //$NON-NLS-1$
if (e.value != null) { if (e.value != null) {
out.append(' '); out.append(' ');
out.append(escapeValue(e.value)); out.append(escapeValue(e.value));
} else if (e.section == null && Character.isWhitespace(c)) { } else if (e.section == null && Character.isWhitespace(c)) {
// Save the leading whitespace (if any). // Save the leading whitespace (if any).
if (e.prefix == null) if (e.prefix == null)
e.prefix = "";
e.prefix = ""; //$NON-NLS-1$
e.prefix += c; e.prefix += c;


} else if ('[' == c) { } else if ('[' == c) {
} }
if (']' != input) if (']' != input)
throw new ConfigInvalidException(JGitText.get().badGroupHeader); throw new ConfigInvalidException(JGitText.get().badGroupHeader);
e.suffix = "";
e.suffix = ""; //$NON-NLS-1$


} else if (last != null) { } else if (last != null) {
// Read a value. // Read a value.
e.subsection = last.subsection; e.subsection = last.subsection;
in.reset(); in.reset();
e.name = readKeyName(in); 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.name = e.name.substring(0, e.name.length() - 1);
e.value = MAGIC_EMPTY_VALUE; e.value = MAGIC_EMPTY_VALUE;
} else } else

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java View File

* Constants for use with the Configuration classes: section names, * Constants for use with the Configuration classes: section names,
* configuration keys * configuration keys
*/ */
@SuppressWarnings("nls")
public class ConfigConstants { public class ConfigConstants {
/** The "core" section */ /** The "core" section */
public static final String CONFIG_CORE_SECTION = "core"; public static final String CONFIG_CORE_SECTION = "core";

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java View File

return a.equals(b); return a.equals(b);
} }


@SuppressWarnings("nls")
@Override @Override
public String toString() { public String toString() {
if (section == null) if (section == null)

+ 0
- 0
org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigSnapshot.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save