From patchwork Tue Mar 22 17:28:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12788843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D4D7C433F5 for ; Tue, 22 Mar 2022 17:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239736AbiCVRaS (ORCPT ); Tue, 22 Mar 2022 13:30:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235913AbiCVRaM (ORCPT ); Tue, 22 Mar 2022 13:30:12 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CFD8E39 for ; Tue, 22 Mar 2022 10:28:43 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id m30so14592279wrb.1 for ; Tue, 22 Mar 2022 10:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=jm3MEfd6YOUjgSif2gdO+IzGaNt3BFBtqV9gV65PpGI=; b=kHgw63AQg3o+9J5pI9exwKxkOjFYC42PgjWhULZPU9KFizuhESr8ZyASEJxpMS7Kvu yWcjf1lri834TKjbrmHXmRIBe9ZjSsgnA7q70UJkgdt3xnFwfsoB8z4ZEETW+OsDUC3L A+tWvvnfG1snZw5OUvdYB1vZYcdlLugEXDuPYATbbCoNjtpXwy6DTYZt6GTBiKdEj78b cAN/1JBwKhiJibSEq8KwJvB8zIfkx1Od1BmtNYAiIwq+wERLSjTr79dqkgQk6D6nH0mY 6adl2lIVvT4UNJWThl8mHoqmxr7nznNrMhuEG8WzUP86uugaQfOXxwPVcERPyJFTtuC0 W5xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=jm3MEfd6YOUjgSif2gdO+IzGaNt3BFBtqV9gV65PpGI=; b=HojuyQ7uxEC6c111CxlWmzejY8quRJlkfZzTJSqDWCZbtU3NmJiLBMGXGyJFuuU736 7Sipc/kUdb3TRjI1Hv0pSHpq+UCLxa60ISWP6fNOBjMKI1bHatqFPPrHt2Vl8DXfngAi xzmGp1gzs/Kg2S3ZsKksjGf6FcxPUHSGJzLH0T50qaBLDWIs/HBcY8h5hW3jb2do4/1A qM2aY/ZEPIoa1LYQ7DhdpDz0RaqbnV6N4XfGhr+XzwmaNFI3BnZ+pDzvoJ+B/4qu1b7m 91LH7buYDGVPrEC+hsQRbAiK2Xbq/Aj0ey7X0yJg59kCMTLtGv9OvYKk2AdU5F5W+6XA c6Ig== X-Gm-Message-State: AOAM533ixQQlz7Zgz4hMSTi8ZTErh0WqLVpcTLv/ZhT2a7xEe/Lq7qTX /vVV/dQh08qQX7jZSsPR4DWQgBwgyYs= X-Google-Smtp-Source: ABdhPJxWjf9QJONQd9tAHkoQrPgjYjLLbhEsHki3Blpak2hkHP6IhfyROVlGMZAcW0DRRVmWSL+JqA== X-Received: by 2002:a05:6000:2a7:b0:205:8031:bfee with SMTP id l7-20020a05600002a700b002058031bfeemr1482220wry.117.1647970121977; Tue, 22 Mar 2022 10:28:41 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v14-20020a7bcb4e000000b0034492fa24c6sm2309173wmj.34.2022.03.22.10.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 10:28:41 -0700 (PDT) Message-Id: <166d86fd7009a8a1b82a4157cb718a6a4a527a0c.1647970119.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 22 Mar 2022 17:28:35 +0000 Subject: [PATCH 1/5] list-objects-filter: remove CL_ARG__FILTER Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, avarab@gmail.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee We have established the command-line interface for the --[no-]filter options for a while now, so we do not need a helper to make this editable in the future. Signed-off-by: Derrick Stolee --- builtin/fetch-pack.c | 4 ++-- list-objects-filter-options.h | 5 +---- revision.c | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index c2d96f4c89a..c4b9104f9b5 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -153,11 +153,11 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) args.from_promisor = 1; continue; } - if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) { + if (skip_prefix(arg, ("--filter="), &arg)) { parse_list_objects_filter(&args.filter_options, arg); continue; } - if (!strcmp(arg, ("--no-" CL_ARG__FILTER))) { + if (!strcmp(arg, ("--no-filter"))) { list_objects_filter_set_no_filter(&args.filter_options); continue; } diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h index 2eb6c983949..90e4bc96252 100644 --- a/list-objects-filter-options.h +++ b/list-objects-filter-options.h @@ -69,9 +69,6 @@ struct list_objects_filter_options { */ }; -/* Normalized command line arguments */ -#define CL_ARG__FILTER "filter" - /* * Parse value of the argument to the "filter" keyword. * On the command line this looks like: @@ -111,7 +108,7 @@ int opt_parse_list_objects_filter(const struct option *opt, const char *arg, int unset); #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \ - OPT_CALLBACK(0, CL_ARG__FILTER, fo, N_("args"), \ + OPT_CALLBACK(0, "filter", fo, N_("args"), \ N_("object filtering"), \ opt_parse_list_objects_filter) diff --git a/revision.c b/revision.c index 2646b78990e..7d435f80480 100644 --- a/revision.c +++ b/revision.c @@ -2691,9 +2691,9 @@ static int handle_revision_pseudo_opt(struct rev_info *revs, revs->no_walk = 0; } else if (!strcmp(arg, "--single-worktree")) { revs->single_worktree = 1; - } else if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) { + } else if (skip_prefix(arg, ("--filter="), &arg)) { parse_list_objects_filter(&revs->filter, arg); - } else if (!strcmp(arg, ("--no-" CL_ARG__FILTER))) { + } else if (!strcmp(arg, ("--no-filter"))) { list_objects_filter_set_no_filter(&revs->filter); } else { return 0; From patchwork Tue Mar 22 17:28:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12788841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8677EC433F5 for ; Tue, 22 Mar 2022 17:28:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239715AbiCVRaO (ORCPT ); Tue, 22 Mar 2022 13:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239712AbiCVRaM (ORCPT ); Tue, 22 Mar 2022 13:30:12 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B178365E7 for ; Tue, 22 Mar 2022 10:28:44 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id u3so1308255wrg.3 for ; Tue, 22 Mar 2022 10:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=wP6hj1eM5IDvWMDV7fFtEtoYk1XgcQDJMMe99buLEZg=; b=KIt3NAMllWU2cTHGFAVcIVp0GVHcpgKnYb5EZtRuagEUr5lAeOreZPgYPAylpCItFY st+RPq3gPeCpQyk6IrmNiJxiV3gjALkscTo9oj1aY71dbEFpHfmStRPUiQU1vEBDkFuS TN0uVzmp3SngfPDi9R1r7f8ySOuPKTlfeQk6V8UgQOA3fsmQbu0t4SN+eW6WhwahiLNf xlvgXJrE9NkYJE/OzPikSMl3TegaWotARWGC58h6oTN8qOSryjQncyLPFZCvGF0lhxk1 F08kQmkTtBc00Y8KQq/D3PQW0h3mE+S8ztu2sP4z4Lq+4WgP9iqZebtt3XAYCXDxLWsx xI2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=wP6hj1eM5IDvWMDV7fFtEtoYk1XgcQDJMMe99buLEZg=; b=yIxJBc0ja56kcny+0reuga3SzY+Df41XoiP7gZJCqtQU1S8OKIpU55D9iXvl4ZI2bu TXJLpCOVraHysekhfSWg2rxfYn0+Ok+2Q2I4VF1m1CQsn1MGSLjeQbBDr2zdvlPk9z6S JUWo79D3JzFtVkRBbG6R5QxFHDhjWo03KCnrkMT1r89iWOjJBO2GSSGb7SXjRLN4zDZ+ m/HyEygBrM532Ropbgw7ukOL2Fy7iCUF2jMyWL1K1ZphWI1jNaxeXvSn2N4BzqI0jAwG QVMrOZoknc2xFUFmV2N+ncw2361Ad/EE9rWsCM0+xffNSJmRCVw66BfXMFfQckyZRxlX XVxA== X-Gm-Message-State: AOAM532KoQwCXicYymtFwrOj7cv7Erh0GejcfY6q29y78T5OoI3Uarz8 pw3gpV9/c90B7hBWQjkT4ObQFPChyNo= X-Google-Smtp-Source: ABdhPJxT/h9rimP806LOOCgubgFeeXYpiCJtzlfFX+aaozP79W9Await8PPyld69QZnmbfB+YFZhWg== X-Received: by 2002:a5d:5987:0:b0:204:1f21:6a29 with SMTP id n7-20020a5d5987000000b002041f216a29mr5596524wri.716.1647970122943; Tue, 22 Mar 2022 10:28:42 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g5-20020a5d64e5000000b00203914f5313sm16184676wri.114.2022.03.22.10.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 10:28:42 -0700 (PDT) Message-Id: <619b757d98465dbc4995bdc11a5282fbfcbd3daa.1647970119.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 22 Mar 2022 17:28:36 +0000 Subject: [PATCH 2/5] pack-objects: move revs out of get_object_list() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, avarab@gmail.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee We intend to parse the --filter option directly into revs.filter, but we first need to move the 'revs' variable out of get_object_list() and pass it as a pointer instead. This change only deals with the issues of making that work. Signed-off-by: Derrick Stolee --- builtin/pack-objects.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 829ca359cf9..f29bef9d0b6 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3714,9 +3714,8 @@ static void mark_bitmap_preferred_tips(void) } } -static void get_object_list(int ac, const char **av) +static void get_object_list(struct rev_info *revs, int ac, const char **av) { - struct rev_info revs; struct setup_revision_opt s_r_opt = { .allow_exclude_promisor_objects = 1, }; @@ -3724,10 +3723,10 @@ static void get_object_list(int ac, const char **av) int flags = 0; int save_warning; - repo_init_revisions(the_repository, &revs, NULL); + repo_init_revisions(the_repository, revs, NULL); save_commit_buffer = 0; - setup_revisions(ac, av, &revs, &s_r_opt); - list_objects_filter_copy(&revs.filter, &filter_options); + setup_revisions(ac, av, revs, &s_r_opt); + list_objects_filter_copy(&revs->filter, &filter_options); /* make sure shallows are read */ is_repository_shallow(the_repository); @@ -3757,13 +3756,13 @@ static void get_object_list(int ac, const char **av) } die(_("not a rev '%s'"), line); } - if (handle_revision_arg(line, &revs, flags, REVARG_CANNOT_BE_FILENAME)) + if (handle_revision_arg(line, revs, flags, REVARG_CANNOT_BE_FILENAME)) die(_("bad revision '%s'"), line); } warn_on_object_refname_ambiguity = save_warning; - if (use_bitmap_index && !get_object_list_from_bitmap(&revs)) + if (use_bitmap_index && !get_object_list_from_bitmap(revs)) return; if (use_delta_islands) @@ -3772,24 +3771,24 @@ static void get_object_list(int ac, const char **av) if (write_bitmap_index) mark_bitmap_preferred_tips(); - if (prepare_revision_walk(&revs)) + if (prepare_revision_walk(revs)) die(_("revision walk setup failed")); - mark_edges_uninteresting(&revs, show_edge, sparse); + mark_edges_uninteresting(revs, show_edge, sparse); if (!fn_show_object) fn_show_object = show_object; - traverse_commit_list(&revs, + traverse_commit_list(revs, show_commit, fn_show_object, NULL); if (unpack_unreachable_expiration) { - revs.ignore_missing_links = 1; - if (add_unseen_recent_objects_to_traversal(&revs, + revs->ignore_missing_links = 1; + if (add_unseen_recent_objects_to_traversal(revs, unpack_unreachable_expiration)) die(_("unable to add recent objects")); - if (prepare_revision_walk(&revs)) + if (prepare_revision_walk(revs)) die(_("revision walk setup failed")); - traverse_commit_list(&revs, record_recent_commit, + traverse_commit_list(revs, record_recent_commit, record_recent_object, NULL); } @@ -3872,6 +3871,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) int rev_list_index = 0; int stdin_packs = 0; struct string_list keep_pack_list = STRING_LIST_INIT_NODUP; + struct rev_info revs; + struct option pack_objects_options[] = { OPT_SET_INT('q', "quiet", &progress, N_("do not show progress meter"), 0), @@ -3976,6 +3977,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) read_replace_refs = 0; + repo_init_revisions(the_repository, &revs, NULL); + sparse = git_env_bool("GIT_TEST_PACK_SPARSE", -1); if (the_repository->gitdir) { prepare_repo_settings(the_repository); @@ -4154,7 +4157,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) } else if (!use_internal_rev_list) { read_object_list_from_stdin(); } else { - get_object_list(rp.nr, rp.v); + get_object_list(&revs, rp.nr, rp.v); } cleanup_preferred_base(); if (include_tag && nr_result) From patchwork Tue Mar 22 17:28:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12788844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB134C433EF for ; Tue, 22 Mar 2022 17:28:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239739AbiCVRaU (ORCPT ); Tue, 22 Mar 2022 13:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239718AbiCVRaO (ORCPT ); Tue, 22 Mar 2022 13:30:14 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9516E65EB for ; Tue, 22 Mar 2022 10:28:45 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id u3so1308322wrg.3 for ; Tue, 22 Mar 2022 10:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ZZwdbmza6VzHoo8DhGH6ETA/M7qBT77r0dOdZfqRQ1g=; b=b/P1bS+5m8TrBPZ4jZt0AV44RE35UURbnfTye+svhLP4r9Vr43ie6V4xgS/xxN0fe2 oZL9UqfvwWD+iccPsgcnTRDivQBJYMcH6tM5BBJlqynWpA4Wu4uLfRcN8D7K5kX1dhdD AJxfo4SNSNOtmHHTWANavHV1Es5ML/eQDDwnPcceOVxqtGFcB+hU9yqRGN5oDlxA2jwf OWHEDWYTMw/gQX+AiXB1kbO4a4LThwcbbC32GEYst2ddJ/78S+YT96K2xYghV1GN/Ao8 RQqSdBLaaJFPjTdSHGSpZJeJ1X+GXSD8d9UREgMq4odCjBYHbZBEUKhYCkMbgTIBVt+B o9KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ZZwdbmza6VzHoo8DhGH6ETA/M7qBT77r0dOdZfqRQ1g=; b=im9BERUjw1+OlTthLeCg5uD6F9yUGCZQbm48ULkuoEBNYCzNEBsS+Yv7F80NRySBLJ JT5KAgzgzZ90RZe3WzogCVUbUJxuO4FAd4bKQuYkmrt/LJDMC0zQUzzCOV1x0S5w43bn CQ9OG0+rkvr040j36906Pa59jeQzuQVWkg0hL4zwiontN/O2LUihPvc2K0BVeflqWcfQ SUKn7WwUnd6UUf/+99YDBsC47D27eZJ1J78qW6wnV5lxpetyER291xUoPAcGDaIbjBsa QLKBBjspR3/jGywVouCYLjdgDWe3flPz6IxqagtbMlTnATbszqUTa1ZZPq/F4/0zNlqt /i4w== X-Gm-Message-State: AOAM530+SYepmIKDjgBE4MD6vq8KoTC1iCXP7HYpgdzhVx2Mp8xfXCta 2BriB0WTiS9rv7R9GTQ4dziaV9Qqre8= X-Google-Smtp-Source: ABdhPJyN/rTPRbdk1sazD/OpT1k4oAj9F1ZeZxKdGcPMtgrFEuB6KQVW6z2m9DMTsULkcSB/NEiJUQ== X-Received: by 2002:a05:6000:144e:b0:203:e36c:74b3 with SMTP id v14-20020a056000144e00b00203e36c74b3mr24104660wrx.565.1647970123970; Tue, 22 Mar 2022 10:28:43 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n124-20020a1ca482000000b0038c9cf6e296sm3259368wme.14.2022.03.22.10.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 10:28:43 -0700 (PDT) Message-Id: <97de926904988b89b5663bd4c59c011a1723a8f5.1647970119.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 22 Mar 2022 17:28:37 +0000 Subject: [PATCH 3/5] pack-objects: parse --filter directly into revs.filter Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, avarab@gmail.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The previous change moved the 'revs' variable into cmd_pack_objects() and now we can remote the global filter_options in favor of revs.filter. Signed-off-by: Derrick Stolee --- builtin/pack-objects.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index f29bef9d0b6..d39f668ad56 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -237,8 +237,6 @@ static unsigned long cache_max_small_delta_size = 1000; static unsigned long window_memory_limit = 0; -static struct list_objects_filter_options filter_options; - static struct string_list uri_protocols = STRING_LIST_INIT_NODUP; enum missing_action { @@ -3723,10 +3721,8 @@ static void get_object_list(struct rev_info *revs, int ac, const char **av) int flags = 0; int save_warning; - repo_init_revisions(the_repository, revs, NULL); save_commit_buffer = 0; setup_revisions(ac, av, revs, &s_r_opt); - list_objects_filter_copy(&revs->filter, &filter_options); /* make sure shallows are read */ is_repository_shallow(the_repository); @@ -3958,7 +3954,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) &write_bitmap_index, N_("write a bitmap index if possible"), WRITE_BITMAP_QUIET, PARSE_OPT_HIDDEN), - OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options), + OPT_PARSE_LIST_OBJECTS_FILTER(&revs.filter), OPT_CALLBACK_F(0, "missing", NULL, N_("action"), N_("handling for missing objects"), PARSE_OPT_NONEG, option_parse_missing_action), @@ -4080,7 +4076,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) if (!rev_list_all || !rev_list_reflog || !rev_list_index) unpack_unreachable_expiration = 0; - if (filter_options.choice) { + if (revs.filter.choice) { if (!pack_to_stdout) die(_("cannot use --filter without --stdout")); if (stdin_packs) From patchwork Tue Mar 22 17:28:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12788846 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70E0DC433F5 for ; Tue, 22 Mar 2022 17:29:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239752AbiCVRaZ (ORCPT ); Tue, 22 Mar 2022 13:30:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239735AbiCVRaR (ORCPT ); Tue, 22 Mar 2022 13:30:17 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57ED1E39 for ; Tue, 22 Mar 2022 10:28:47 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id bg31-20020a05600c3c9f00b00381590dbb33so2383892wmb.3 for ; Tue, 22 Mar 2022 10:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=lL7IRR3IAXAd1hNj4pTPG7N19dM5VsQBYzO3xGDzQAg=; b=lBtu910OjSRmMRnKAFe0+iUwygFwRxH4kOTDjuAkov5xMl8nkNkRCNVwgJo5i4B48/ +oRsas+2rZralrgVzuQzcPdCJog87vgOFeIez/K68YxChR3VwetEIy2Gx6fnFNIcKMHR GZQCT12SQw52X8beLYKmMYE44mOcoojd+bXWfW6AJ23+0zWTN+TecugmyogrZP8QTNsc Kr1xZhqpdTDX0wtObidAqhy6aww4AymwBf+ohX+YH2y9BDp2iiwePW01G3kShI9Z/dy8 gSF9AgzhO3jC+wLWpgovz184WjB2fjO7BGRv1+AFrwFbDk+nAqjJBVHKVroBLB5gsdKI MFWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=lL7IRR3IAXAd1hNj4pTPG7N19dM5VsQBYzO3xGDzQAg=; b=w6tHSXR4YGLn7gbDzqzG4WrXpcAI4+gLYPywqa6YoiDdX/I91i+L/9le2gRUqjm7oB 9Dwq/zwGo2DBCAH97xlhfmt8O2mZYuBhcS7ieaZ7r+5HDzAhxKIlTRIWmZZTrHuoXFnB I776ZUWIrHWZv1gL47U2uIdJfvrbl+BfY770D7uiZ0E0Lbk3AhspnVrj5Z1su9zK784K fhFiMYppNVuoJQt1oK/4eMAgeBAEMeYHfC+SNXiclW+nJtYsp0YF+ZI/57prvH2HHFrL 0ghv/PdJvSFhCn69999VvjdT/RWSm1gkue2MihdvrhZixiYqGrNgCnBYU4IDqs9zb6zb n4yg== X-Gm-Message-State: AOAM533GXFufwBnG7hF/vJGo6ylnGYueOeK9GN3BR6l0IEJ6i5xRsMim buPSV8Fc+SAcOC0cArWQz42zsjbMi7M= X-Google-Smtp-Source: ABdhPJwMHOat20ajSbcvI3dEcZsoPJJKESLWslC94qiJwqNsvxpRGNWAVEEavFmdQJVxUsUfcL4Emw== X-Received: by 2002:a05:600c:4f89:b0:38c:bd13:e03f with SMTP id n9-20020a05600c4f8900b0038cbd13e03fmr2797442wmq.117.1647970125490; Tue, 22 Mar 2022 10:28:45 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g5-20020a5d64e5000000b00203914f5313sm16184732wri.114.2022.03.22.10.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 10:28:44 -0700 (PDT) Message-Id: <1b2130426bd7bd6c0bf5c56be2bf66a4d81f0b27.1647970119.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 22 Mar 2022 17:28:38 +0000 Subject: [PATCH 4/5] bundle: move capabilities to end of 'verify' Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, avarab@gmail.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The 'filter' capability was added in 105c6f14a (bundle: parse filter capability, 2022-03-09), but was added in a strange place in the 'git bundle verify' output. The tests for this show output like the following: The bundle contains these 2 refs: The bundle uses this filter: blob:none The bundle records a complete history. This looks very odd if we have a thin bundle that contains boundary commits instead of a complete history: The bundle contains these 2 refs: The bundle uses this filter: blob:none The bundle requires these 2 refs: This separation between tip refs and boundary refs is unfortunate. Move the filter capability output to the end of the output. Update the documentation to match. Signed-off-by: Derrick Stolee --- Documentation/git-bundle.txt | 10 +++++----- bundle.c | 9 ++++----- t/t6020-bundle-misc.sh | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt index ac4c4352aae..7685b570455 100644 --- a/Documentation/git-bundle.txt +++ b/Documentation/git-bundle.txt @@ -75,11 +75,11 @@ verify :: cleanly to the current repository. This includes checks on the bundle format itself as well as checking that the prerequisite commits exist and are fully linked in the current repository. - Information about additional capabilities, such as "object filter", - is printed. See "Capabilities" in link:technical/bundle-format.html - for more information. Finally, 'git bundle' prints a list of - missing commits, if any. The exit code is zero for success, but - will be nonzero if the bundle file is invalid. + Then, 'git bundle' prints a list of missing commits, if any. + Finally, information about additional capabilities, such as "object + filter", is printed. See "Capabilities" in link:technical/bundle-format.html + for more information. The exit code is zero for success, but will + be nonzero if the bundle file is invalid. list-heads :: Lists the references defined in the bundle. If followed by a diff --git a/bundle.c b/bundle.c index e359370cfcd..276b55f8ce2 100644 --- a/bundle.c +++ b/bundle.c @@ -267,11 +267,6 @@ int verify_bundle(struct repository *r, (uintmax_t)r->nr); list_refs(r, 0, NULL); - if (header->filter.choice) { - printf_ln("The bundle uses this filter: %s", - list_objects_filter_spec(&header->filter)); - } - r = &header->prerequisites; if (!r->nr) { printf_ln(_("The bundle records a complete history.")); @@ -282,6 +277,10 @@ int verify_bundle(struct repository *r, (uintmax_t)r->nr); list_refs(r, 0, NULL); } + + if (header->filter.choice) + printf_ln("The bundle uses this filter: %s", + list_objects_filter_spec(&header->filter)); } return ret; } diff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh index ed95d195427..c4ab1367afc 100755 --- a/t/t6020-bundle-misc.sh +++ b/t/t6020-bundle-misc.sh @@ -510,8 +510,8 @@ do refs/tags/v2 refs/tags/v3 HEAD - The bundle uses this filter: $filter The bundle records a complete history. + The bundle uses this filter: $filter EOF test_cmp expect actual && From patchwork Tue Mar 22 17:28:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12788845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5ED63C433EF for ; Tue, 22 Mar 2022 17:28:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239749AbiCVRaY (ORCPT ); Tue, 22 Mar 2022 13:30:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239734AbiCVRaR (ORCPT ); Tue, 22 Mar 2022 13:30:17 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FDB365C0 for ; Tue, 22 Mar 2022 10:28:48 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id i186so2385477wma.3 for ; Tue, 22 Mar 2022 10:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=xAr9PF28yZSi7PsaTPcsSOpQPfWmKCXhkTZW1DnpfOs=; b=YSYeF+ILqDDviWeT7oa0W55UwFJ13x5JA8mAyctiZXxjNUC4/VKxtuxtwc4plqHjnH Xbo53RrptDvos3uv6+hodYbHqKDVrZNfa/nowlMGb4pkuzyi0Jbw6/cNzfhJHRpoJnD6 +/jMQMWZgR4D4p+I27NzlGboSQYitEkCG8RJ/QG/85iru8zz3SWejPBQlw99ZKGsQHJc 4YlTrY9l4baogTFRlMQ2GvpTGkGgjPvKT474BwPz95NS7RjU1py0WpzYZjta5HyXxRoX IqJOBkO9Fqwj6tPXAwVYOWoR3cj1tC2KjkScrlfpxomX3IE5jGvrPWa+dseh/Em308ks 4rwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=xAr9PF28yZSi7PsaTPcsSOpQPfWmKCXhkTZW1DnpfOs=; b=WR+70KQW7C98Gnox55Xoc2CeJIoxGcaCfbMZs6ankfnCYjpmobEL0RXAq0dP3z0fqN +X+d9JVqZr/nVVlSxQndRk9nLi6m26FCjIwETjvl1JqT6sjGhrlDep1h2WGn2cet6IA9 5MAkxUfnVAGO51jcWz40/L95+xyRTq2Vqp5z+GTOq5LAC0C+BQz0ozZZq974tldZ/5E3 N4M2npWsSDh7+7R345eBNJMBh7bwEj9arRBMY3aaLRRA4Dk9GgTDwzs1DMttqmV1M5U6 PDD2e/wyxCfbs0jIyU6sX3bRJE/7C0ZSdTRsfoBCdDxoIvRXPhbpXktJx5DN9D8dalTw rk4g== X-Gm-Message-State: AOAM533/skW0FRebMacsCZ7GvIOlFplBEDBqpt1BiGC4J/4t6Kp2aMI5 pevokGF4kqCHAt+NEmaUTrKb/I8Nq6c= X-Google-Smtp-Source: ABdhPJxbkMGAKwCz5Y0ExfNe1cWjmrwSPHNc6MJiv5ulY998lYMmnp0sgW9BVIWL3KPTwTcA0wtqWQ== X-Received: by 2002:a1c:2744:0:b0:382:a9b7:1c8a with SMTP id n65-20020a1c2744000000b00382a9b71c8amr4771786wmn.187.1647970126453; Tue, 22 Mar 2022 10:28:46 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d1-20020adffbc1000000b00203de0fff63sm16305223wrs.70.2022.03.22.10.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 10:28:46 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 22 Mar 2022 17:28:39 +0000 Subject: [PATCH 5/5] bundle: output hash information in 'verify' Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, avarab@gmail.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The previous change moved the 'filter' capability to the end of the 'git bundle verify' output. Now, add the 'object-format' capability to the output, when it exists. This change makes 'git bundle verify' output the hash used in all cases, even if the capability is not in the bundle. This means that v2 bundles will always output that they use "sha1". This might look noisy to some users, but it does simplify the implementation and the test strategy for this feature. Since 'verify' ends early when a prerequisite commit is missing, we need to insert this hash message carefully into our expected test output throughout t6020. Signed-off-by: Derrick Stolee --- bundle.c | 2 ++ t/t6020-bundle-misc.sh | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/bundle.c b/bundle.c index 276b55f8ce2..d50cfb5aa7e 100644 --- a/bundle.c +++ b/bundle.c @@ -278,6 +278,8 @@ int verify_bundle(struct repository *r, list_refs(r, 0, NULL); } + printf_ln("The bundle uses this hash algorithm: %s", + header->hash_algo->name); if (header->filter.choice) printf_ln("The bundle uses this filter: %s", list_objects_filter_spec(&header->filter)); diff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh index c4ab1367afc..833205125ab 100755 --- a/t/t6020-bundle-misc.sh +++ b/t/t6020-bundle-misc.sh @@ -122,6 +122,8 @@ format_and_save_expect () { sed -e 's/Z$//' >expect } +HASH_MESSAGE="The bundle uses this hash algorithm: $GIT_DEFAULT_HASH" + # (C) (D, pull/1/head, topic/1) # o --- o # / \ (L) @@ -194,11 +196,12 @@ test_expect_success 'create bundle from special rev: main^!' ' git bundle verify special-rev.bdl | make_user_friendly_and_stable_output >actual && - format_and_save_expect <<-\EOF && + format_and_save_expect <<-EOF && The bundle contains this ref: refs/heads/main The bundle requires this ref: Z + $HASH_MESSAGE EOF test_cmp expect actual && @@ -215,12 +218,13 @@ test_expect_success 'create bundle with --max-count option' ' git bundle verify max-count.bdl | make_user_friendly_and_stable_output >actual && - format_and_save_expect <<-\EOF && + format_and_save_expect <<-EOF && The bundle contains these 2 refs: refs/heads/main refs/tags/v1 The bundle requires this ref: Z + $HASH_MESSAGE EOF test_cmp expect actual && @@ -240,7 +244,7 @@ test_expect_success 'create bundle with --since option' ' git bundle verify since.bdl | make_user_friendly_and_stable_output >actual && - format_and_save_expect <<-\EOF && + format_and_save_expect <<-EOF && The bundle contains these 5 refs: refs/heads/main refs/heads/release @@ -250,6 +254,7 @@ test_expect_success 'create bundle with --since option' ' The bundle requires these 2 refs: Z Z + $HASH_MESSAGE EOF test_cmp expect actual && @@ -267,11 +272,12 @@ test_expect_success 'create bundle 1 - no prerequisites' ' EOF git bundle create stdin-1.bdl --stdin expect <<-\EOF && + format_and_save_expect <<-EOF && The bundle contains these 2 refs: refs/heads/topic/1 refs/heads/topic/2 The bundle records a complete history. + $HASH_MESSAGE EOF # verify bundle, which has no prerequisites @@ -308,13 +314,14 @@ test_expect_success 'create bundle 2 - has prerequisites' ' --stdin \ release refs/heads/release The bundle requires these 3 refs: Z Z Z + $HASH_MESSAGE EOF git bundle verify 2.bdl | @@ -367,13 +374,14 @@ test_expect_success 'create bundle 3 - two refs, same object' ' --stdin \ main HEAD refs/heads/main HEAD The bundle requires these 2 refs: Z Z + $HASH_MESSAGE EOF git bundle verify 3.bdl | @@ -409,12 +417,13 @@ test_expect_success 'create bundle 4 - with tags' ' --stdin \ --all expect <<-\EOF && + cat >expect <<-EOF && The bundle contains these 3 refs: refs/tags/v1 refs/tags/v2 refs/tags/v3 The bundle records a complete history. + $HASH_MESSAGE EOF git bundle verify 4.bdl | @@ -511,6 +520,7 @@ do refs/tags/v3 HEAD The bundle records a complete history. + $HASH_MESSAGE The bundle uses this filter: $filter EOF test_cmp expect actual &&