Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-08 16:51:12 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-08 16:51:12 +0300
commit43cb85d43809733551d9ad682987d89a2f4afb36 (patch)
tree450ecdf157bab2cc8f7e171734d9dfe5cec435f4
parent5e11497d19fd5ac5d5ce84e42d6a86556061d319 (diff)
parenta8f996a321e73597a0c726576bc9b8c1d03d9a07 (diff)
Merge branch 'pks-git-disable-commit-graph-generation-v2' into 'master'
git: Fix commit-graph corruption caused by corrected committer dates Closes #4327 and gitlab#365903 See merge request gitlab-org/gitaly!4677
-rw-r--r--internal/git/command_factory.go28
-rw-r--r--internal/git/command_factory_test.go2
2 files changed, 30 insertions, 0 deletions
diff --git a/internal/git/command_factory.go b/internal/git/command_factory.go
index b9046b5d4..9a4c8b881 100644
--- a/internal/git/command_factory.go
+++ b/internal/git/command_factory.go
@@ -520,6 +520,34 @@ func (cf *ExecCommandFactory) globalConfiguration(ctx context.Context) ([]Global
// mechanism to replace malicious commits with seemingly benign ones. We thus globally
// disable this mechanism.
ConfigPair{Key: "core.useReplaceRefs", Value: "false"},
+
+ // Commit-graphs are used as an optimization to speed up reading commits and to be
+ // able to perform certain commit-related queries faster. One property that these
+ // graphs are storing is the generation number of a commit, where there are two
+ // different types of generation numbers:
+ //
+ // - Topological level: a commit with no parents has a level of 1. A commit with
+ // at least one parent has a level one more than the largest topological level
+ // of its parents.
+ //
+ // - Corrected committer date: a commit with no parents has a corrected commit
+ // date equal to its committer date. A commit with at least one parent has a
+ // corrected committer date equal to the maximum between either its own
+ // committer date or the largest corrected committer date across its parents
+ // plus 1.
+ //
+ // By default, newer Git versions store both generation numbers for commits, where
+ // the corrected committer date allows for some more optimizations. But due to a bug
+ // in Git v2.35.0 and earlier, the corrected committer date wasn't ever read.
+ //
+ // This bug was fixed in Git v2.36.0, together with a few other bugs in this area.
+ // But unfortunately, a new bug was introduced: when upgrading a commit-graph
+ // written by Git v2.35.0 or newer with Git v2.36.0 and later with `--changed-paths`
+ // enabled then the resulting commit-graph may be corrupt.
+ //
+ // Let's disable reading and writing corrected committer dates for now until the fix
+ // to this issue is upstream.
+ ConfigPair{Key: "commitGraph.generationVersion", Value: "1"},
}
// Git v2.36.0 introduced new fine-grained configuration for what data should be fsynced and
diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go
index 5868e539c..b47119a71 100644
--- a/internal/git/command_factory_test.go
+++ b/internal/git/command_factory_test.go
@@ -482,6 +482,7 @@ func TestExecCommandFactory_config(t *testing.T) {
"gc.auto=0",
"core.autocrlf=input",
"core.usereplacerefs=false",
+ "commitgraph.generationversion=1",
}
for _, tc := range []struct {
@@ -542,6 +543,7 @@ func TestExecCommandFactory_SidecarGitConfiguration(t *testing.T) {
{Key: "gc.auto", Value: "0"},
{Key: "core.autocrlf", Value: "input"},
{Key: "core.useReplaceRefs", Value: "false"},
+ {Key: "commitGraph.generationVersion", Value: "1"},
}
commonTail := []git.ConfigPair{