@@ -55,6 +55,15 @@ public class GitRepository extends Repository {
55
55
/** git blame command */
56
56
private static final String BLAME = "blame" ;
57
57
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
+
58
67
public GitRepository () {
59
68
type = "git" ;
60
69
datePattern = "EEE MMM dd hh:mm:ss yyyy ZZZZ" ;
@@ -75,6 +84,7 @@ private String getCorrectPath(String fileName, String revision) throws IOExcepti
75
84
ensureCommand (CMD_PROPERTY_KEY , CMD_FALLBACK );
76
85
cmd .add (this .cmd );
77
86
cmd .add (BLAME );
87
+ cmd .add (ABBREV_BLAME );
78
88
cmd .add ("-C" );
79
89
cmd .add (fileName );
80
90
File directory = new File (directoryName );
@@ -124,6 +134,7 @@ Executor getHistoryLogExecutor(final File file, String sinceRevision)
124
134
cmd .add (this .cmd );
125
135
cmd .add ("log" );
126
136
cmd .add ("--abbrev-commit" );
137
+ cmd .add (ABBREV_LOG );
127
138
cmd .add ("--name-only" );
128
139
cmd .add ("--pretty=fuller" );
129
140
@@ -212,9 +223,6 @@ public InputStream getHistoryGet(String parent, String basename, String rev)
212
223
213
224
return ret ;
214
225
}
215
- /** Pattern used to extract author/revision from git blame. */
216
- private static final Pattern BLAME_PATTERN =
217
- Pattern .compile ("^\\ W*(\\ w+).+?\\ ((\\ D+).*$" );
218
226
219
227
/**
220
228
* Annotate the specified file/revision.
@@ -229,6 +237,7 @@ public Annotation annotate(File file, String revision) throws IOException {
229
237
ensureCommand (CMD_PROPERTY_KEY , CMD_FALLBACK );
230
238
cmd .add (this .cmd );
231
239
cmd .add (BLAME );
240
+ cmd .add (ABBREV_BLAME );
232
241
if (revision != null ) {
233
242
cmd .add (revision );
234
243
}
@@ -243,6 +252,7 @@ public Annotation annotate(File file, String revision) throws IOException {
243
252
ensureCommand (CMD_PROPERTY_KEY , CMD_FALLBACK );
244
253
cmd .add (this .cmd );
245
254
cmd .add (BLAME );
255
+ cmd .add (ABBREV_BLAME );
246
256
cmd .add ("-C" );
247
257
cmd .add (file .getName ());
248
258
exec = new Executor (cmd , file .getParentFile ());
@@ -264,6 +274,7 @@ public Annotation annotate(File file, String revision) throws IOException {
264
274
ensureCommand (CMD_PROPERTY_KEY , CMD_FALLBACK );
265
275
cmd .add (this .cmd );
266
276
cmd .add (BLAME );
277
+ cmd .add (ABBREV_BLAME );
267
278
if (revision != null ) {
268
279
cmd .add (revision );
269
280
}
0 commit comments