]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ds/commit-graph-incremental'
authorJunio C Hamano <gitster@pobox.com>
Fri, 19 Jul 2019 18:30:20 +0000 (11:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Jul 2019 18:30:20 +0000 (11:30 -0700)
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

1  2 
builtin/commit.c
builtin/gc.c
commit-graph.c
t/t5318-commit-graph.sh

index 3b561c2a75b5075ca688868ab965c7b96a87a9e8,9216e9c043d1561315bf2566c9531dc00ece0485..3e4b5bfe4e1d18d8f7dfa8d33d0377b642653375
@@@ -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 builtin/gc.c
Simple merge
diff --cc commit-graph.c
index 8cc1d1d6c3aff0842c42ecda5cc545c9eb085802,c91e6f0fb821582706b3c9ee232da1335ea7427d..b3c4de79b6da4502726dbec5e21b11734d76e28e
@@@ -267,10 -295,10 +295,12 @@@ struct commit_graph *parse_commit_graph
                last_chunk_offset = chunk_offset;
        }
  
 -      if (verify_commit_graph_lite(graph))
+       hashcpy(graph->oid.hash, graph->data + graph->data_len - graph->hash_len);
 +      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;
  }
Simple merge