Re: [PATCH v2 06/10] commit.c: use generation to halt paint walk
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 11, 2018, 03:02 UTC
- Message-ID
- <xmqq604yzbqe.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180409164131.37312-7-dstolee@microsoft.com>
Derrick Stolee <dstolee@microsoft.com> writes:
Show 31 quoted lines
> @@ -800,17 +810,26 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n, struc
> return result;
> }
> prio_queue_put(&queue, one);
> + if (one->generation < min_nonstale_gen)
> + min_nonstale_gen = one->generation;
>
> for (i = 0; i < n; i++) {
> twos[i]->object.flags |= PARENT2;
> prio_queue_put(&queue, twos[i]);
> + if (twos[i]->generation < min_nonstale_gen)
> + min_nonstale_gen = twos[i]->generation;
> }
>
> - while (queue_has_nonstale(&queue)) {
> + while (queue_has_nonstale(&queue, min_nonstale_gen)) {
> struct commit *commit = prio_queue_get(&queue);
> struct commit_list *parents;
> int flags;
>
> + if (commit->generation > last_gen)
> + BUG("bad generation skip");
> +
> + last_gen = commit->generation;
> +
> flags = commit->object.flags & (PARENT1 | PARENT2 | STALE);
> if (flags == (PARENT1 | PARENT2)) {
> if (!(commit->object.flags & RESULT)) {
> @@ -830,6 +849,10 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n, struc
> return NULL;
> p->object.flags |= flags;Hmph. Can a commit that used to be not stale (and contributed to the current value of min_nonstale_gen) become stale here by getting visited twice, invalidating the value in min_nonstale_gen?
Show 7 quoted lines
> prio_queue_put(&queue, p); > + > + if (!(flags & STALE) && > + p->generation < min_nonstale_gen) > + min_nonstale_gen = p->generation; > } > }