Skip to content

Commit

Permalink
Merge commits tunable (#3496)
Browse files Browse the repository at this point in the history
fixes #3367
  • Loading branch information
Vladimir Kotal committed Apr 9, 2021
1 parent 96ffc67 commit 93915c6
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
* Portions Copyright (c) 2020, Aleksandr Kirillov <[email protected]>.
*/
Expand Down Expand Up @@ -232,6 +232,8 @@ public final class Configuration {
*/
private boolean handleHistoryOfRenamedFiles;

private boolean mergeCommitsEnabled;

public static final double defaultRamBufferSize = 16;

/**
Expand Down Expand Up @@ -541,6 +543,7 @@ public Configuration() {
//mandoc is default(String)
setMaxSearchThreadCount(2 * Runtime.getRuntime().availableProcessors());
setMaxRevisionThreadCount(Runtime.getRuntime().availableProcessors());
setMergeCommitsEnabled(true);
setMessageLimit(500);
setNavigateWindowEnabled(false);
setNestingMaximum(1);
Expand Down Expand Up @@ -831,6 +834,14 @@ public void setHandleHistoryOfRenamedFiles(boolean enable) {
this.handleHistoryOfRenamedFiles = enable;
}

public void setMergeCommitsEnabled(boolean flag) {
this.mergeCommitsEnabled = flag;
}

public boolean isMergeCommitsEnabled() {
return mergeCommitsEnabled;
}

public boolean isNavigateWindowEnabled() {
return navigateWindowEnabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2018, Chris Fraire <[email protected]>.
*/
package org.opengrok.indexer.configuration;
Expand Down Expand Up @@ -83,6 +83,11 @@ public class Project implements Comparable<Project>, Nameable, Serializable {
*/
private Boolean historyEnabled = null;

/**
* This flag enables/disables per project merge commits.
*/
private Boolean mergeCommitsEnabled = null;

/**
* This marks the project as (not)ready before initial index is done. this
* is to avoid all/multi-project searches referencing this project from
Expand Down Expand Up @@ -237,6 +242,13 @@ public boolean isHandleRenamedFiles() {
return handleRenamedFiles != null && handleRenamedFiles;
}

/**
* @return true if merge commits are enabled.
*/
public boolean isMergeCommitsEnabled() {
return mergeCommitsEnabled != null && mergeCommitsEnabled;
}

/**
* @param flag true if project should handle renamed files, false otherwise.
*/
Expand All @@ -258,6 +270,13 @@ public void setHistoryEnabled(boolean flag) {
this.historyEnabled = flag;
}

/**
* @param flag true if project's repositories should deal with merge commits.
*/
public void setMergeCommitsEnabled(boolean flag) {
this.mergeCommitsEnabled = flag;
}

/**
* Return groups where this project belongs.
*
Expand Down Expand Up @@ -322,6 +341,11 @@ public final void completeWithDefaults() {
if (navigateWindowEnabled == null) {
setNavigateWindowEnabled(env.isNavigateWindowEnabled());
}

// Allow project to override global setting of merge commits.
if (mergeCommitsEnabled == null) {
setMergeCommitsEnabled(env.isMergeCommitsEnabled());
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
*/
package org.opengrok.indexer.configuration;
Expand Down Expand Up @@ -1251,6 +1251,14 @@ public boolean isHandleHistoryOfRenamedFiles() {
return syncReadConfiguration(Configuration::isHandleHistoryOfRenamedFiles);
}

public void setMergeCommitsEnabled(boolean flag) {
syncWriteConfiguration(flag, Configuration::setMergeCommitsEnabled);
}

public boolean isMergeCommitsEnabled() {
return syncReadConfiguration(Configuration::isMergeCommitsEnabled);
}

public void setNavigateWindowEnabled(boolean navigateWindowEnabled) {
syncWriteConfiguration(navigateWindowEnabled, Configuration::setNavigateWindowEnabled);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ Executor getHistoryLogExecutor(final File file, String sinceRevision)
cmd.add("--name-only");
cmd.add("--pretty=fuller");
cmd.add(GIT_DATE_OPT);
cmd.add("-m");
if (isMergeCommitsEnabled()) {
cmd.add("-m");
}

if (file.isFile() && isHandleRenamedFiles()) {
cmd.add("--follow");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
*/
package org.opengrok.indexer.history;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2017, 2019, Chris Fraire <[email protected]>.
*/
package org.opengrok.indexer.history;
Expand Down Expand Up @@ -77,6 +77,8 @@ public class RepositoryInfo implements Serializable {
private boolean handleRenamedFiles;
@DTOElement
private boolean historyEnabled;
@DTOElement
private boolean mergeCommitsEnabled;

/**
* Empty constructor to support serialization.
Expand Down Expand Up @@ -110,6 +112,20 @@ public void setHandleRenamedFiles(boolean flag) {
this.handleRenamedFiles = flag;
}

/**
* @return true if the repository handles merge commits.
*/
public boolean isMergeCommitsEnabled() {
return this.mergeCommitsEnabled;
}

/**
* @param flag true if the repository should handle merge commits, false otherwise.
*/
public void setMergeCommitsEnabled(boolean flag) {
this.mergeCommitsEnabled = flag;
}

/**
* @return true if the repository should have history cache.
*/
Expand Down Expand Up @@ -293,11 +309,13 @@ public void fillFromProject() {
if (proj != null) {
setHistoryEnabled(proj.isHistoryEnabled());
setHandleRenamedFiles(proj.isHandleRenamedFiles());
setMergeCommitsEnabled(proj.isMergeCommitsEnabled());
} else {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();

setHistoryEnabled(env.isHistoryEnabled());
setHandleRenamedFiles(env.isHandleHistoryOfRenamedFiles());
setMergeCommitsEnabled(env.isMergeCommitsEnabled());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2019, 2020, Chris Fraire <[email protected]>.
*/
package org.opengrok.indexer.history;
Expand All @@ -34,6 +34,7 @@
import org.opengrok.indexer.condition.ConditionalRun;
import org.opengrok.indexer.condition.ConditionalRunRule;
import org.opengrok.indexer.condition.RepositoryInstalled;
import org.opengrok.indexer.configuration.RuntimeEnvironment;
import org.opengrok.indexer.util.TestRepository;
import org.opengrok.indexer.web.Util;

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

@AfterClass
Expand Down

0 comments on commit 93915c6

Please sign in to comment.