From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3083BC433F5 for ; Mon, 29 Nov 2021 22:26:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232268AbhK2W3k (ORCPT ); Mon, 29 Nov 2021 17:29:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbhK2W24 (ORCPT ); Mon, 29 Nov 2021 17:28:56 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD421C09676F for ; Mon, 29 Nov 2021 14:25:24 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id e8so19081155ilu.9 for ; Mon, 29 Nov 2021 14:25:24 -0800 (PST) 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=lDsFe1jBg/drSQVHnwBdv3PUnKButsbHCmsHsdEdiYY=; b=uPPEYTFG85cmOw+Z+mVFxWhKcFoJVsk+HeIeK2QyBDWvewpyG475lIJThZBiqQQgq0 PQGv8auzKOucoz7CTecBzmM7PU8B3PCbVDB8VGuFFYySMQ+T3evTQqFTrYg74DCEEqbl +rPSK+rd6kAiUFguQReHpWQ0RUhIH0gVnY8vcxmppr4o4bKT877VogEla6ltTkM9KbtZ HRtSYMnz3gxxlAPItiNCAQcUiixJ9BEVmmQOqt1Fp7YbS8fLQmutrHKVyJ8MfCWnHi0s 8qbjcy0q+bYxq6ipwfV9VQGO76s/pBmBPlooTIRTa5xIGo2vVDzT0f5leBoOSkUwu/Cq orTA== 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=lDsFe1jBg/drSQVHnwBdv3PUnKButsbHCmsHsdEdiYY=; b=P8eKN7vDqE36V6bBLBR1FMePC5JOvpmol/aTr9IbLiqhU4Clvwuh4OXfEZPQZZWBWi v+672+qhtUZZ4enlEJqXM3/JTQYHBI3uDSSvb71RI+CJTYLwrpr4Ux5f9TR7QgzdBdIG UnoHdEw1tZGt4QcC3lerjxct8Ds3cxVGR0jBShyWzeG5oLLPBd6iscs33wEcrBedPZpA vn6XkNkC7u+yFmRHaQuSx2VhN3MZEL81J9Ag3zqdUcDOqokb4lK/dbPrkEk53ZCSMnIf OP66DN6v7RJdXhg9j/66UpVzJPvmdXNCbY6Zf7IlCByDvWbbIMTr7F685uwD59up854w i1hA== X-Gm-Message-State: AOAM531l3ZU+fbcCLvOpao4Qv4XqifL9bNZDnTXH+GOL63UHoGZpVQiG H8c5UoaURjRlfYNVKAr9o/PveUI1kPVJOmI1 X-Google-Smtp-Source: ABdhPJxuRZ2TBP38R4O2jw0SCIYIg14B69EucRAeY69qggoLtmcx8tdP/gHDsqhlMUFyhPRA32HiPA== X-Received: by 2002:a92:2811:: with SMTP id l17mr14527321ilf.149.1638224723869; Mon, 29 Nov 2021 14:25:23 -0800 (PST) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id g7sm7469205iln.67.2021.11.29.14.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 14:25:23 -0800 (PST) Date: Mon, 29 Nov 2021 17:25:22 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: gitster@pobox.com, larsxschneider@gmail.com, peff@peff.net, tytso@mit.edu Subject: [PATCH 08/17] builtin/pack-objects.c: --cruft without expiration Message-ID: <66165917a4660f63ce60b820d178d52a51304d20.1638224692.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, as well as any packs that `pack-objects` found but the caller did not specify. These packs are presumed to have entered the repository between the caller collecting packs and invoking `pack-objects`. Since we do not want to include objects in these 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 | 23 +++ builtin/pack-objects.c | 203 ++++++++++++++++++++++++++- object-file.c | 2 +- object-store.h | 2 + t/t5327-pack-objects-cruft.sh | 218 +++++++++++++++++++++++++++++ 5 files changed, 442 insertions(+), 6 deletions(-) create mode 100755 t/t5327-pack-objects-cruft.sh diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index dbfd1f9017..573c18afcd 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=