From: Derrick Stolee <dstolee@microsoft•com>
To: "git@vger•kernel.org" <git@vger•kernel.org>
Cc: "sbeller@google•com" <sbeller@google•com>,
"jnareb@gmail•com" <jnareb@gmail•com>,
"stolee@gmail•com" <stolee@gmail•com>,
Derrick Stolee <dstolee@microsoft•com>
Subject: [RFC PATCH 6/6] commit-graph: revert to odb on missing parents
Date: Thu, 31 May 2018 17:41:20 +0000 [thread overview]
Message-ID: <20180531174024.124488-7-dstolee@microsoft.com> (raw)
In-Reply-To: <20180531174024.124488-1-dstolee@microsoft.com>
The commit-graph format includes a way to specify a parent is
"missing" from the commit-graph (i.e. we do not have a record of
that parent in our list of object IDs, and hence cannot provide
a graph position). For mose cases, this does not occur due to
the close_reachable() method adding all reachable commits. However,
in a shallow clone, we will try to record the parents of a commit
on the shallow boundary, but the parents are not in the repository.
The GRAPH_PARENT_MISSING value that is stored in the format is
purposeful, especially for future plans to make the commit-graph file
incremental or transporting sections of a commit-graph file across
the network.
In the meantime, check if a commit has a missing parent while filling
its details from the commit-graph. If a parent is missing, still
assign the generation number and graph position for that item, but
report that the commit-graph failed to fill the contents. Then the
caller is responsible for filling the rest of the data from a commit
buffer.
Signed-off-by: Derrick Stolee <dstolee@microsoft•com>
---
commit-graph.c | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/commit-graph.c b/commit-graph.c
index 80e377b90f..3e33d061fe 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -278,17 +278,44 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin
struct commit_list **pptr;
const unsigned char *commit_data = g->chunk_commit_data + (g->hash_len + 16) * pos;
- item->object.parsed = 1;
+ item->generation = get_be32(commit_data + g->hash_len + 8) >> 2;
item->graph_pos = pos;
+ /*
+ * If we have any edges marked as GRAPH_PARENT_MISSING, we must not parse any
+ * more of this object and leave it to the commit buffer to parse.
+ */
+ edge_value = get_be32(commit_data + g->hash_len);
+ if (edge_value == GRAPH_PARENT_MISSING)
+ return 0;
+ if (edge_value == GRAPH_PARENT_NONE)
+ goto continue_parsing;
+
+ edge_value = get_be32(commit_data + g->hash_len + 4);
+ if (edge_value == GRAPH_PARENT_MISSING)
+ return 0;
+ if (edge_value == GRAPH_PARENT_NONE)
+ goto continue_parsing;
+ if (!(edge_value & GRAPH_OCTOPUS_EDGES_NEEDED))
+ goto continue_parsing;
+
+ parent_data_ptr = (uint32_t*)(g->chunk_large_edges +
+ 4 * (uint64_t)(edge_value & GRAPH_EDGE_LAST_MASK));
+ do {
+ edge_value = get_be32(parent_data_ptr);
+ if (edge_value == GRAPH_PARENT_MISSING)
+ return 0;
+ parent_data_ptr++;
+ } while (!(edge_value & GRAPH_LAST_EDGE));
+
+continue_parsing:
+ item->object.parsed = 1;
item->maybe_tree = NULL;
date_high = get_be32(commit_data + g->hash_len + 8) & 0x3;
date_low = get_be32(commit_data + g->hash_len + 12);
item->date = (timestamp_t)((date_high << 32) | date_low);
- item->generation = get_be32(commit_data + g->hash_len + 8) >> 2;
-
pptr = &item->parents;
edge_value = get_be32(commit_data + g->hash_len);
--
2.16.2.338.gcfe06ae955
next prev parent reply other threads:[~2018-05-31 17:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-31 17:40 [RFC PATCH 0/6] Fix commit-graph/graft/replace/shallow combo Derrick Stolee
2018-05-31 17:41 ` [RFC PATCH 1/6] DO NOT MERGE: compute commit-graph on every commit Derrick Stolee
2018-05-31 19:39 ` Stefan Beller
2018-05-31 17:41 ` [RFC PATCH 2/6] DO NOT MERGE: write commit-graph on every fetch Derrick Stolee
2018-05-31 17:41 ` [RFC PATCH 3/6] commit-graph: enable replace-object and grafts Derrick Stolee
2018-06-09 15:47 ` Jakub Narebski
2018-05-31 17:41 ` [RFC PATCH 4/6] commit-graph: avoid writing when repo is shallow Derrick Stolee
2018-05-31 19:07 ` Stefan Beller
2018-06-01 2:30 ` Junio C Hamano
2018-06-01 11:46 ` Derrick Stolee
2018-06-02 18:39 ` Jakub Narebski
2018-06-04 2:19 ` Junio C Hamano
2018-05-31 17:41 ` [RFC PATCH 5/6] fetch: destroy commit graph on shallow parameters Derrick Stolee
2018-05-31 19:29 ` Stefan Beller
2018-05-31 17:41 ` Derrick Stolee [this message]
2018-05-31 18:33 ` [RFC PATCH 0/6] Fix commit-graph/graft/replace/shallow combo Stefan Beller
2018-06-01 1:09 ` Derrick Stolee
2018-06-08 11:59 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180531174024.124488-7-dstolee@microsoft.com \
--to=dstolee@microsoft$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=jnareb@gmail$(echo .)com \
--cc=sbeller@google$(echo .)com \
--cc=stolee@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox