From: Junio C Hamano Date: Fri, 19 Jul 2019 18:30:20 +0000 (-0700) Subject: Merge branch 'ds/commit-graph-incremental' X-Git-Tag: v2.23.0-rc0~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=92b1ea66b9a8f012a343ebc157c3441154e831f0;p=thirdparty%2Fgit.git Merge branch 'ds/commit-graph-incremental' The commits in a repository can be described by multiple commit-graph files now, which allows the commit-graph files to be updated incrementally. * ds/commit-graph-incremental: commit-graph: test verify across alternates commit-graph: normalize commit-graph filenames commit-graph: test --split across alternate without --split commit-graph: test octopus merges with --split commit-graph: clean up chains after flattened write commit-graph: verify chains with --shallow mode commit-graph: create options for split files commit-graph: expire commit-graph files commit-graph: allow cross-alternate chains commit-graph: merge commit-graph chains commit-graph: add --split option to builtin commit-graph: write commit-graph chains commit-graph: rearrange chunk count logic commit-graph: add base graphs chunk commit-graph: load commit-graph chains commit-graph: rename commit_compare to oid_compare commit-graph: prepare for commit-graph chains commit-graph: document commit-graph chains --- 92b1ea66b9a8f012a343ebc157c3441154e831f0 diff --cc builtin/commit.c index 3b561c2a75,9216e9c043..3e4b5bfe4e --- a/builtin/commit.c +++ b/builtin/commit.c @@@ -1684,10 -1667,10 +1684,10 @@@ int cmd_commit(int argc, const char **a if (commit_index_files()) die(_("repository has been updated, but unable to write\n" "new_index file. Check that disk is not full and quota is\n" - "not exceeded, and then \"git reset HEAD\" to recover.")); + "not exceeded, and then \"git restore --staged :/\" to recover.")); if (git_env_bool(GIT_TEST_COMMIT_GRAPH, 0) && - write_commit_graph_reachable(get_object_directory(), 0)) + write_commit_graph_reachable(get_object_directory(), 0, NULL)) return 1; repo_rerere(the_repository, 0); diff --cc commit-graph.c index 8cc1d1d6c3,c91e6f0fb8..b3c4de79b6 --- a/commit-graph.c +++ b/commit-graph.c @@@ -267,10 -295,10 +295,12 @@@ struct commit_graph *parse_commit_graph last_chunk_offset = chunk_offset; } + hashcpy(graph->oid.hash, graph->data + graph->data_len - graph->hash_len); + - if (verify_commit_graph_lite(graph)) + if (verify_commit_graph_lite(graph)) { + free(graph); return NULL; + } return graph; } @@@ -412,12 -596,27 +603,27 @@@ static int fill_commit_in_graph(struct uint32_t *parent_data_ptr; uint64_t date_low, date_high; struct commit_list **pptr; - const unsigned char *commit_data = g->chunk_commit_data + (g->hash_len + 16) * pos; + const unsigned char *commit_data; + uint32_t lex_index; - item->object.parsed = 1; + while (pos < g->num_commits_in_base) + g = g->base_graph; + + if (pos >= g->num_commits + g->num_commits_in_base) + die(_("invalid commit position. commit-graph is likely corrupt")); + + /* + * Store the "full" position, but then use the + * "local" position for the rest of the calculation. + */ item->graph_pos = pos; + lex_index = pos - g->num_commits_in_base; + + commit_data = g->chunk_commit_data + (g->hash_len + 16) * lex_index; + + item->object.parsed = 1; - item->maybe_tree = NULL; + set_commit_tree(item, NULL); date_high = get_be32(commit_data + g->hash_len + 8) & 0x3; date_low = get_be32(commit_data + g->hash_len + 12); @@@ -499,11 -709,16 +716,16 @@@ static struct tree *load_tree_for_commi struct commit *c) { struct object_id oid; - const unsigned char *commit_data = g->chunk_commit_data + - GRAPH_DATA_WIDTH * (c->graph_pos); + const unsigned char *commit_data; + + while (c->graph_pos < g->num_commits_in_base) + g = g->base_graph; + + commit_data = g->chunk_commit_data + + GRAPH_DATA_WIDTH * (c->graph_pos - g->num_commits_in_base); hashcpy(oid.hash, commit_data); - c->maybe_tree = lookup_tree(r, &oid); + set_commit_tree(c, lookup_tree(r, &oid)); return c->maybe_tree; }