]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph: don't consider "replace" objects with "verify"
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 14 Oct 2021 23:37:16 +0000 (01:37 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 15 Oct 2021 16:21:30 +0000 (09:21 -0700)
Extend the code added in d6538246d3d (commit-graph: not compatible
with replace objects, 2018-08-20) which ignored replace objects in the
"write" command to ignore it in the "verify" command too.

We can just move this assignment to the cmd_commit_graph(), it
dispatches to "write" and "verify", and we're unlikely to ever get a
sub-command that would like to consider replace refs.

This will make tests added in eddc1f556cd (mktag tests: test
update-ref and reachable fsck, 2021-06-17) pass in combination with
the "GIT_TEST_COMMIT_GRAPH" mode added in 859fdc0c3cf (commit-graph:
define GIT_TEST_COMMIT_GRAPH, 2018-08-29), except that mode is
currently broken (but is being fixed concurrently). See the discussion
starting at [1].

1. https://lore.kernel.org/git/87wnmihswp.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit-graph.c
t/t5318-commit-graph.sh

index cd8631522167e1c1f23da9038bf58ce87c17fa94..2780816820532a16ac7f0b5f6ce04a33784fa40e 100644 (file)
@@ -267,7 +267,6 @@ static int graph_write(int argc, const char **argv)
            git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))
                flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;
 
-       read_replace_refs = 0;
        odb = find_odb(the_repository, opts.obj_dir);
 
        if (opts.reachable) {
@@ -328,6 +327,7 @@ int cmd_commit_graph(int argc, const char **argv, const char *prefix)
                             builtin_commit_graph_usage,
                             PARSE_OPT_STOP_AT_NON_OPTION);
 
+       read_replace_refs = 0;
        save_commit_buffer = 0;
 
        if (argc > 0) {
index 579067299e508fe816fe6b86eaeb622795dab70c..58057de00fa328bc2957edf4c84de2ab51e4540e 100755 (executable)
@@ -366,6 +366,7 @@ test_expect_success 'replace-objects invalidates commit-graph' '
                git commit-graph write --reachable &&
                test_path_is_file .git/objects/info/commit-graph &&
                git replace HEAD~1 HEAD~2 &&
+               graph_git_two_modes "commit-graph verify" &&
                git -c core.commitGraph=false log >expect &&
                git -c core.commitGraph=true log >actual &&
                test_cmp expect actual &&