From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D049DC43463 for ; Fri, 18 Sep 2020 02:59:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9480923119 for ; Fri, 18 Sep 2020 02:59:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20150623.gappssmtp.com header.i=@ttaylorr-com.20150623.gappssmtp.com header.b="ZAOEQhUR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728431AbgIRC7K (ORCPT ); Thu, 17 Sep 2020 22:59:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728975AbgIRC7G (ORCPT ); Thu, 17 Sep 2020 22:59:06 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ED5CC061788 for ; Thu, 17 Sep 2020 19:59:06 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id d20so4665169qka.5 for ; Thu, 17 Sep 2020 19:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QDd5zAw5T0CkEFFw1gGfAUsaq+OCjkuvRbzDJtjonbU=; b=ZAOEQhURb+pyr/icASYrTwbbAVXH7Jl5xzNlIwvSL34HrXZvFR3SidBTJ51W3P4alp HGtqKUD7ry2ytdn8iiVC4fxTU5UEkFOJw2YsTkZyq5JnWF5hYdhkJqx4qUStH2HGRhUk G8QRLUQfjc+lGlScJ57zZsTJDBZiyIUcWGvMzgCIegj+Ecqm4xnm6xFW7DzDwc9yg/ig zds1Vlqp9ZBqq40xlJC7H74AoIjYM7VYFNwPwyQGxoiMQQoPw0AqNt82g8bKRv1eFgP6 VUSIQb/LF4TxVBGAbsiwrWzlGOb/OIAJoAYgiQ4aN8U4cBtc2yC2ArZov6pielWTdAY3 tdNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QDd5zAw5T0CkEFFw1gGfAUsaq+OCjkuvRbzDJtjonbU=; b=FXhjtZ+GwZN0USLEdkgpwW9kB4ByMRPLvNW+933/NFQ5NQSDi78CdyYHiNrWTxSeS7 9L4HmD6N7aL9s7Z1mGyHnHI1aC8/44+fJO163p/TEsmh1W18Vzp0Lr7NTm7IywERCyU7 sXllkci2FEuxJ/4qWtfieUKKX33bjJTugw8ePS3GYJEgOGdn1dlCr6j96q95d0UWYu/H 3/2LOG3MX2zeAfe0uBxNoTWzWzyyUQMLxBL0ZGQ0PZG6XbeMsU9LswnqLPxDHH7SZslz 8XR8vf1oQIagEPfPxhdlwn8e8rrgS9w0ifkXoCsOM5hVYcb4Yc5ySKrpIhBS5b7XhoEt v7tA== X-Gm-Message-State: AOAM533a7uMmvDZwRSjG1H3ty5EECDSonX2d1Q2DNuSjpPIJTFS6pfQh PKwLK4JhLSDyVazpVkNfs17On8FvaJ9Dt2B2 X-Google-Smtp-Source: ABdhPJwc1wCNKiXVNc4Td7e0knKoKYaUQ+yR883gqzYinEDPmVsl1aZi+aG5Fn1jNEhvMqhXInGx1A== X-Received: by 2002:a37:9581:: with SMTP id x123mr30395043qkd.414.1600397945268; Thu, 17 Sep 2020 19:59:05 -0700 (PDT) Received: from localhost ([2605:9480:22e:ff10:2003:d617:ca70:4fd1]) by smtp.gmail.com with ESMTPSA id w44sm1301203qth.9.2020.09.17.19.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 19:59:04 -0700 (PDT) Date: Thu, 17 Sep 2020 22:59:02 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: dstolee@microsoft.com, gitster@pobox.com, peff@peff.net, szeder.dev@gmail.com Subject: [PATCH v3 03/13] commit-graph: pass a 'struct repository *' in more places Message-ID: <1644544221150c6d642b109d38c5607e600153ed.1600397826.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a future commit, some commit-graph internals will want access to 'r->settings', but we only have the 'struct object_directory *' corresponding to that repository. Add an additional parameter to pass the repository around in more places. Signed-off-by: Taylor Blau Signed-off-by: Junio C Hamano --- builtin/commit-graph.c | 2 +- commit-graph.c | 17 ++++++++++------- commit-graph.h | 6 ++++-- fuzz-commit-graph.c | 5 +++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 523501f217..ba5584463f 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -106,7 +106,7 @@ static int graph_verify(int argc, const char **argv) FREE_AND_NULL(graph_name); if (open_ok) - graph = load_commit_graph_one_fd_st(fd, &st, odb); + graph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb); else graph = read_commit_graph_one(the_repository, odb); diff --git a/commit-graph.c b/commit-graph.c index 6a36ed0b06..72a838bd00 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -231,7 +231,8 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st) return 1; } -struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st, +struct commit_graph *load_commit_graph_one_fd_st(struct repository *r, + int fd, struct stat *st, struct object_directory *odb) { void *graph_map; @@ -247,7 +248,7 @@ struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st, } graph_map = xmmap(NULL, graph_size, PROT_READ, MAP_PRIVATE, fd, 0); close(fd); - ret = parse_commit_graph(graph_map, graph_size); + ret = parse_commit_graph(r, graph_map, graph_size); if (ret) ret->odb = odb; @@ -287,7 +288,8 @@ static int verify_commit_graph_lite(struct commit_graph *g) return 0; } -struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size) +struct commit_graph *parse_commit_graph(struct repository *r, + void *graph_map, size_t graph_size) { const unsigned char *data, *chunk_lookup; uint32_t i; @@ -452,7 +454,8 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size) return NULL; } -static struct commit_graph *load_commit_graph_one(const char *graph_file, +static struct commit_graph *load_commit_graph_one(struct repository *r, + const char *graph_file, struct object_directory *odb) { @@ -464,7 +467,7 @@ static struct commit_graph *load_commit_graph_one(const char *graph_file, if (!open_ok) return NULL; - g = load_commit_graph_one_fd_st(fd, &st, odb); + g = load_commit_graph_one_fd_st(r, fd, &st, odb); if (g) g->filename = xstrdup(graph_file); @@ -476,7 +479,7 @@ static struct commit_graph *load_commit_graph_v1(struct repository *r, struct object_directory *odb) { char *graph_name = get_commit_graph_filename(odb); - struct commit_graph *g = load_commit_graph_one(graph_name, odb); + struct commit_graph *g = load_commit_graph_one(r, graph_name, odb); free(graph_name); return g; @@ -557,7 +560,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r, valid = 0; for (odb = r->objects->odb; odb; odb = odb->next) { char *graph_name = get_split_graph_filename(odb, line.buf); - struct commit_graph *g = load_commit_graph_one(graph_name, odb); + struct commit_graph *g = load_commit_graph_one(r, graph_name, odb); free(graph_name); diff --git a/commit-graph.h b/commit-graph.h index 0677dd1031..d9acb22bac 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -75,11 +75,13 @@ struct commit_graph { struct bloom_filter_settings *bloom_filter_settings; }; -struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st, +struct commit_graph *load_commit_graph_one_fd_st(struct repository *r, + int fd, struct stat *st, struct object_directory *odb); struct commit_graph *read_commit_graph_one(struct repository *r, struct object_directory *odb); -struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size); +struct commit_graph *parse_commit_graph(struct repository *r, + void *graph_map, size_t graph_size); /* * Return 1 if and only if the repository has a commit-graph diff --git a/fuzz-commit-graph.c b/fuzz-commit-graph.c index 430817214d..e7cf6d5b0f 100644 --- a/fuzz-commit-graph.c +++ b/fuzz-commit-graph.c @@ -1,7 +1,8 @@ #include "commit-graph.h" #include "repository.h" -struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size); +struct commit_graph *parse_commit_graph(struct repository *r, + void *graph_map, size_t graph_size); int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); @@ -10,7 +11,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) struct commit_graph *g; initialize_the_repository(); - g = parse_commit_graph((void *)data, size); + g = parse_commit_graph(the_repository, (void *)data, size); repo_clear(the_repository); free_commit_graph(g); -- 2.28.0.510.g375ecf1f36