From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 3C6761F4D8 for ; Wed, 18 May 2022 23:12:40 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=ttaylorr-com.20210112.gappssmtp.com header.i=@ttaylorr-com.20210112.gappssmtp.com header.b="c7fMKy4t"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231300AbiERXL3 (ORCPT ); Wed, 18 May 2022 19:11:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbiERXLR (ORCPT ); Wed, 18 May 2022 19:11:17 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ECAA1EAD9 for ; Wed, 18 May 2022 16:11:14 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id a10so4014907ioe.9 for ; Wed, 18 May 2022 16:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=J/R31/ebmQ4lbVegmp4wIsp5bWpx1GJe4uyhjKvlOFQ=; b=c7fMKy4t0jUQpqQWs5uNeaFNo6mllcransDTTL97XjPfVdJPu2yzYLEAAq3+UbaU+y 0sJF6DW6FrRXimVbZ1EJkiO1UYp5RePUVNEAZ6+ufyEDPpI8VlwZSbwC+JTmYl9nZb39 LqBSvx6AR+4nPuQ8w5HjbFI/lQyQEJ1GOMKusEuxQPryVGpZvzG4lRcr2vaMLdk6MhI/ Dzqaq8LUVoeDJoSae7AsYcJBh/RWkmIaae2TxRbaajIH6jYXvIY2Rc5ucRjSq/VMV5rR VsNWdd5zeToFZZ86Tc07rLMUXXMpcq/kLhfqk3J+tOVMwYXnIzAdM0M7dRyE2n1dSMak a74A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J/R31/ebmQ4lbVegmp4wIsp5bWpx1GJe4uyhjKvlOFQ=; b=Ekk4o1Y1f474BxMFcU6K43DGLzu+pCfManolWVXcywX7Ov0I3P6X+2VXswwm7rZKhN QQcfAT7ZYxTqSM5FtkbM227AMA1TIB6Udk1drqsI42+p1zJIO/2yQXOoQXmGVnQ8lZJr EPvYikrtcwE+cELDQzMuLRHCz4pCYBJmpeC8yJP12r1x54itSoKtwijgpUzG1uQGd7EH QdmN69VDyVHHdaGv92S1bbif3qDpKypbs15yapmYKm0VypFM0KX0JeVCMt6fECsprq5h kJLRty0p/1OzAeCGylZF3j7ynuLvlRUdgzM7w8FK9ayd/1cgS0xADv2+b1nHk8Fk17Hn 6mRw== X-Gm-Message-State: AOAM530Xw8KVHGHTQEeYnUuYAZTJDlwzgiBoj5DxXYyvTm7QMQyucagF rP0g3e0g2JzmWMVsV9nrUnN4JwjuMRWuv/IY X-Google-Smtp-Source: ABdhPJybas9kpoYcfmgn4hqfb5/tSDEY4rzVY1H1AIwH2fOt+P6Csu/DsqbjZtCDhReKHKu+mQ5o7Q== X-Received: by 2002:a05:6638:380e:b0:32e:6034:628d with SMTP id i14-20020a056638380e00b0032e6034628dmr1028980jav.227.1652915473035; Wed, 18 May 2022 16:11:13 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id s3-20020a92cc03000000b002cde6e352e4sm878570ilp.46.2022.05.18.16.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 16:11:12 -0700 (PDT) Date: Wed, 18 May 2022 19:11:12 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: avarab@gmail.com, derrickstolee@github.com, gitster@pobox.com, jrnieder@gmail.com, larsxschneider@gmail.com, tytso@mit.edu Subject: [PATCH v4 08/17] builtin/pack-objects.c: --cruft without expiration Message-ID: <94fe03cc65716b6102e2d71df49d4ae5a1a60dc7.1652915424.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Teach `pack-objects` how to generate a cruft pack when no objects are dropped (i.e., `--cruft-expiration=never`). Later patches will teach `pack-objects` how to generate a cruft pack that prunes objects. When generating a cruft pack which does not prune objects, we want to collect all unreachable objects into a single pack (noting and updating their mtimes as we accumulate them). Ordinary use will pass the result of a `git repack -A` as a kept pack, so when this patch says "kept pack", readers should think "reachable objects". Generating a non-expiring cruft packs works as follows: - Callers provide a list of every pack they know about, and indicate which packs are about to be removed. - All packs which are going to be removed (we'll call these the redundant ones) are marked as kept in-core. Any packs the caller did not mention (but are known to the `pack-objects` process) are also marked as kept in-core. Packs not mentioned by the caller are assumed to be unknown to them, i.e., they entered the repository after the caller decided which packs should be kept and which should be discarded. Since we do not want to include objects in these "unknown" packs (because we don't know which of their objects are or aren't reachable), these are also marked as kept in-core. - Then, we enumerate all objects in the repository, and add them to our packing list if they do not appear in an in-core kept pack. This results in a new cruft pack which contains all known objects that aren't included in the kept packs. When the kept pack is the result of `git repack -A`, the resulting pack contains all unreachable objects. Signed-off-by: Taylor Blau --- Documentation/git-pack-objects.txt | 30 ++++ builtin/pack-objects.c | 201 +++++++++++++++++++++++++- object-file.c | 2 +- object-store.h | 2 + t/t5329-pack-objects-cruft.sh | 218 +++++++++++++++++++++++++++++ 5 files changed, 448 insertions(+), 5 deletions(-) create mode 100755 t/t5329-pack-objects-cruft.sh diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index f8344e1e5b..a9995a932c 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -13,6 +13,7 @@ SYNOPSIS [--no-reuse-delta] [--delta-base-offset] [--non-empty] [--local] [--incremental] [--window=] [--depth=] [--revs [--unpacked | --all]] [--keep-pack=] + [--cruft] [--cruft-expiration=