Skip to content

Commit 82d2d4f

Browse files
committed
use specific length for git changeset IDs
fixes #661
1 parent 6ce0623 commit 82d2d4f

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

src/org/opensolaris/opengrok/history/GitRepository.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ public class GitRepository extends Repository {
5555
/** git blame command */
5656
private static final String BLAME = "blame";
5757

58+
/** arguments to shorten git IDs */
59+
private static final int CSET_LEN = 8;
60+
private static final String ABBREV_LOG = "--abbrev=" + CSET_LEN;
61+
private static final String ABBREV_BLAME = "--abbrev=" + (CSET_LEN - 1);
62+
63+
/** Pattern used to extract author/revision from git blame. */
64+
private static final Pattern BLAME_PATTERN =
65+
Pattern.compile("^\\W*(\\w+).+?\\((\\D+).*$");
66+
5867
public GitRepository() {
5968
type = "git";
6069
datePattern = "EEE MMM dd hh:mm:ss yyyy ZZZZ";
@@ -75,6 +84,7 @@ private String getCorrectPath(String fileName, String revision) throws IOExcepti
7584
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
7685
cmd.add(this.cmd);
7786
cmd.add(BLAME);
87+
cmd.add(ABBREV_BLAME);
7888
cmd.add("-C");
7989
cmd.add(fileName);
8090
File directory = new File(directoryName);
@@ -124,6 +134,7 @@ Executor getHistoryLogExecutor(final File file, String sinceRevision)
124134
cmd.add(this.cmd);
125135
cmd.add("log");
126136
cmd.add("--abbrev-commit");
137+
cmd.add(ABBREV_LOG);
127138
cmd.add("--name-only");
128139
cmd.add("--pretty=fuller");
129140

@@ -212,9 +223,6 @@ public InputStream getHistoryGet(String parent, String basename, String rev)
212223

213224
return ret;
214225
}
215-
/** Pattern used to extract author/revision from git blame. */
216-
private static final Pattern BLAME_PATTERN =
217-
Pattern.compile("^\\W*(\\w+).+?\\((\\D+).*$");
218226

219227
/**
220228
* Annotate the specified file/revision.
@@ -229,6 +237,7 @@ public Annotation annotate(File file, String revision) throws IOException {
229237
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
230238
cmd.add(this.cmd);
231239
cmd.add(BLAME);
240+
cmd.add(ABBREV_BLAME);
232241
if (revision != null) {
233242
cmd.add(revision);
234243
}
@@ -243,6 +252,7 @@ public Annotation annotate(File file, String revision) throws IOException {
243252
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
244253
cmd.add(this.cmd);
245254
cmd.add(BLAME);
255+
cmd.add(ABBREV_BLAME);
246256
cmd.add("-C");
247257
cmd.add(file.getName());
248258
exec = new Executor(cmd, file.getParentFile());
@@ -264,6 +274,7 @@ public Annotation annotate(File file, String revision) throws IOException {
264274
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
265275
cmd.add(this.cmd);
266276
cmd.add(BLAME);
277+
cmd.add(ABBREV_BLAME);
267278
if (revision != null) {
268279
cmd.add(revision);
269280
}

src/org/opensolaris/opengrok/index/Indexer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public static void main(String argv[]) {
350350
if (arg[0].endsWith(".")) {
351351
arg[0] = arg[0].substring(0, arg[0].lastIndexOf('.')).toUpperCase();
352352
prefix = true;
353-
} else if (arg[0].startsWith(".")) {
353+
} else if (arg[0].startsWith(".")) {
354354
arg[0] = arg[0].substring(arg[0].lastIndexOf('.') + 1).toUpperCase();
355355
} else {
356356
A_usage();

src/org/opensolaris/opengrok/search/Summarizer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
package org.opensolaris.opengrok.search;
2222

2323
import java.io.IOException;
24-
import java.io.StringReader;
2524
import java.util.ArrayList;
2625
import java.util.Comparator;
2726
import java.util.HashSet;

src/org/opensolaris/opengrok/web/SearchHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public SearchHelper prepareExec(SortedSet<String> projects) {
246246
}
247247
// the Query created by the QueryBuilder
248248
try {
249-
indexDir=new File(dataRoot, "index");
249+
indexDir=new File(dataRoot, "index");
250250
query = builder.build();
251251
if (projects == null) {
252252
errorMsg = "No project selected!";

0 commit comments

Comments
 (0)