From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 2A5151F428 for ; Wed, 15 Mar 2023 17:49:24 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=ejc5w76B; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232664AbjCORqp (ORCPT ); Wed, 15 Mar 2023 13:46:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbjCORqZ (ORCPT ); Wed, 15 Mar 2023 13:46:25 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFDC684F54 for ; Wed, 15 Mar 2023 10:45:55 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id p23-20020a05600c1d9700b003ead4835046so2377719wms.0 for ; Wed, 15 Mar 2023 10:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678902348; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=ofjKpPkVz1iVkizfG/EM1C0RNrO41vW8RqRU6hvCL/A=; b=ejc5w76BByLAvWh5zE4KIKko6u/B7hNkqdwngoIBiCKQqiiLLRPg9GFJdK/bxC54+7 hkcrMCOiWDFaAhYT4UAhst5j923jIW/SoHVxhFbrvVgFRySrHOZ1FF95f4yPL3rEpknt u8LYxfXUKWAmWRyA7wA1KtJx+Hutl4zsG4Vzxx49riPN2Ql+TAhrgNZQvYg3yoQHYkSj YPlWqLJpNi2XadpzVq8Bv9UmtaMkI45AXvku9cV7+oItb+Q6iOsQJMfRkWF0yaTxbOIP m6Gkxs7Owqyyaaj4Gu9Tip3u3fA5lt39Nl0wlkA+HqLDX2Ti12wXq3nzMiOLGzic+S++ 15Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678902348; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ofjKpPkVz1iVkizfG/EM1C0RNrO41vW8RqRU6hvCL/A=; b=iXsk0DHJCXo5cZCj+F8VwEc4BHAiiY091KryExrgHq64X4JxZVbL3JnuOfSQU8qbaf MddZ0ITuDYahyRy70cw4PIpksbKw6ISiYDpRzGTvULYv06zKjE1ACFjGhwi7foCHKmkY eLdkzgoVejpfwk1VnvVrj3DXd0NoPN11pq+zOBh0e9O+RkTrirHTEJoclvWpSn77u2ao g5Ea0hXo0eX/EqkM6urDHidPRcuko1JDA1uYYRPehu/PEqQnSRhlIfjI7RNLwFHyfZcc z/cYt9IRvxA7S/WbSX/kB4aMuIZHRuQ5t6iKU8XT6DtUxMbTu0VtrWyIHHEuA/G118WM CEbw== X-Gm-Message-State: AO0yUKW8acmD7bY3LOfMXJ/YYe5w1jEujsJLubKx3UAwP08C3dawCxT6 nQzq5On9AxrmYVJgGKLkpXKNLisUFOs= X-Google-Smtp-Source: AK7set8PeVCsrW6JA+A/eVU23/kMMPE7LVsQLXRywhVjPW2YnmGzqsfSWlQpVJUubGYX/lnXQ4w7mQ== X-Received: by 2002:a05:600c:3b87:b0:3e2:66b:e90e with SMTP id n7-20020a05600c3b8700b003e2066be90emr18330619wms.10.1678902348004; Wed, 15 Mar 2023 10:45:48 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z4-20020adff744000000b002c55de1c72bsm5289413wrp.62.2023.03.15.10.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 10:45:47 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Taylor Blau via GitGitGadget" Date: Wed, 15 Mar 2023 17:45:40 +0000 Subject: [PATCH v3 5/8] commit-graph: introduce `ensure_generations_valid()` Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, me@ttaylorr.com, vdye@github.com, Jeff King , Phillip Wood , =?UTF-8?Q?=C3=86var_Arnfj=C3=B6r=C3=B0?= Bjarmason , Derrick Stolee , Taylor Blau Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Taylor Blau Use the just-introduced compute_reachable_generation_numbers_1() to implement a function which dynamically computes topological levels (or corrected commit dates) for out-of-graph commits. This will be useful for the ahead-behind algorithm we are about to introduce, which needs accurate topological levels on _all_ commits reachable from the tips in order to avoid over-counting. Co-authored-by: Derrick Stolee Signed-off-by: Taylor Blau Signed-off-by: Derrick Stolee --- commit-graph.c | 29 +++++++++++++++++++++++++++++ commit-graph.h | 8 ++++++++ 2 files changed, 37 insertions(+) diff --git a/commit-graph.c b/commit-graph.c index b4da4e05067..0df8d27afc8 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -1609,6 +1609,35 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx) stop_progress(&ctx->progress); } +static void set_generation_in_graph_data(struct commit *c, timestamp_t t, + void *data) +{ + commit_graph_data_at(c)->generation = t; +} + +/* + * After this method, all commits reachable from those in the given + * list will have non-zero, non-infinite generation numbers. + */ +void ensure_generations_valid(struct repository *r, + struct commit **commits, size_t nr) +{ + int generation_version = get_configured_generation_version(r); + struct packed_commit_list list = { + .list = commits, + .alloc = nr, + .nr = nr, + }; + struct compute_generation_info info = { + .r = r, + .commits = &list, + .get_generation = get_generation_from_graph_data, + .set_generation = set_generation_in_graph_data, + }; + + compute_reachable_generation_numbers_1(&info, generation_version); +} + static void trace2_bloom_filter_write_statistics(struct write_commit_graph_context *ctx) { trace2_data_intmax("commit-graph", ctx->r, "filter-computed", diff --git a/commit-graph.h b/commit-graph.h index 37faee6b66d..73e182ab2d0 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -190,4 +190,12 @@ struct commit_graph_data { */ timestamp_t commit_graph_generation(const struct commit *); uint32_t commit_graph_position(const struct commit *); + +/* + * After this method, all commits reachable from those in the given + * list will have non-zero, non-infinite generation numbers. + */ +void ensure_generations_valid(struct repository *r, + struct commit **commits, size_t nr); + #endif -- gitgitgadget