Skip to content

Commit 93915c6

Browse files
author
Vladimir Kotal
committed
Merge commits tunable (#3496)
fixes #3367
1 parent 96ffc67 commit 93915c6

File tree

7 files changed

+72
-7
lines changed

7 files changed

+72
-7
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, 2020, Chris Fraire <cfraire@me.com>.
2323
* Portions Copyright (c) 2020, Aleksandr Kirillov <alexkirillovsamara@gmail.com>.
2424
*/
@@ -232,6 +232,8 @@ public final class Configuration {
232232
*/
233233
private boolean handleHistoryOfRenamedFiles;
234234

235+
private boolean mergeCommitsEnabled;
236+
235237
public static final double defaultRamBufferSize = 16;
236238

237239
/**
@@ -541,6 +543,7 @@ public Configuration() {
541543
//mandoc is default(String)
542544
setMaxSearchThreadCount(2 * Runtime.getRuntime().availableProcessors());
543545
setMaxRevisionThreadCount(Runtime.getRuntime().availableProcessors());
546+
setMergeCommitsEnabled(true);
544547
setMessageLimit(500);
545548
setNavigateWindowEnabled(false);
546549
setNestingMaximum(1);
@@ -831,6 +834,14 @@ public void setHandleHistoryOfRenamedFiles(boolean enable) {
831834
this.handleHistoryOfRenamedFiles = enable;
832835
}
833836

837+
public void setMergeCommitsEnabled(boolean flag) {
838+
this.mergeCommitsEnabled = flag;
839+
}
840+
841+
public boolean isMergeCommitsEnabled() {
842+
return mergeCommitsEnabled;
843+
}
844+
834845
public boolean isNavigateWindowEnabled() {
835846
return navigateWindowEnabled;
836847
}

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Project.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2018, Chris Fraire <cfraire@me.com>.
2323
*/
2424
package org.opengrok.indexer.configuration;
@@ -83,6 +83,11 @@ public class Project implements Comparable<Project>, Nameable, Serializable {
8383
*/
8484
private Boolean historyEnabled = null;
8585

86+
/**
87+
* This flag enables/disables per project merge commits.
88+
*/
89+
private Boolean mergeCommitsEnabled = null;
90+
8691
/**
8792
* This marks the project as (not)ready before initial index is done. this
8893
* is to avoid all/multi-project searches referencing this project from
@@ -237,6 +242,13 @@ public boolean isHandleRenamedFiles() {
237242
return handleRenamedFiles != null && handleRenamedFiles;
238243
}
239244

245+
/**
246+
* @return true if merge commits are enabled.
247+
*/
248+
public boolean isMergeCommitsEnabled() {
249+
return mergeCommitsEnabled != null && mergeCommitsEnabled;
250+
}
251+
240252
/**
241253
* @param flag true if project should handle renamed files, false otherwise.
242254
*/
@@ -258,6 +270,13 @@ public void setHistoryEnabled(boolean flag) {
258270
this.historyEnabled = flag;
259271
}
260272

273+
/**
274+
* @param flag true if project's repositories should deal with merge commits.
275+
*/
276+
public void setMergeCommitsEnabled(boolean flag) {
277+
this.mergeCommitsEnabled = flag;
278+
}
279+
261280
/**
262281
* Return groups where this project belongs.
263282
*
@@ -322,6 +341,11 @@ public final void completeWithDefaults() {
322341
if (navigateWindowEnabled == null) {
323342
setNavigateWindowEnabled(env.isNavigateWindowEnabled());
324343
}
344+
345+
// Allow project to override global setting of merge commits.
346+
if (mergeCommitsEnabled == null) {
347+
setMergeCommitsEnabled(env.isMergeCommitsEnabled());
348+
}
325349
}
326350

327351
/**

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, 2020, Chris Fraire <cfraire@me.com>.
2323
*/
2424
package org.opengrok.indexer.configuration;
@@ -1251,6 +1251,14 @@ public boolean isHandleHistoryOfRenamedFiles() {
12511251
return syncReadConfiguration(Configuration::isHandleHistoryOfRenamedFiles);
12521252
}
12531253

1254+
public void setMergeCommitsEnabled(boolean flag) {
1255+
syncWriteConfiguration(flag, Configuration::setMergeCommitsEnabled);
1256+
}
1257+
1258+
public boolean isMergeCommitsEnabled() {
1259+
return syncReadConfiguration(Configuration::isMergeCommitsEnabled);
1260+
}
1261+
12541262
public void setNavigateWindowEnabled(boolean navigateWindowEnabled) {
12551263
syncWriteConfiguration(navigateWindowEnabled, Configuration::setNavigateWindowEnabled);
12561264
}

opengrok-indexer/src/main/java/org/opengrok/indexer/history/GitRepository.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ Executor getHistoryLogExecutor(final File file, String sinceRevision)
171171
cmd.add("--name-only");
172172
cmd.add("--pretty=fuller");
173173
cmd.add(GIT_DATE_OPT);
174-
cmd.add("-m");
174+
if (isMergeCommitsEnabled()) {
175+
cmd.add("-m");
176+
}
175177

176178
if (file.isFile() && isHandleRenamedFiles()) {
177179
cmd.add("--follow");

opengrok-indexer/src/main/java/org/opengrok/indexer/history/Repository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, 2020, Chris Fraire <cfraire@me.com>.
2323
*/
2424
package org.opengrok.indexer.history;

opengrok-indexer/src/main/java/org/opengrok/indexer/history/RepositoryInfo.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, 2019, Chris Fraire <cfraire@me.com>.
2323
*/
2424
package org.opengrok.indexer.history;
@@ -77,6 +77,8 @@ public class RepositoryInfo implements Serializable {
7777
private boolean handleRenamedFiles;
7878
@DTOElement
7979
private boolean historyEnabled;
80+
@DTOElement
81+
private boolean mergeCommitsEnabled;
8082

8183
/**
8284
* Empty constructor to support serialization.
@@ -110,6 +112,20 @@ public void setHandleRenamedFiles(boolean flag) {
110112
this.handleRenamedFiles = flag;
111113
}
112114

115+
/**
116+
* @return true if the repository handles merge commits.
117+
*/
118+
public boolean isMergeCommitsEnabled() {
119+
return this.mergeCommitsEnabled;
120+
}
121+
122+
/**
123+
* @param flag true if the repository should handle merge commits, false otherwise.
124+
*/
125+
public void setMergeCommitsEnabled(boolean flag) {
126+
this.mergeCommitsEnabled = flag;
127+
}
128+
113129
/**
114130
* @return true if the repository should have history cache.
115131
*/
@@ -293,11 +309,13 @@ public void fillFromProject() {
293309
if (proj != null) {
294310
setHistoryEnabled(proj.isHistoryEnabled());
295311
setHandleRenamedFiles(proj.isHandleRenamedFiles());
312+
setMergeCommitsEnabled(proj.isMergeCommitsEnabled());
296313
} else {
297314
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
298315

299316
setHistoryEnabled(env.isHistoryEnabled());
300317
setHandleRenamedFiles(env.isHandleHistoryOfRenamedFiles());
318+
setMergeCommitsEnabled(env.isMergeCommitsEnabled());
301319
}
302320
}
303321

opengrok-indexer/src/test/java/org/opengrok/indexer/history/GitRepositoryOctopusTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2019, 2020, Chris Fraire <cfraire@me.com>.
2323
*/
2424
package org.opengrok.indexer.history;
@@ -34,6 +34,7 @@
3434
import org.opengrok.indexer.condition.ConditionalRun;
3535
import org.opengrok.indexer.condition.ConditionalRunRule;
3636
import org.opengrok.indexer.condition.RepositoryInstalled;
37+
import org.opengrok.indexer.configuration.RuntimeEnvironment;
3738
import org.opengrok.indexer.util.TestRepository;
3839
import org.opengrok.indexer.web.Util;
3940

@@ -59,6 +60,7 @@ public static void setUpClass() throws Exception {
5960
repository = new TestRepository();
6061
repository.create(GitRepositoryOctopusTest.class.getResourceAsStream(
6162
"/history/git-octopus.zip"));
63+
RuntimeEnvironment.getInstance().setMergeCommitsEnabled(true);
6264
}
6365

6466
@AfterClass

0 commit comments

Comments
 (0)