commit-graph: return 64-bit generation number
In a preparatory step for introducing corrected commit dates, let's return timestamp_t values from commit_graph_generation(), use timestamp_t for local variables and define GENERATION_NUMBER_INFINITY as (2 ^ 63 - 1) instead. We rename GENERATION_NUMBER_MAX to GENERATION_NUMBER_V1_MAX to represent the largest topological level we can store in the commit data chunk. With corrected commit dates implemented, we will have two such *_MAX variables to denote the largest offset and largest topological level that can be stored. Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com> Reviewed-by: Taylor Blau <me@ttaylorr.com> Reviewed-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
72a2bfcaf0
commit
d7f92784c6
@ -32,12 +32,12 @@ static int queue_has_nonstale(struct prio_queue *queue)
|
||||
static struct commit_list *paint_down_to_common(struct repository *r,
|
||||
struct commit *one, int n,
|
||||
struct commit **twos,
|
||||
int min_generation)
|
||||
timestamp_t min_generation)
|
||||
{
|
||||
struct prio_queue queue = { compare_commits_by_gen_then_commit_date };
|
||||
struct commit_list *result = NULL;
|
||||
int i;
|
||||
uint32_t last_gen = GENERATION_NUMBER_INFINITY;
|
||||
timestamp_t last_gen = GENERATION_NUMBER_INFINITY;
|
||||
|
||||
if (!min_generation)
|
||||
queue.compare = compare_commits_by_commit_date;
|
||||
@ -58,10 +58,10 @@ static struct commit_list *paint_down_to_common(struct repository *r,
|
||||
struct commit *commit = prio_queue_get(&queue);
|
||||
struct commit_list *parents;
|
||||
int flags;
|
||||
uint32_t generation = commit_graph_generation(commit);
|
||||
timestamp_t generation = commit_graph_generation(commit);
|
||||
|
||||
if (min_generation && generation > last_gen)
|
||||
BUG("bad generation skip %8x > %8x at %s",
|
||||
BUG("bad generation skip %"PRItime" > %"PRItime" at %s",
|
||||
generation, last_gen,
|
||||
oid_to_hex(&commit->object.oid));
|
||||
last_gen = generation;
|
||||
@ -177,12 +177,12 @@ static int remove_redundant(struct repository *r, struct commit **array, int cnt
|
||||
repo_parse_commit(r, array[i]);
|
||||
for (i = 0; i < cnt; i++) {
|
||||
struct commit_list *common;
|
||||
uint32_t min_generation = commit_graph_generation(array[i]);
|
||||
timestamp_t min_generation = commit_graph_generation(array[i]);
|
||||
|
||||
if (redundant[i])
|
||||
continue;
|
||||
for (j = filled = 0; j < cnt; j++) {
|
||||
uint32_t curr_generation;
|
||||
timestamp_t curr_generation;
|
||||
if (i == j || redundant[j])
|
||||
continue;
|
||||
filled_index[filled] = j;
|
||||
@ -321,7 +321,7 @@ int repo_in_merge_bases_many(struct repository *r, struct commit *commit,
|
||||
{
|
||||
struct commit_list *bases;
|
||||
int ret = 0, i;
|
||||
uint32_t generation, max_generation = GENERATION_NUMBER_ZERO;
|
||||
timestamp_t generation, max_generation = GENERATION_NUMBER_ZERO;
|
||||
|
||||
if (repo_parse_commit(r, commit))
|
||||
return ret;
|
||||
@ -470,7 +470,7 @@ static int in_commit_list(const struct commit_list *want, struct commit *c)
|
||||
static enum contains_result contains_test(struct commit *candidate,
|
||||
const struct commit_list *want,
|
||||
struct contains_cache *cache,
|
||||
uint32_t cutoff)
|
||||
timestamp_t cutoff)
|
||||
{
|
||||
enum contains_result *cached = contains_cache_at(cache, candidate);
|
||||
|
||||
@ -506,11 +506,11 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
|
||||
{
|
||||
struct contains_stack contains_stack = { 0, 0, NULL };
|
||||
enum contains_result result;
|
||||
uint32_t cutoff = GENERATION_NUMBER_INFINITY;
|
||||
timestamp_t cutoff = GENERATION_NUMBER_INFINITY;
|
||||
const struct commit_list *p;
|
||||
|
||||
for (p = want; p; p = p->next) {
|
||||
uint32_t generation;
|
||||
timestamp_t generation;
|
||||
struct commit *c = p->item;
|
||||
load_commit_graph_info(the_repository, c);
|
||||
generation = commit_graph_generation(c);
|
||||
@ -566,8 +566,8 @@ static int compare_commits_by_gen(const void *_a, const void *_b)
|
||||
const struct commit *a = *(const struct commit * const *)_a;
|
||||
const struct commit *b = *(const struct commit * const *)_b;
|
||||
|
||||
uint32_t generation_a = commit_graph_generation(a);
|
||||
uint32_t generation_b = commit_graph_generation(b);
|
||||
timestamp_t generation_a = commit_graph_generation(a);
|
||||
timestamp_t generation_b = commit_graph_generation(b);
|
||||
|
||||
if (generation_a < generation_b)
|
||||
return -1;
|
||||
@ -580,7 +580,7 @@ int can_all_from_reach_with_flag(struct object_array *from,
|
||||
unsigned int with_flag,
|
||||
unsigned int assign_flag,
|
||||
time_t min_commit_date,
|
||||
uint32_t min_generation)
|
||||
timestamp_t min_generation)
|
||||
{
|
||||
struct commit **list = NULL;
|
||||
int i;
|
||||
@ -681,13 +681,13 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
|
||||
time_t min_commit_date = cutoff_by_min_date ? from->item->date : 0;
|
||||
struct commit_list *from_iter = from, *to_iter = to;
|
||||
int result;
|
||||
uint32_t min_generation = GENERATION_NUMBER_INFINITY;
|
||||
timestamp_t min_generation = GENERATION_NUMBER_INFINITY;
|
||||
|
||||
while (from_iter) {
|
||||
add_object_array(&from_iter->item->object, NULL, &from_objs);
|
||||
|
||||
if (!parse_commit(from_iter->item)) {
|
||||
uint32_t generation;
|
||||
timestamp_t generation;
|
||||
if (from_iter->item->date < min_commit_date)
|
||||
min_commit_date = from_iter->item->date;
|
||||
|
||||
@ -701,7 +701,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
|
||||
|
||||
while (to_iter) {
|
||||
if (!parse_commit(to_iter->item)) {
|
||||
uint32_t generation;
|
||||
timestamp_t generation;
|
||||
if (to_iter->item->date < min_commit_date)
|
||||
min_commit_date = to_iter->item->date;
|
||||
|
||||
@ -741,13 +741,13 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
|
||||
struct commit_list *found_commits = NULL;
|
||||
struct commit **to_last = to + nr_to;
|
||||
struct commit **from_last = from + nr_from;
|
||||
uint32_t min_generation = GENERATION_NUMBER_INFINITY;
|
||||
timestamp_t min_generation = GENERATION_NUMBER_INFINITY;
|
||||
int num_to_find = 0;
|
||||
|
||||
struct prio_queue queue = { compare_commits_by_gen_then_commit_date };
|
||||
|
||||
for (item = to; item < to_last; item++) {
|
||||
uint32_t generation;
|
||||
timestamp_t generation;
|
||||
struct commit *c = *item;
|
||||
|
||||
parse_commit(c);
|
||||
|
||||
Reference in New Issue
Block a user