From patchwork Mon Apr 17 20:54:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13214705 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 84BC4C77B78 for ; Mon, 17 Apr 2023 20:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbjDQU44 (ORCPT ); Mon, 17 Apr 2023 16:56:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231184AbjDQU4l (ORCPT ); Mon, 17 Apr 2023 16:56:41 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D3EC648 for ; Mon, 17 Apr 2023 13:54:28 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-54fb615ac3dso219273367b3.2 for ; Mon, 17 Apr 2023 13:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20221208.gappssmtp.com; s=20221208; t=1681764857; x=1684356857; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=wEoLssQdCNMXu2B6skyMInK1O7b8/2PI/cmR41Be7RU=; b=NcnMv58NbqaqsNVAbSOS/Zz9yBK0pBnDEyj5q7F9mBrClUV7JCf+CezyvMszJG5C8r 63bmEww3GNpIvPSNgCTS2PJ5BgPiF8TXaxDdvbaJVO/wK7q7UuBYW9nKJOmUfDxS/zeG WMGN9XOyTBSIvb3F6Omr1j2OnCZOht2dMUPoG8QdpB0z/wFrlc3SWE6zSlZUaqywthxz E2gYEfJyrdmrQu1+Vcf/wUi/BmZrk2Z55LG1XDmzj8/1Agz34f+TebIyk5Q8/MfV8weB JRVQV5DRKxdYkCTlJg4DkMck7eIUC/dUD6o9VPAJKqnViCxFqR0NWcb+o4X89jxVA8h4 Ncqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764857; x=1684356857; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wEoLssQdCNMXu2B6skyMInK1O7b8/2PI/cmR41Be7RU=; b=IM8hJOX8ZYVD4y5rWtq8BZfOwxVBuwr2b33S/6DbdVJrN4oQZrcAmeHzlatkoqmyDk L3/ihIUKLvVNEarMB3W19MKwftQDHsMxy5e2UcASt/tEsCUHrD07o0FfbsCKN0Nmnokz 6idtl9s4c/WB8/O0FbMmX7RmG/87lCKciAALjUjjVnM+VTAo8TpiUDD4+g/PZ82xT41J maNSgUdNFqXoyAIoEwXndBls91lD7NO4q4rGZ+rjq+EVKri6ydb1lAokCEcsJkwHFHa6 +XOGuP8FfRHIUQ/RusPEYagaOOodT3TkNsTjkOfncgM0D2rJ1uIgSj4H8psDxzX4Dj17 qTSQ== X-Gm-Message-State: AAQBX9eiue33pKoePT9s7QCMkZDvKPls9rB0CWiT5NMGOvZgVTQ/TPX9 3bCfWDHMCZF5avvZDr+fdN0sCthu+O+VhKw6DderBQ== X-Google-Smtp-Source: AKy350YtW9WwhvCmxDl28dDIbv0ZCm8FG5rBmHZaSCO3skYY1z1xMeYGVNGZ7I9e4Mu8rgZI/aLqhQ== X-Received: by 2002:a0d:cbc8:0:b0:552:a147:c50b with SMTP id n191-20020a0dcbc8000000b00552a147c50bmr10913724ywd.23.1681764856724; Mon, 17 Apr 2023 13:54:16 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id 189-20020a8117c6000000b00545a08184b1sm3306277ywx.65.2023.04.17.13.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:54:16 -0700 (PDT) Date: Mon, 17 Apr 2023 16:54:15 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Derrick Stolee , Junio C Hamano Subject: [PATCH 01/10] pack-write.c: plug a leak in stage_tmp_packfiles() Message-ID: <65ac7ed9b843a83f7b4cc0acd7b4e70d98ca20aa.1681764848.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The function `stage_tmp_packfiles()` generates a filename to use for staging the contents of what will become the pack's ".mtimes" file. The name is generated in `write_mtimes_file()` and the result is returned back to `stage_tmp_packfiles()` which uses it to rename the temporary file into place via `rename_tmp_packfiles()`. `write_mtimes_file()` returns a `const char *`, indicating that callers are not expected to free its result (similar to, e.g., `oid_to_hex()`). But callers are expected to free its result, so this return type is incorrect. Change the function's signature to return a non-const `char *`, and free it at the end of `stage_tmp_packfiles()`. Signed-off-by: Taylor Blau --- pack-write.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pack-write.c b/pack-write.c index f171405495..4da0ccc5f5 100644 --- a/pack-write.c +++ b/pack-write.c @@ -312,13 +312,13 @@ static void write_mtimes_trailer(struct hashfile *f, const unsigned char *hash) hashwrite(f, hash, the_hash_algo->rawsz); } -static const char *write_mtimes_file(struct packing_data *to_pack, - struct pack_idx_entry **objects, - uint32_t nr_objects, - const unsigned char *hash) +static char *write_mtimes_file(struct packing_data *to_pack, + struct pack_idx_entry **objects, + uint32_t nr_objects, + const unsigned char *hash) { struct strbuf tmp_file = STRBUF_INIT; - const char *mtimes_name; + char *mtimes_name; struct hashfile *f; int fd; @@ -544,7 +544,7 @@ void stage_tmp_packfiles(struct strbuf *name_buffer, char **idx_tmp_name) { const char *rev_tmp_name = NULL; - const char *mtimes_tmp_name = NULL; + char *mtimes_tmp_name = NULL; if (adjust_shared_perm(pack_tmp_name)) die_errno("unable to make temporary pack file readable"); @@ -568,6 +568,8 @@ void stage_tmp_packfiles(struct strbuf *name_buffer, rename_tmp_packfile(name_buffer, rev_tmp_name, "rev"); if (mtimes_tmp_name) rename_tmp_packfile(name_buffer, mtimes_tmp_name, "mtimes"); + + free(mtimes_tmp_name); } void write_promisor_file(const char *promisor_name, struct ref **sought, int nr_sought) From patchwork Mon Apr 17 20:54:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13214706 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 06ABAC77B76 for ; Mon, 17 Apr 2023 20:57:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231219AbjDQU5F (ORCPT ); Mon, 17 Apr 2023 16:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231238AbjDQU4q (ORCPT ); Mon, 17 Apr 2023 16:56:46 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 338A5C672 for ; Mon, 17 Apr 2023 13:54:36 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id n193so4927724ybf.12 for ; Mon, 17 Apr 2023 13:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20221208.gappssmtp.com; s=20221208; t=1681764860; x=1684356860; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YhgS/HETCgTYAYvaTLBae15oddw5fwQFfwH4eFCw1Z8=; b=WRLceu4EdOomuu47MZXUeMr9/4FOZsn7iaoG9KTgNcu+zNqa1hLGzdHedSevweqADc AAX21123l/PiL4KRfOiy+bq6CaKy7fR+6ZpvShby7TkySF6F4HbLRIRszOhSVatAAloc kGkYKHFmz1fowPKcOQFi+UXiXDErnZKUckLXcStRoyJ4tUgP1tDLbY0bdULJFV/z3xw5 lt+aAGjTa8nzH77zAASAksY+9iwBHtiVsPlUvyO2j7U17HvVerR/8FBxEcFGhxvLk4vT 1Fnang2JGxSjbP+RBG6E2Ek/vprY65XbozIAMzQD3XoNpvaFBRdgjWPhXqNUKfLxoKkG mgOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764860; x=1684356860; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YhgS/HETCgTYAYvaTLBae15oddw5fwQFfwH4eFCw1Z8=; b=E7IELMlPERnssXdH5LZKajwA/e0ftq6O/IFrVsRfIZEQzsGeH6jiiTIC0hZxeyI3FB irEDyD3zzk7nsU2nw9fTtACtGT+dkfm0GOJixFTHmkNUF+nIsREczP1D10CaifpQDdz8 pfaA4ftwS6rCU0LsN3RtmdDsyNwgqu8TGvUv3ICcKwsWMK+4mSp2jLvZjZoPAR32UvFQ bjVmWjYtkHoKES61XhhxDR4tyj75gYM8tM2QrafGHkJjtBs/QfzZA5haRmCyvtgeaXr9 IpGVCGMwFIDjLXXs5T9XJaDgaVWTfgU7gtogUOXD8gDd5avQzlYjFAqg3m2wPzTY7XWB wutA== X-Gm-Message-State: AAQBX9eWtHJ0xn3fnYskwhgnONMGKrZRvJhgMK7/D06LGXRzx7jbuJBw IHOXQV7b8d5F+dWhf3jieWUQoW5n91Cn7gYmKYweqw== X-Google-Smtp-Source: AKy350a/nzgdPhqtJH174yxMrEC9NQojmEuzLfSugGxOWPEoe3FI/HoQVJNlCtQh1F6x5MWrtShDvQ== X-Received: by 2002:a25:55c1:0:b0:b92:4a08:4830 with SMTP id j184-20020a2555c1000000b00b924a084830mr4171720ybb.26.1681764859734; Mon, 17 Apr 2023 13:54:19 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id h82-20020a252155000000b00b8d65899d76sm3223881ybh.47.2023.04.17.13.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:54:19 -0700 (PDT) Date: Mon, 17 Apr 2023 16:54:18 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Derrick Stolee , Junio C Hamano Subject: [PATCH 02/10] builtin/repack.c: fix incorrect reference to '-C' Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When cruft packs were originally being developed, `-C` was designated as the short-form for `--cruft` (as in `git repack -C`). This was dropped due to confusion with Git's top-level `-C` option before submitting to the list. But the reference to it in `--cruft-expiration`'s help text was never updated. Fix that dangling reference in this patch. Signed-off-by: Taylor Blau --- builtin/repack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/repack.c b/builtin/repack.c index df4d8e0f0b..d9eee15c2f 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -774,7 +774,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) N_("same as -a, pack unreachable cruft objects separately"), PACK_CRUFT), OPT_STRING(0, "cruft-expiration", &cruft_expiration, N_("approxidate"), - N_("with -C, expire objects older than this")), + N_("with --cruft, expire objects older than this")), OPT_BOOL('d', NULL, &delete_redundant, N_("remove redundant packs, and run git-prune-packed")), OPT_BOOL('f', NULL, &po_args.no_reuse_delta, From patchwork Mon Apr 17 20:54:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13214707 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 CB64DC77B76 for ; Mon, 17 Apr 2023 20:57:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231139AbjDQU5V (ORCPT ); Mon, 17 Apr 2023 16:57:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231130AbjDQU4y (ORCPT ); Mon, 17 Apr 2023 16:56:54 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F08CC1D for ; Mon, 17 Apr 2023 13:54:45 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id r184so11480572ybc.1 for ; Mon, 17 Apr 2023 13:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20221208.gappssmtp.com; s=20221208; t=1681764863; x=1684356863; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ufLzWQemmfKm6VPiBYmhZeagjpz2vAilwKvh4+0e+Bk=; b=i9REyRCSykzi0v81jksOU2nV5PKCJWnm8nnEeXRZ5A+fCphhu0hfZmyE+ZfwpN5uml TZAPdMyDqhhEjX97EDrzWvLfhbiTS5zDIi+FedEcAoROlwNZS7O/kzlsCDNeHn5LQLZ9 3WXQMYEdKc6iE6gjx3WGECu90+c8dCN8Iz8W69bBWuauUSle6QcTcHSFOWGcBcZXtlcj 34aXmjzbOMzzssKervonD22+kW8UqW40XVRqC/y8ctyEQ/TGpkJ/4XhfUnrrQhKvSeSD y8uE8iYdTz1ggF5Tr4BjGt+fqmaJtVK+CXbBiBLaPKsEEADHHMykWJ8mJr6z6ypYXCjZ q2+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764863; x=1684356863; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ufLzWQemmfKm6VPiBYmhZeagjpz2vAilwKvh4+0e+Bk=; b=B3eefYOERhEDr+hCUq+gJ7CXG2rD4Id+vg/h/ik5h88JtDSAYTPlyGHA+kXCjkVK6s kxKSVXy/YRwtq3Ww8QYvw7Zs2LXzjDFtO8QLqHAxvGzb4CtGXFh+ovOux351FB45/xu6 Z5e2Q+96pIaIDf5pUKIf01eRdvQrxafctGxBmfGIm/wINqitmdnsPcuSsx59K4rR536J oeWYdGwfK1NDTgVGwLb9pCmnbJ9G6d3IWmVTztXcba80aSyA1p8drrFUaDtsyMBjoy8e EzgOBwYh7Yw0v7ASmqc5ZiHMHQm0ZXC1goEnCKJSzeP7LmQxp6u/qzCgzX/kMiApUHfO J3JA== X-Gm-Message-State: AAQBX9cfOjMrzPtLYSNVTHabKdNf0U3CJujZJYpA/pyxQB/7hD+yuVSp aSzrgHAiyi3Hgkd3GW3y9BygaEeNPeBmqel8WW/xBw== X-Google-Smtp-Source: AKy350ZUjoCFEeNmxSic+Fq+xCOE6UILKgAi5DLn0H5woYX0YMX1x8S7AIRex+UTg03WrAsQR7jLTg== X-Received: by 2002:a25:3743:0:b0:b8f:3eda:30b7 with SMTP id e64-20020a253743000000b00b8f3eda30b7mr16998639yba.13.1681764862656; Mon, 17 Apr 2023 13:54:22 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id a6-20020a259386000000b00b923b9e0a82sm1524900ybm.45.2023.04.17.13.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:54:22 -0700 (PDT) Date: Mon, 17 Apr 2023 16:54:21 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Derrick Stolee , Junio C Hamano Subject: [PATCH 03/10] builtin/gc.c: ignore cruft packs with `--keep-largest-pack` Message-ID: <796df920ad6af0ee9101a0f3f80edbc793987336.1681764848.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When cruft packs were implemented, we never adjusted the code for `git gc`'s `--keep-largest-pack` and `gc.bigPackThreshold` to ignore cruft packs. This option and configuration option share a common implementation, but including cruft packs is wrong in both cases: - Running `git gc --keep-largest-pack` in a repository where the largest pack is the cruft pack itself will make it impossible for `git gc` to prune objects, since the cruft pack itself is kept. - The same is true for `gc.bigPackThreshold`, if the size of the cruft pack exceeds the limit set by the caller. Ignore cruft packs in the common implementation for both of these options, and add a pair of tests to prevent any future regressions here. Signed-off-by: Taylor Blau --- Documentation/config/gc.txt | 10 ++++----- Documentation/git-gc.txt | 7 +++--- builtin/gc.c | 2 +- t/t6500-gc.sh | 43 +++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/Documentation/config/gc.txt b/Documentation/config/gc.txt index 38fea076a2..8d5353e9e0 100644 --- a/Documentation/config/gc.txt +++ b/Documentation/config/gc.txt @@ -43,11 +43,11 @@ gc.autoDetach:: if the system supports it. Default is true. gc.bigPackThreshold:: - If non-zero, all packs larger than this limit are kept when - `git gc` is run. This is very similar to `--keep-largest-pack` - except that all packs that meet the threshold are kept, not - just the largest pack. Defaults to zero. Common unit suffixes of - 'k', 'm', or 'g' are supported. + If non-zero, all non-cruft packs larger than this limit are kept + when `git gc` is run. This is very similar to + `--keep-largest-pack` except that all non-cruft packs that meet + the threshold are kept, not just the largest pack. Defaults to + zero. Common unit suffixes of 'k', 'm', or 'g' are supported. + Note that if the number of kept packs is more than gc.autoPackLimit, this configuration variable is ignored, all packs except the base pack diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt index a65c9aa62d..2427478314 100644 --- a/Documentation/git-gc.txt +++ b/Documentation/git-gc.txt @@ -77,9 +77,10 @@ be performed as well. instance running on this repository. --keep-largest-pack:: - All packs except the largest pack and those marked with a - `.keep` files are consolidated into a single pack. When this - option is used, `gc.bigPackThreshold` is ignored. + All packs except the largest pack, any packs marked with a + `.keep` file, and any cruft pack(s) are consolidated into a + single pack. When this option is used, `gc.bigPackThreshold` is + ignored. AGGRESSIVE ---------- diff --git a/builtin/gc.c b/builtin/gc.c index edd98d35a5..53ef137e1d 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -219,7 +219,7 @@ static struct packed_git *find_base_packs(struct string_list *packs, struct packed_git *p, *base = NULL; for (p = get_all_packs(the_repository); p; p = p->next) { - if (!p->pack_local) + if (!p->pack_local || p->is_cruft) continue; if (limit) { if (p->pack_size >= limit) diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index d9acb63951..df6f2e6e52 100755 --- a/t/t6500-gc.sh +++ b/t/t6500-gc.sh @@ -298,6 +298,49 @@ test_expect_success 'feature.experimental=false avoids cruft packs by default' ' ) ' +test_expect_success '--keep-largest-pack ignores cruft packs' ' + test_when_finished "rm -fr repo" && + git init repo && + ( + cd repo && + + # Generate a pack for reachable objects (of which there + # are 3), and one for unreachable objects (of which + # there are 6). + prepare_cruft_history && + git gc --cruft && + + mtimes="$(find .git/objects/pack -type f -name "pack-*.mtimes")" && + sz="$(test_file_size "${mtimes%.mtimes}.pack")" && + + # Ensure that the cruft pack gets removed (due to + # `--prune=now`) despite it being the largest pack. + git -c gc.bigPackThreshold=$sz gc --cruft --prune=now && + + assert_no_cruft_packs + ) +' + +test_expect_success 'gc.bigPackThreshold ignores cruft packs' ' + test_when_finished "rm -fr repo" && + git init repo && + ( + cd repo && + + # Generate a pack for reachable objects (of which there + # are 3), and one for unreachable objects (of which + # there are 6). + prepare_cruft_history && + git gc --cruft && + + # Ensure that the cruft pack gets removed (due to + # `--prune=now`) despite it being the largest pack. + git gc --cruft --prune=now --keep-largest-pack && + + assert_no_cruft_packs + ) +' + run_and_wait_for_auto_gc () { # We read stdout from gc for the side effect of waiting until the # background gc process exits, closing its fd 9. Furthermore, the From patchwork Mon Apr 17 20:54:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13214708 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 CF096C77B76 for ; Mon, 17 Apr 2023 20:57:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231207AbjDQU5b (ORCPT ); Mon, 17 Apr 2023 16:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230514AbjDQU5E (ORCPT ); Mon, 17 Apr 2023 16:57:04 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE60BCC3E for ; Mon, 17 Apr 2023 13:54:52 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id m14so9983888ybk.4 for ; Mon, 17 Apr 2023 13:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20221208.gappssmtp.com; s=20221208; t=1681764865; x=1684356865; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=iEJ9qzbPbjrFbQGLENPt1su2NVmD89oNuuCJMqep5HQ=; b=rOf8UBlMuV9DT2p5cjkQr5+8xf6qPa5ilWPUqtwgX3D5sY0voAfAw8Ai3+c2dtJ9SU HJ1+LhLkGHqqSxECNhkcHdWGsmgfPPU9yD7h6Zd504wBBQiMOKnQ4iSEF64dcjr+9wAN fn46Eu4LO1ZE+s83DzuIuOIu0NMy14XYB0B583/GzhMgfWkqSAFnleipozsAA24PvxFJ n3gX4BKdY2urVx7xqnk8FpvKmbpQZbJpjQdPyAI2GsnavnqU3rjZaw7Tbux/6Yeaz+mf MoE+2gGQiYdTgsS0x2RM5nqWaExBy7U78CwjBP+5laOn4FEpLLLcU6ptafAbJWQKPax/ 1KcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764865; x=1684356865; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iEJ9qzbPbjrFbQGLENPt1su2NVmD89oNuuCJMqep5HQ=; b=Tf+lb7Kxqsty71gyOnjHflRRUESw90+i7fxGuIIntTdhNl77VNr4cDFHenGwvNGWnf Eva+9uwmr4g89I0wlw6Fdt3lQiCbrZLfeaDSLCHjcFvZHMSHGiVPF/+208EGLLI4mdPz fel8fno9JdzUKe1WGQ2JV2JFB7eO6S/3X1P6HZasUqUPj1+pTCqYQ73CHcultsh0Gup2 Dkm12hmJxpd5exa+kBla/GnwxMy3wMSEKbRP3YEp/RvJOWmpqD3GW5XsvRIdv5m+GxdU 6Fyn5p6QR9nLnnRZ0O9qESiIolXankw5cwjwFovn8Q1rJzZtcuyj7OA3QnUTqYzx5JR6 QHjw== X-Gm-Message-State: AAQBX9fOFfiPLhm9bpykt31GN41DS0WaxKVApK/Nz9KhXwYCm2+zm3IE u7tOd3dasCxdByDeWP05ic4dKEggGeT7/MlyWuThFA== X-Google-Smtp-Source: AKy350Z1R/4qZe/izrG/a1xUYJ+IyThdYuiCgwe0j6leYwXGsL+j7BwaIHOLcCqds5sqILiU7nbxKQ== X-Received: by 2002:a25:4555:0:b0:b8f:2257:af0c with SMTP id s82-20020a254555000000b00b8f2257af0cmr14442796yba.15.1681764865523; Mon, 17 Apr 2023 13:54:25 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id d71-20020a25cd4a000000b00b8f5b3b7115sm3131933ybf.60.2023.04.17.13.54.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:54:25 -0700 (PDT) Date: Mon, 17 Apr 2023 16:54:24 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Derrick Stolee , Junio C Hamano Subject: [PATCH 04/10] t/t5304-prune.sh: prepare for `gc --cruft` by default Message-ID: <44006da959eeeaef93a33d73071fb5edc45cd45b.1681764848.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Many of the tests in t5304 run `git gc`, and rely on its behavior that unreachable-but-recent objects are written out loose. This is sensible, since t5304 deals specifically with this kind of pruning. If left unattended, however, this test would break when the default behavior of a bare "git gc" is adjusted to generate a cruft pack by default. Ensure that these tests continue to work as-is (and continue to provide coverage of loose object pruning) by passing `--no-cruft` explicitly. Signed-off-by: Taylor Blau --- t/t5304-prune.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh index 5500dd0842..662ae9b152 100755 --- a/t/t5304-prune.sh +++ b/t/t5304-prune.sh @@ -62,11 +62,11 @@ test_expect_success 'prune --expire' ' test_expect_success 'gc: implicit prune --expire' ' add_blob && test-tool chmtime =-$((2*$week-30)) $BLOB_FILE && - git gc && + git gc --no-cruft && verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && test_path_is_file $BLOB_FILE && test-tool chmtime =-$((2*$week+1)) $BLOB_FILE && - git gc && + git gc --no-cruft && verbose test $before = $(git count-objects | sed "s/ .*//") && test_path_is_missing $BLOB_FILE ' @@ -86,7 +86,7 @@ test_expect_success 'gc: refuse to start with invalid gc.pruneExpire' ' test_expect_success 'gc: start with ok gc.pruneExpire' ' git config gc.pruneExpire 2.days.ago && - git gc + git gc --no-cruft ' test_expect_success 'prune: prune nonsense parameters' ' @@ -137,44 +137,44 @@ test_expect_success 'gc --no-prune' ' add_blob && test-tool chmtime =-$((5001*$day)) $BLOB_FILE && git config gc.pruneExpire 2.days.ago && - git gc --no-prune && + git gc --no-prune --no-cruft && verbose test 1 = $(git count-objects | sed "s/ .*//") && test_path_is_file $BLOB_FILE ' test_expect_success 'gc respects gc.pruneExpire' ' git config gc.pruneExpire 5002.days.ago && - git gc && + git gc --no-cruft && test_path_is_file $BLOB_FILE && git config gc.pruneExpire 5000.days.ago && - git gc && + git gc --no-cruft && test_path_is_missing $BLOB_FILE ' test_expect_success 'gc --prune=' ' add_blob && test-tool chmtime =-$((5001*$day)) $BLOB_FILE && - git gc --prune=5002.days.ago && + git gc --prune=5002.days.ago --no-cruft && test_path_is_file $BLOB_FILE && - git gc --prune=5000.days.ago && + git gc --prune=5000.days.ago --no-cruft && test_path_is_missing $BLOB_FILE ' test_expect_success 'gc --prune=never' ' add_blob && - git gc --prune=never && + git gc --prune=never --no-cruft && test_path_is_file $BLOB_FILE && - git gc --prune=now && + git gc --prune=now --no-cruft && test_path_is_missing $BLOB_FILE ' test_expect_success 'gc respects gc.pruneExpire=never' ' git config gc.pruneExpire never && add_blob && - git gc && + git gc --no-cruft && test_path_is_file $BLOB_FILE && git config gc.pruneExpire now && - git gc && + git gc --no-cruft && test_path_is_missing $BLOB_FILE ' @@ -194,7 +194,7 @@ test_expect_success 'gc: prune old objects after local clone' ' cd aclone && verbose test 1 = $(git count-objects | sed "s/ .*//") && test_path_is_file $BLOB_FILE && - git gc --prune && + git gc --prune --no-cruft && verbose test 0 = $(git count-objects | sed "s/ .*//") && test_path_is_missing $BLOB_FILE ) @@ -237,7 +237,7 @@ test_expect_success 'clean pack garbage with gc' ' >.git/objects/pack/fake2.keep && >.git/objects/pack/fake2.idx && >.git/objects/pack/fake3.keep && - git gc && + git gc --no-cruft && git count-objects -v 2>stderr && grep "^warning:" stderr | sort >actual && cat >expected <<\EOF && From patchwork Mon Apr 17 20:54:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13214709 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 A717DC77B76 for ; Mon, 17 Apr 2023 20:57:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230525AbjDQU5l (ORCPT ); Mon, 17 Apr 2023 16:57:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231165AbjDQU5S (ORCPT ); Mon, 17 Apr 2023 16:57:18 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49EADD32C for ; Mon, 17 Apr 2023 13:55:01 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-54c0c86a436so551833467b3.6 for ; Mon, 17 Apr 2023 13:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20221208.gappssmtp.com; s=20221208; t=1681764868; x=1684356868; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=bKiKbZnJpPrCZn5U+gYXllyRzne0MiR744ovoifmPTo=; b=XvoxY06+7tM9Ww4WiB2uSzQmHsgE7AgFXrv1HLQ3AOnyef6gmrMJ3eZM3D/AIuXkYV S5D8CXSEs6lnHSB7pyjL/iteaZOw55rNhCNqjm4ygPkTgiEugznjZZbrQ+VArFrR3KsG 7aXDfkZg0ZJfFH0EsxD5hoKQEjtyjKuaiml6yWZR/dQd9QZZbnlwMgeYh5Ht8Bkj1cLx E3NNcYL8T2ivWbCmV/2Rg+Qn/hMczJkFK2KsK7iMc4E9btN1SIl1Ws/yo1t/0wK7+N9v yuvjQlDhHyXMbCVKd1CMl0gBKOKvkb6mu1Ngi8WV1Uf2fQqfDXSnaPsV7n9w98M048YD bR1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764868; x=1684356868; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bKiKbZnJpPrCZn5U+gYXllyRzne0MiR744ovoifmPTo=; b=VaW7UUO4M9skR+GY7OXzlWxwF7O5Q8c8b6QgD4JVDleK63DT6Y34A2uW9u5cxbRdSN pflHY2NTjIqGy/B//xSGdHt9PlfPe7s3wfKKpEi2tBkOzc5Se2ZjBgUmwM9pwydnwSiQ 95PiiAB2xPqVBPL+LHbqdjgeimdmKnW4zIDdT0/FadqAb/9lCdyj0J/Tgnpq7NnAD4Hi OUI8R/fSJJBzLbf0uOqO/cVaqfuxQaTh60v9iy2M+FRoxIq5VQtMtwhz5HP9OXbO86M0 rx/MDKn9FZR24KWtyktTIXmVBdZc5WX2EsMxIxWZ2aN+8rQuzIR6gpWfWHZfOiRErdeT tUdQ== X-Gm-Message-State: AAQBX9djLCk41nGUzF84oqErX3ZTn44EM9AsaoWzd9g0RGDapNBzJ7B7 Dpgi4i9uysPWAv06xXGcPv4vKBLOd7Clte3gQG6JqA== X-Google-Smtp-Source: AKy350ZCclcrWUIiChwS/Bi5qaUKaAu7dxfTFvmOumjwum4GPJN+8YJkOAS/UrOLratkg3pXPycyAw== X-Received: by 2002:a0d:d644:0:b0:545:62d7:6fac with SMTP id y65-20020a0dd644000000b0054562d76facmr15227307ywd.10.1681764868453; Mon, 17 Apr 2023 13:54:28 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id eq7-20020a05690c2d0700b00545a08184b3sm1826995ywb.67.2023.04.17.13.54.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:54:28 -0700 (PDT) Date: Mon, 17 Apr 2023 16:54:27 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Derrick Stolee , Junio C Hamano Subject: [PATCH 05/10] t/t9300-fast-import.sh: prepare for `gc --cruft` by default Message-ID: <1b07eb83fe6ab9fcb65d5a4746dec50c0f2cbd9e.1681764848.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a similar fashion as the previous commit, adjust the fast-import tests to prepare for "git gc" generating a cruft pack by default. This adjustment is slightly different, however. Instead of relying on us writing out the objects loose, and then calling `git prune` to remove them, t9300 needs to be prepared to drop objects that would be moved into cruft packs. To do this, we can combine the `git gc` invocation with `git prune` into one `git gc --prune`, which handles pruning both loose objects, and objects that would otherwise be written to a cruft pack. Signed-off-by: Taylor Blau --- t/t9300-fast-import.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index aa55b41b9a..ac237a1f90 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -388,9 +388,7 @@ test_expect_success 'B: accept branch name "TEMP_TAG"' ' INPUT_END - test_when_finished "rm -f .git/TEMP_TAG - git gc - git prune" && + test_when_finished "rm -f .git/TEMP_TAG && git gc --prune=now" && git fast-import X-Patchwork-Id: 13214710 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 73551C77B72 for ; Mon, 17 Apr 2023 20:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230447AbjDQU5r (ORCPT ); Mon, 17 Apr 2023 16:57:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbjDQU51 (ORCPT ); Mon, 17 Apr 2023 16:57:27 -0400 Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 618E710240 for ; Mon, 17 Apr 2023 13:55:10 -0700 (PDT) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-54fe82d8bf5so118497367b3.3 for ; Mon, 17 Apr 2023 13:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20221208.gappssmtp.com; s=20221208; t=1681764871; x=1684356871; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=qkkwKqgaROJ7eFygG7db6ztdmnrn7KSjjlMwVUTv4mE=; b=E4Fgo0Sx/nfqcgeY2YzH9G/s1hIpkUFmVtcI6ObQuPwxKNm+w1aY0KiKw5WQ/eC7O0 rjiuLAci8WqeDJiOFEEqklwuknsicJVJe+YOFPAhsiwm6mjb/31UJb8+yqhhfObKp80+ NH4Rg2GUaLkIixie9bgijb94or2e0QHCrH+YagFZTqLl7VZSA8y7frql1hA9dHYA/WJd 4jQQ2mCgZKEbyFBxKx4rBrTIv8TKJFCGag8tIFwE4cv5oQeWQstY63mE/k4mH7vh86GY rA+ezpwSOtlIybN5KPPiZvABK08mvtJvvUGR4E0nr7Ueh4FxGnnvpeqlQL/jBGF/4uLA ntKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764871; x=1684356871; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qkkwKqgaROJ7eFygG7db6ztdmnrn7KSjjlMwVUTv4mE=; b=Ns7n8w6lLayFE8barW8s3CF62fuAp3jo3Ho/epFvXsdJ+h5t+WRqxD7NlxoPmPak6e DVb9CEI2AL3vs2EduBydDqMzPO5dnslTyknqO4Rgk5DIwYDRhl6IQuahs1KYTEy3mPiO vmgoOhIrlA8gMZ3+Oa8lSqHr2ExApX2yVZnMqMm5LM0UqJOHsUVqQEjbBZ3zCQIrCeSK OVsRlGRsTpzGe0nhELckJ1TOofKq9YlQ4kzAjFHb3WXPYMhBbym0ljKA413UiiBCf6sn wO+dsy5zKhBhqSfAHYrapwpDjA/A49slFRBK6BRyxdi76zBCyP7pHVmlup7iFd8zK3nm zarw== X-Gm-Message-State: AAQBX9ciBsr/YknRSveClRza2+Dqrwq3VPeB1xzITpZ+czV/3A0ZDKYp nuvEDjdbsbGcUtbuj+me5CfacjstmAUUzBhNWygjtA== X-Google-Smtp-Source: AKy350YU5V1g6X9qJVAOrweWlORu6DAzvat4/lagFG6sCrG771ubpoLWDfbxggVZ36oxV7lM8R32Ig== X-Received: by 2002:a0d:f087:0:b0:552:a2e2:684e with SMTP id z129-20020a0df087000000b00552a2e2684emr9293968ywe.52.1681764871488; Mon, 17 Apr 2023 13:54:31 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id by7-20020a05690c082700b00545ef25cec6sm3299750ywb.105.2023.04.17.13.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:54:31 -0700 (PDT) Date: Mon, 17 Apr 2023 16:54:30 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Derrick Stolee , Junio C Hamano Subject: [PATCH 06/10] t/t6500-gc.sh: refactor cruft pack tests Message-ID: <56a965e517c125c1defa95f7ccf8506dbf55275f.1681764848.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In 12253ab6d0 (gc: add tests for --cruft and friends, 2022-10-26), we added a handful of tests to t6500 to ensure that `git gc` respected the value of `--cruft` and `gc.cruftPacks`. Then, in c695592850 (config: let feature.experimental imply gc.cruftPacks=true, 2022-10-26), another set of similar tests was added to ensure that `feature.experimental` correctly implied enabling cruft pack generation (or not). These tests are similar and could be consolidated. Do so in this patch to prepare for expanding the set of command-line invocations that enable or disable writing cruft packs. This makes it possible to easily test more combinations of arguments without being overly repetitive. Signed-off-by: Taylor Blau --- t/t6500-gc.sh | 126 ++++++++++++++++++-------------------------------- 1 file changed, 44 insertions(+), 82 deletions(-) diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index df6f2e6e52..a2f988c5c2 100755 --- a/t/t6500-gc.sh +++ b/t/t6500-gc.sh @@ -210,93 +210,55 @@ prepare_cruft_history () { git reset HEAD^^ } -assert_cruft_packs () { - find .git/objects/pack -name "*.mtimes" >mtimes && - sed -e 's/\.mtimes$/\.pack/g' mtimes >packs && - - test_file_not_empty packs && - while read pack - do - test_path_is_file "$pack" || return 1 - done mtimes && test_must_be_empty mtimes } -test_expect_success 'gc --cruft generates a cruft pack' ' - test_when_finished "rm -fr crufts" && - git init crufts && - ( - cd crufts && - - prepare_cruft_history && - git gc --cruft && - assert_cruft_packs - ) -' - -test_expect_success 'gc.cruftPacks=true generates a cruft pack' ' - test_when_finished "rm -fr crufts" && - git init crufts && - ( - cd crufts && - - prepare_cruft_history && - git -c gc.cruftPacks=true gc && - assert_cruft_packs - ) -' - -test_expect_success 'feature.experimental=true generates a cruft pack' ' - git init crufts && - test_when_finished "rm -fr crufts" && - ( - cd crufts && - - prepare_cruft_history && - git -c feature.experimental=true gc && - assert_cruft_packs - ) -' - -test_expect_success 'feature.experimental=false allows explicit cruft packs' ' - git init crufts && - test_when_finished "rm -fr crufts" && - ( - cd crufts && - - prepare_cruft_history && - git -c gc.cruftPacks=true -c feature.experimental=false gc && - assert_cruft_packs - ) -' - -test_expect_success 'feature.experimental=true can be overridden' ' - git init crufts && - test_when_finished "rm -fr crufts" && - ( - cd crufts && - - prepare_cruft_history && - git -c feature.expiremental=true -c gc.cruftPacks=false gc && - assert_no_cruft_packs - ) -' - -test_expect_success 'feature.experimental=false avoids cruft packs by default' ' - git init crufts && - test_when_finished "rm -fr crufts" && - ( - cd crufts && - - prepare_cruft_history && - git -c feature.experimental=false gc && - assert_no_cruft_packs - ) -' +for argv in \ + "gc --cruft" \ + "-c gc.cruftPacks=true gc" \ + "-c feature.experimental=true gc" \ + "-c gc.cruftPacks=true -c feature.experimental=false gc" +do + test_expect_success "git $argv generates a cruft pack" ' + test_when_finished "rm -fr repo" && + git init repo && + ( + cd repo && + + prepare_cruft_history && + git $argv && + + find .git/objects/pack -name "*.mtimes" >mtimes && + sed -e 's/\.mtimes$/\.pack/g' mtimes >packs && + + test_file_not_empty packs && + while read pack + do + test_path_is_file "$pack" || return 1 + done X-Patchwork-Id: 13214711 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 02533C77B76 for ; Mon, 17 Apr 2023 20:57:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbjDQU5z (ORCPT ); Mon, 17 Apr 2023 16:57:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbjDQU5c (ORCPT ); Mon, 17 Apr 2023 16:57:32 -0400 Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75DD210266 for ; Mon, 17 Apr 2023 13:55:15 -0700 (PDT) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-54fbb713301so190263297b3.11 for ; Mon, 17 Apr 2023 13:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20221208.gappssmtp.com; s=20221208; t=1681764874; x=1684356874; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Zqn+KrQfmAEpBOrH9kb2/2ZRJlyEO5bB4c2oYbqMeTc=; b=3RKClGfSe35LRcG3hTY77Vv39xD2fui0UB40y8w6/2rAnF6DRo4QHWx8cswIjpt8YY +xh2yhaPXKwJTBgdSpgYwv0suMGkR2oj992Tk0EDq9jyaGxp6vG/esJjVql7OPKoSKTU QCXuvmQgw5ogk1VyONyHd/MGWqr3uwtF5gBjfe7gePz5no7ciJFcnjeugUPzyqTsNkK9 1VuNarmLnCiEzxRwC+05myAAu1EN6TeGnlQH6YnyCXfidLLNfuFURkvusMdxPQ3dBNy3 6lZNBfD93hxzn2phOsI+r0kzGXVKIVJPLI888Gm6vYj9FlBd8X5qc8x7SBGHgs+NZVro Hj8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764874; x=1684356874; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Zqn+KrQfmAEpBOrH9kb2/2ZRJlyEO5bB4c2oYbqMeTc=; b=bEE1UW1xH4wMLG/FdVTpgmd3GC0PYKdGxNxbTB9Weg1iltBNd1CmqNWbETL+CT6tao kgAd5CIHQIDkgslcW/MjpCdWlNyMGcpq1l9J+iO59hTUSRHeyBT12OBXA7tS3NBcmoIb ZthqIXHvKqFTF8drEkmgboGIbnn41GKxpHEBn3Mu3BTtQJDdfK80vljw9jSH7vGzjyEy yu0gxyOePoetLpRA68U5EPc9BeiyZzyyT/mFprrVkW7GuOE87JFLoglskZmKqbtZNOGC NH9oZaPxggRM++QcfyZ6tMd6rTzzIhm2cGEkIzW7SUOVccsopd+3Ppv9U5oD9ebaWDRY LyBQ== X-Gm-Message-State: AAQBX9cBtcA2Vo7RuGvq+SbxZKTEaiHkx7tAHjwrsgIOKzecnv/0Q7z0 /fWgdkiFAYGQExGkBRRfc5kWJDs+vVhgXB9g40oMDg== X-Google-Smtp-Source: AKy350YvzMpTKpRJtms7IfvK1/PqIcRENmeeu6JEDzaKgiImU24P2KnELB4mUw7hdPuokispgM7OBg== X-Received: by 2002:a81:84d1:0:b0:541:9ac1:f5a9 with SMTP id u200-20020a8184d1000000b005419ac1f5a9mr16123451ywf.2.1681764874550; Mon, 17 Apr 2023 13:54:34 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id j199-20020a8155d0000000b0054f80928ea4sm3305279ywb.140.2023.04.17.13.54.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:54:34 -0700 (PDT) Date: Mon, 17 Apr 2023 16:54:33 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Derrick Stolee , Junio C Hamano Subject: [PATCH 07/10] t/t6500-gc.sh: add additional test cases Message-ID: <6957e54f51759ff1b6d2469bc40c9b966635595d.1681764848.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the last commit, we refactored some of the tests in t6500 to make clearer when cruft packs will and won't be generated by `git gc`. Add the remaining cases not covered by the previous patch into this one, which enumerates all possible combinations of arguments that will produce (or not produce) a cruft pack. This prepares us for the following commit, which will change the default of `gc.cruftPacks` by ensuring that we understand which invocations do and do not change as a result. Signed-off-by: Taylor Blau --- t/t6500-gc.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index a2f988c5c2..e7d3d1448f 100755 --- a/t/t6500-gc.sh +++ b/t/t6500-gc.sh @@ -218,6 +218,7 @@ assert_no_cruft_packs () { for argv in \ "gc --cruft" \ "-c gc.cruftPacks=true gc" \ + "-c gc.cruftPacks=false gc --cruft" \ "-c feature.experimental=true gc" \ "-c gc.cruftPacks=true -c feature.experimental=false gc" do @@ -243,6 +244,9 @@ do done for argv in \ + "gc --no-cruft" \ + "-c gc.cruftPacks=false gc" \ + "-c gc.cruftPacks=true gc --no-cruft" \ "-c feature.expiremental=true -c gc.cruftPacks=false gc" \ "-c feature.experimental=false gc" do From patchwork Mon Apr 17 20:54:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13214712 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 48646C77B76 for ; Mon, 17 Apr 2023 20:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231255AbjDQU6D (ORCPT ); Mon, 17 Apr 2023 16:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230416AbjDQU5j (ORCPT ); Mon, 17 Apr 2023 16:57:39 -0400 Received: from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com [IPv6:2607:f8b0:4864:20::1133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 006DA10277 for ; Mon, 17 Apr 2023 13:55:21 -0700 (PDT) Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-54fa9da5e5bso232126077b3.1 for ; Mon, 17 Apr 2023 13:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20221208.gappssmtp.com; s=20221208; t=1681764880; x=1684356880; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=IlRk2Cyq1ILCTYojEJhxP5kHxinVdRACLgFFvc3slZY=; b=B8ECsnTrq8la1EtMLsYLmKbxHiIm4HuJ2Sa7jQYcgoY2/ja6drrIki5El09Fze2l0G HXHlGcWU2X4uJjypV6JTy2EzzsrFOlxtmcvgyY5tPhiKxE+uwdVjHkoUJdYcX0SPOM6C RXDIaiVMcxUBgBoWgHNAlQBFfKNOsE0eakPYBQX6Lv7dxBCjXpO1y/3i+CdE2yPZO8+u 2yJfaZD2Ud1rVSKpixYX/+5gABZkJoYmOba21TESp/RJt89fhpm7xkevqMGWSpf8+15t AeOiaQlJMOhnsG+IEef6FtJXEDIW8ytfNKuLX5/nsYf7npIbWtn3YWn1IgAperguVSGq 3j0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764880; x=1684356880; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IlRk2Cyq1ILCTYojEJhxP5kHxinVdRACLgFFvc3slZY=; b=JmhsN6WYfpM8ozB33Lrl+ZqBl4bySRjcOcqfo6324UEsyAnKjmENXl6EE8c4ra5Nh6 dL4nidG/BySf/aT2k2plcaL6z4LYnT/g76O1AZTefkSpMUwU+7Llj7usczqldWCYf5Kl 0OWOR+2JKOB0d0lDsG6GKph/xOKktoa+Gn4STP8gNTSDxIU5RVnk5PzIkIUMDwMRdMoe fjyIVRZweRM5rwAW8HIeIR5GTZPXTHMhTKUcPCpmm6AtllBv1Lk1NYOr7M5rk8kppNCv +c+dwxRXjQ6/qcAdnsx4U450H3H4MGMzOi8KDjb5nsh7Rulz2R0Dv0dJEEg50yFl1XLD DR+Q== X-Gm-Message-State: AAQBX9dx7y4Hxt7In8by36llT9tOUqf/bPDJUJ406tOKtBC9tzAAQiZC 5ReYO7h40rXAJp8Nfs/cF60PsnxfNPo9Qo5MOVSUwg== X-Google-Smtp-Source: AKy350ZFuuF0ixiQ/qeue9fm8XFUpsg3Kq9fcPePorw8MeovXHSP+gbOaGp9qfUq9acE6eT0Jt0WoQ== X-Received: by 2002:a81:748b:0:b0:54f:cc36:2fae with SMTP id p133-20020a81748b000000b0054fcc362faemr14873700ywc.41.1681764878373; Mon, 17 Apr 2023 13:54:38 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id v16-20020a81b710000000b0054fb931adefsm3337665ywh.4.2023.04.17.13.54.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:54:38 -0700 (PDT) Date: Mon, 17 Apr 2023 16:54:36 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Derrick Stolee , Junio C Hamano Subject: [PATCH 08/10] t/t6501-freshen-objects.sh: prepare for `gc --cruft` by default Message-ID: <4ccc525c39dd23db1136681bc0ffd572db0ed2f2.1681764848.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a similar spirit as previous commits, prepare for `gc --cruft` becoming the default by ensuring that the tests in t6501 explicitly cover the case of freshening loose objects not using cruft packs. We could run this test twice, once with `--cruft` and once with `--no-cruft`, but doing so is unnecessary, since the object rescuing and freshening behavior is already extensively tested via t5329. Signed-off-by: Taylor Blau --- t/t6501-freshen-objects.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/t6501-freshen-objects.sh b/t/t6501-freshen-objects.sh index 3968b47ed5..dbfa8a4d4c 100755 --- a/t/t6501-freshen-objects.sh +++ b/t/t6501-freshen-objects.sh @@ -101,7 +101,7 @@ do ' test_expect_success "simultaneous gc ($title)" ' - git gc --prune=12.hours.ago + git gc --no-cruft --prune=12.hours.ago ' test_expect_success "finish writing out commit ($title)" ' @@ -131,7 +131,7 @@ do ' test_expect_success "simultaneous gc ($title)" ' - git gc --prune=12.hours.ago + git gc --no-cruft --prune=12.hours.ago ' # tree should have been refreshed by write-tree @@ -151,7 +151,7 @@ test_expect_success 'do not complain about existing broken links (commit)' ' some message EOF commit=$(git hash-object -t commit -w broken-commit) && - git gc -q 2>stderr && + git gc --no-cruft -q 2>stderr && verbose git cat-file -e $commit && test_must_be_empty stderr ' @@ -161,7 +161,7 @@ test_expect_success 'do not complain about existing broken links (tree)' ' 100644 blob $(test_oid 003) foo EOF tree=$(git mktree --missing stderr && + git gc --no-cruft -q 2>stderr && git cat-file -e $tree && test_must_be_empty stderr ' @@ -176,7 +176,7 @@ test_expect_success 'do not complain about existing broken links (tag)' ' this is a broken tag EOF tag=$(git hash-object -t tag -w broken-tag) && - git gc -q 2>stderr && + git gc --no-cruft -q 2>stderr && git cat-file -e $tag && test_must_be_empty stderr ' From patchwork Mon Apr 17 20:54:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13214713 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 6637CC77B72 for ; Mon, 17 Apr 2023 20:58:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231260AbjDQU6I (ORCPT ); Mon, 17 Apr 2023 16:58:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbjDQU5l (ORCPT ); Mon, 17 Apr 2023 16:57:41 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5140118C1 for ; Mon, 17 Apr 2023 13:55:25 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-54f21cdfadbso381312387b3.7 for ; Mon, 17 Apr 2023 13:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20221208.gappssmtp.com; s=20221208; t=1681764883; x=1684356883; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=v9K0Zbm+0644tvTFeKisoas+Ny/N05PQ+B08TiThMa0=; b=y6ltkwinPDNUXoH6Z5b4NZZugaXn+pkKSCDk8TEgJajnrSSIicj3P64b4OFehO6mEh a+9yk1hsgsWaDZoI2gDFbJggWsN9GiCA3DAZ3umV+P/E6Sc2wkWgZXCYp3BL7s0EtRVv AfqRhSdPDuLZz2Jqs2x5e5v1inqVmMz2TlpkHCNW2bOZcvaDey35TutSf9nuGAz/JV5n AYi0bYJGZmhPUpq2I+BYiLuVzTLsL/t3bu2+JSn0IO77hR/uOYhxBE0vU4Rcs6o4d/k4 qDoC2uXuIJdMtJnSwoBRUL5zFYgwZKkzvTq14BtdauLSAzF95znzUJhwetcBXXppc4Bx XVxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764883; x=1684356883; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=v9K0Zbm+0644tvTFeKisoas+Ny/N05PQ+B08TiThMa0=; b=IESPLn6kvbGlzRn8CiAESm3urbPTsqOdll7yxsovBLvbLxK3eWbB4/3iLdBlty/DSw 24J6H2lopSiWvDwxEKXCAfk/tF851oXXs8Jlz0wtOeJ7b3C3p7LtijVtm8cy0n4d1z8K wTZeQJbc7saL5PXO9FQnGCFdX+e1yVpF1OVI2PFW6IuSwqt7hCecUBf7fZaxz+pBlLuX kO3w/oPNRyUk/JbXy/NzUon1MI2TY7K+WXg2qas0emQ4lKi3LVpfNH6aILFbW1LiwDfm T9QgzCvPkZELnhCGWaVgfCvh9ILx84mZWS0x4VuMfTU5cLc+VVcLLYUB+ec+VOHpgZFe +hkA== X-Gm-Message-State: AAQBX9cPoR44ctFd42pigp12tIaJJisDBoNEJVyxB3M5yPL6Q401gQ/7 65K7hzMSmXAejmuyAHxeXoS/OscCvMV2C1AT4UxdnQ== X-Google-Smtp-Source: AKy350bgxLIl0Q+3lRzjdBzN1rwb0+GripJtU4VHI3S8CeB5MQMZyFKDBO8cDY6x//RJbra+PdDQvw== X-Received: by 2002:a81:1c91:0:b0:536:e8d6:9654 with SMTP id c139-20020a811c91000000b00536e8d69654mr19551017ywc.4.1681764882171; Mon, 17 Apr 2023 13:54:42 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id bf21-20020a05690c029500b0054f8a3624dbsm3290112ywb.145.2023.04.17.13.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:54:41 -0700 (PDT) Date: Mon, 17 Apr 2023 16:54:39 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Derrick Stolee , Junio C Hamano Subject: [PATCH 09/10] builtin/gc.c: make `gc.cruftPacks` enabled by default Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Back in 5b92477f89 (builtin/gc.c: conditionally avoid pruning objects via loose, 2022-05-20), `git gc` learned the `--cruft` option and `gc.cruftPacks` configuration to opt-in to writing cruft packs when collecting or pruning unreachable objects. Cruft packs were introduced with the merge in a50036da1a (Merge branch 'tb/cruft-packs', 2022-06-03). They address the problem of "loose object explosions", where Git will write out many individual loose objects when there is a large number of unreachable objects that have not yet aged past `--prune=`. Instead of keeping track of those unreachable yet recent objects via their loose object file's mtime, cruft packs collect all unreachable objects into a single pack with a corresponding `*.mtimes` file that acts as a table to store the mtimes of all unreachable objects. This prevents the need to store unreachable objects as loose as they age out of the repository, and avoids the problem of loose object explosions. Beyond avoiding loose object explosions, cruft packs also act as a more efficient mechanism to store unreachable objects as they age out of a repository. This is because pairs of similar unreachable objects serve as delta bases for one another. In 5b92477f89, the feature was introduced as experimental. Since then, GitHub has been running these patches in every repository generating hundreds of millions of cruft packs along the way. The feature is battle-tested, and avoids many pathological cases such as above. Users who either run `git gc` manually, or via `git maintenance` can benefit from having cruft packs. As such, enable cruft pack generation to take place by default (by making `gc.cruftPacks` have the default of "true" rather than "false). Signed-off-by: Taylor Blau --- Documentation/config/feature.txt | 3 --- Documentation/config/gc.txt | 2 +- Documentation/git-gc.txt | 5 +++-- Documentation/gitformat-pack.txt | 4 ++-- builtin/gc.c | 6 +----- t/t6500-gc.sh | 9 +++------ 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Documentation/config/feature.txt b/Documentation/config/feature.txt index e52bc6b858..17b4d39f89 100644 --- a/Documentation/config/feature.txt +++ b/Documentation/config/feature.txt @@ -14,9 +14,6 @@ feature.experimental:: + * `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by skipping more commits at a time, reducing the number of round trips. -+ -* `gc.cruftPacks=true` reduces disk space used by unreachable objects during -garbage collection, preventing loose object explosions. feature.manyFiles:: Enable config options that optimize for repos with many files in the diff --git a/Documentation/config/gc.txt b/Documentation/config/gc.txt index 8d5353e9e0..7f95c866e1 100644 --- a/Documentation/config/gc.txt +++ b/Documentation/config/gc.txt @@ -84,7 +84,7 @@ gc.packRefs:: gc.cruftPacks:: Store unreachable objects in a cruft pack (see linkgit:git-repack[1]) instead of as loose objects. The default - is `false`. + is `true`. gc.pruneExpire:: When 'git gc' is run, it will call 'prune --expire 2.weeks.ago' diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt index 2427478314..0b4e7ba882 100644 --- a/Documentation/git-gc.txt +++ b/Documentation/git-gc.txt @@ -54,9 +54,10 @@ other housekeeping tasks (e.g. rerere, working trees, reflog...) will be performed as well. ---cruft:: +--[no-]cruft:: When expiring unreachable objects, pack them separately into a - cruft pack instead of storing them as loose objects. + cruft pack instead of storing them as loose objects. `--cruft` + is on by default. --prune=:: Prune loose objects older than date (default is 2 weeks ago, diff --git a/Documentation/gitformat-pack.txt b/Documentation/gitformat-pack.txt index e06af02f21..0c1be2dbe8 100644 --- a/Documentation/gitformat-pack.txt +++ b/Documentation/gitformat-pack.txt @@ -611,8 +611,8 @@ result of repeatedly resetting the objects' mtimes to the present time. If you are GC-ing repositories in a mixed version environment, consider omitting the `--cruft` option when using linkgit:git-repack[1] and linkgit:git-gc[1], and -leaving the `gc.cruftPacks` configuration unset until all writers understand -cruft packs. +setting the `gc.cruftPacks` configuration to "false" until all writers +understand cruft packs. === Alternatives diff --git a/builtin/gc.c b/builtin/gc.c index 53ef137e1d..ece01e966f 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -48,7 +48,7 @@ static const char * const builtin_gc_usage[] = { static int pack_refs = 1; static int prune_reflogs = 1; -static int cruft_packs = -1; +static int cruft_packs = 1; static int aggressive_depth = 50; static int aggressive_window = 250; static int gc_auto_threshold = 6700; @@ -608,10 +608,6 @@ int cmd_gc(int argc, const char **argv, const char *prefix) if (prune_expire && parse_expiry_date(prune_expire, &dummy)) die(_("failed to parse prune expiry value %s"), prune_expire); - prepare_repo_settings(the_repository); - if (cruft_packs < 0) - cruft_packs = the_repository->settings.gc_cruft_packs; - if (aggressive) { strvec_push(&repack, "-f"); if (aggressive_depth > 0) diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index e7d3d1448f..75760866b4 100755 --- a/t/t6500-gc.sh +++ b/t/t6500-gc.sh @@ -216,11 +216,10 @@ assert_no_cruft_packs () { } for argv in \ + "gc" \ "gc --cruft" \ "-c gc.cruftPacks=true gc" \ - "-c gc.cruftPacks=false gc --cruft" \ - "-c feature.experimental=true gc" \ - "-c gc.cruftPacks=true -c feature.experimental=false gc" + "-c gc.cruftPacks=false gc --cruft" do test_expect_success "git $argv generates a cruft pack" ' test_when_finished "rm -fr repo" && @@ -246,9 +245,7 @@ done for argv in \ "gc --no-cruft" \ "-c gc.cruftPacks=false gc" \ - "-c gc.cruftPacks=true gc --no-cruft" \ - "-c feature.expiremental=true -c gc.cruftPacks=false gc" \ - "-c feature.experimental=false gc" + "-c gc.cruftPacks=true gc --no-cruft" do test_expect_success "git $argv does not generate a cruft pack" ' test_when_finished "rm -fr repo" && From patchwork Mon Apr 17 20:54:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13214714 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 6F71CC77B78 for ; Mon, 17 Apr 2023 20:58:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbjDQU6J (ORCPT ); Mon, 17 Apr 2023 16:58:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230468AbjDQU5l (ORCPT ); Mon, 17 Apr 2023 16:57:41 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 860244C10 for ; Mon, 17 Apr 2023 13:55:27 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-54fbb713301so190271197b3.11 for ; Mon, 17 Apr 2023 13:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20221208.gappssmtp.com; s=20221208; t=1681764885; x=1684356885; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=f8K8lizgoifAwA/PJTy4d9lD9cKZsgX0vjBcam+QEag=; b=1pt/mMkybErBr8CrACID7T5WDUU2mrglnmu1Ds+U+s6zEZDw2mywCdhbg5rq6SkETB gUT/yA6FLbSQ9XiFpGFtzg47oCNYHtJid2pH870/quZKUP4pnL5L3sgoAJU4V58nRgbt 4XFv2VH57rPP/her50a+BlfuWTyKfE6Dr0/hMMNcae9SKJBwUu0Py9cnXGal2EB33vE1 bOWarWg/VlHjU0nPTe78BNCC2pBCyTLhNko7QXStfcTY0+cz5j+Ffa9LE4zp5flgGKSz k4hgP7aP1MsJNuiSBGnx72wFjGNf1ohoIEY3Ql2i0lm3iKgiE5p55Pr5PpJUkW/6iC02 rUPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764885; x=1684356885; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=f8K8lizgoifAwA/PJTy4d9lD9cKZsgX0vjBcam+QEag=; b=XPt9+19KtSE+zQjn/p3LJOU/On88cwBtN/9PnsB8w1mFNglsANz2DzFIvAKVqzqNJ1 5o2bABU6Bbnck280g4x5ODg420lzWM5gsMujZJcgv3ys+tXIiBR0lfgzLL7eLGklNV5g yo7WZ1uNW7vE0KQs6F+ICB0e2UrxzE2KxN1PST0zPtfJf7noTUa1Hcr3BRCnn+pjXjST 2tm4J6nZpxvwLJ4BaOpQgde7l4uC3eIrRnIoDO05pRUTUQQcE6SHrzo3VmW69o0gzBkM Jz18LGv/dhBoYtlimDECGxCg8GaFMOEaLxYsDVJmE10iS8x1SCZ3e8vkOnJ+T/cv0y6w OVSQ== X-Gm-Message-State: AAQBX9dBoAMUixik9f8XETrIFIa7o/DtFfGuviKykI4i6N1yY7r/6/iB +b17jgBVQYLUFp5km9QXQt4Fk+tIyV5ZzFjqg2cN6w== X-Google-Smtp-Source: AKy350YkjuSvn7mMJjSaOycvI1lWvXOj044vh1oSVjZBFQRXFDW4Xzjbm2AQJBtvkzlxHVaTWM+qzw== X-Received: by 2002:a0d:db48:0:b0:54f:b7e1:8724 with SMTP id d69-20020a0ddb48000000b0054fb7e18724mr18558513ywe.1.1681764885058; Mon, 17 Apr 2023 13:54:45 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id b10-20020a81bd0a000000b0054bfc94a10dsm3335337ywi.47.2023.04.17.13.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:54:44 -0700 (PDT) Date: Mon, 17 Apr 2023 16:54:43 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Derrick Stolee , Junio C Hamano Subject: [PATCH 10/10] repository.h: drop unused `gc_cruft_packs` Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As of the previous commit, all callers that need to read the value of `gc.cruftPacks` do so outside without using the `repo_settings` struct, making its `gc_cruft_packs` unused. Drop it accordingly. Signed-off-by: Taylor Blau --- repo-settings.c | 4 +--- repository.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/repo-settings.c b/repo-settings.c index 0a6c0b381f..a8d0b98794 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -41,10 +41,8 @@ void prepare_repo_settings(struct repository *r) repo_cfg_bool(r, "feature.experimental", &experimental, 0); /* Defaults modified by feature.* */ - if (experimental) { + if (experimental) r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING; - r->settings.gc_cruft_packs = 1; - } if (manyfiles) { r->settings.index_version = 4; r->settings.index_skip_hash = 1; diff --git a/repository.h b/repository.h index 15a8afc5fb..50eb0ce391 100644 --- a/repository.h +++ b/repository.h @@ -33,7 +33,6 @@ struct repo_settings { int commit_graph_generation_version; int commit_graph_read_changed_paths; int gc_write_commit_graph; - int gc_cruft_packs; int fetch_write_commit_graph; int command_requires_full_index; int sparse_index;