summaryrefslogtreecommitdiff
path: root/commit-graph.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2018-04-25 14:37:55 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-22 03:36:25 (GMT)
commit83073cc994cc3cd364f3f213478b9162476e8e44 (patch)
treee5b239f23a72baa58e0dd3a76f8fc391a6ca2fb1 /commit-graph.c
parent8fb572af5f4e3bef2415ac2dba8d76d37235b489 (diff)
downloadgit-83073cc994cc3cd364f3f213478b9162476e8e44.zip
git-83073cc994cc3cd364f3f213478b9162476e8e44.tar.gz
git-83073cc994cc3cd364f3f213478b9162476e8e44.tar.bz2
commit: add generation number to struct commit
The generation number of a commit is defined recursively as follows: * If a commit A has no parents, then the generation number of A is one. * If a commit A has parents, then the generation number of A is one more than the maximum generation number among the parents of A. Add a uint32_t generation field to struct commit so we can pass this information to revision walks. We use three special values to signal the generation number is invalid: GENERATION_NUMBER_INFINITY 0xFFFFFFFF GENERATION_NUMBER_MAX 0x3FFFFFFF GENERATION_NUMBER_ZERO 0 The first (_INFINITY) means the generation number has not been loaded or computed. The second (_MAX) means the generation number is too large to store in the commit-graph file. The third (_ZERO) means the generation number was loaded from a commit graph file that was written by a version of git that did not support generation numbers. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 70fa1b2..9ad21c3 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -262,6 +262,8 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin
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);