From patchwork Thu Oct 24 18:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 13849536 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A26A32003A8 for ; Thu, 24 Oct 2024 18:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793334; cv=none; b=qciwioP//crhsovsRDw3XDqxzEyWsx6S/RZI2ko5ClBazmhuc3oKyVQEcW7JzBUtl2gsjkBTo669gYPB4kiqgZeHyWAuJQaYrIxHmhslqZ6AhZHA/+jtvKq4FH2zzBMA2ZepQnB9RMI4RMetEcoP4KnArHsbyxLNX4C4spicfAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793334; c=relaxed/simple; bh=m+fY40M06lffNnAJ1OzhbOwsGkNJUbzrVm6pFyx8BUw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=c0zeUBlOJopbqQCh5SycSlsRrHiwsqzGvLJZ1YPxImZfojtmHzxR3D375tjxMUgwD70LALnKI5gPzXSSX0zuHlFuCFZROqskKf75xv5/CSP7LNs9oBEu+gano8UuHw9RVMSVwOe4pNTk2hc/2FQp0rs7xIaHwQaloYcJCY8JaZs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jonathantanmy.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bmeOkI8M; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jonathantanmy.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bmeOkI8M" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e2954ada861so2282785276.3 for ; Thu, 24 Oct 2024 11:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729793331; x=1730398131; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TiD9pb+i5iVYKZz4maAOXqyh5+IO4TjsdcmlK3H+66A=; b=bmeOkI8Mly7ih2E35NWK8XAEXS95QT4gxGfK3hV96Xk9Ypv8IIwKQv/1NtALcAfnpt bvLMFylsrjJgqm808nTwKHWdbzja+D/crNJQeFe6VMB15VRrom1WMCA8s75cr0Kx4BL4 BoI+K7ezEcfsR5kU730MdR+6n+vciZaoI7i6+U+ILaXmBa+3Dna4BBfdxeMx5x7+hZ/0 0KfWPVQLTOMdce6qFnhiySf6mguMflAOFQLUmBZ+Z7+Uvxd3LJYKkgGyjsPq4zsxYpbZ dw3rKZXVVPJ4FFmMoVQhOEG3U3TxS6oo5OOdRHGqIMco3RFmVcwsGqsxg85oM6WX0+Q4 uYEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793331; x=1730398131; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TiD9pb+i5iVYKZz4maAOXqyh5+IO4TjsdcmlK3H+66A=; b=je1b4TsGRjkIsIv9vILGxYnKZT7wQyoNjBxjdIfnmdOvCv2XzRgaKzwqBXWyOJ9eZL XiAS+kbP6IGY9zVQhouhud+tOvWHRpp3sO7wcrbyS6vzIQt155YxFi0eam3ZqWFk+eYj EbeIPL3F132K9RHG2kTriM7JCINdFA5lfjbFVOsZiV6gGCXLHKjHAb6zEZIwYLjt++E4 gBtQruuAlgkpI/7cGxz3I72GFwc2OQZxBUax3hOWbRcDh3oc9mPRXkm6AWRFefQF2ybK dp1JDheqY+R1V4x5nLrbhDl9LI7B/H/ag2veB0lesCrmBjCZueFw4rM224Il2zh2QpPg +ghw== X-Gm-Message-State: AOJu0YzXdWb1Aa/tBhPuO3/2XNij0BBOEdRl3aQqkwrgRGJfhry45e5u 6oTPmPQyRyZS65SqU5P7Zbl4eOLRh8eWbWJqNwWsg59s7oxQwQZnXYON+kVmJBRIgIut/wZGMSr fAp6GpSFH4t4uuEgmFlkiHSxG0/yKjfAqwdSgLUhlqTHJrdevzyqXRUuc98gQsGVpj8GSZ3p8y3 59kpzleaR8TnLOnaUwr/61xSPihQPYElZHJwMGI8SBvBowv3znl52SBdWwXyTIW0zQzA== X-Google-Smtp-Source: AGHT+IGeodZcrF0vCM0Uj1ABfYRth7WRehsoFyWvbmCFO13byxpPstJafdsHQ3Rn6ZaH3OPFeWFlCUbV1Kz5w03PXXBt X-Received: from jonathantanmy0.svl.corp.google.com ([2620:15c:2d3:204:3554:17cc:309d:28c9]) (user=jonathantanmy job=sendgmr) by 2002:a25:b113:0:b0:e2b:ce2f:787a with SMTP id 3f1490d57ef6-e2f2302ed44mr8054276.3.1729793331241; Thu, 24 Oct 2024 11:08:51 -0700 (PDT) Date: Thu, 24 Oct 2024 11:08:40 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Message-ID: Subject: [PATCH 1/5] pack-objects: make variable non-static From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , calvinwan@google.com, hanyang.tony@bytedance.com Signed-off-by: Jonathan Tan --- builtin/pack-objects.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 0fc0680b40..e15fbaeb21 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -238,8 +238,6 @@ static enum { } write_bitmap_index; static uint16_t write_bitmap_options = BITMAP_OPT_HASH_CACHE; -static int exclude_promisor_objects; - static int use_delta_islands; static unsigned long delta_cache_size = 0; @@ -4327,6 +4325,7 @@ int cmd_pack_objects(int argc, struct string_list keep_pack_list = STRING_LIST_INIT_NODUP; struct list_objects_filter_options filter_options = LIST_OBJECTS_FILTER_INIT; + int exclude_promisor_objects = 0; struct option pack_objects_options[] = { OPT_CALLBACK_F('q', "quiet", &progress, NULL, From patchwork Thu Oct 24 18:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 13849537 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B889200BBE for ; Thu, 24 Oct 2024 18:08:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793336; cv=none; b=OreHi30OT90+BFDIFP5SCCcy6yyhanxTtOgBOnWOOl2B7gdPHCCQhVa04HmBxCtGQkTs171D+62bQHYqioPakcws22DtNJUlmglTlp6t0IUoMXKaCASotQDOv80mLGz5V664aL8Nrcctcflt0DTf69tkYdag2psKA0eNjhoZdjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793336; c=relaxed/simple; bh=lu8JzHccqjbSGPWN5wp60tmQpAYxOLI0jgxmtQqFYFI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ZB/eu+7isJ+6YpXk46wDkbQR9tqgChBAqHrtjo3+E9M+DW5U1txWWTepWtt+PV55nXIRPxrhPgAqcRW6R6xFkycR98QT8VhftZ3zOlKwlIAFmbU7vZTojjotzK1E+CpARKHxpeWB1w9bfgrEk9N7h94Stw0doXMHwop7XMsWGrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jonathantanmy.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XmCJ6VgX; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jonathantanmy.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XmCJ6VgX" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e38562155bso19932087b3.1 for ; Thu, 24 Oct 2024 11:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729793333; x=1730398133; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=qArcyT9B1tS2X2BzAtvme6q83X0H/CDdvhzRr8ACm7k=; b=XmCJ6VgXXRGM+E2zMRZPuMfZ3cxx5pZKEXA4/tzH8qm0CcVID8259u4AGQD6NdAtw2 /vzMc/va26AQRJ0eVHjMvGfBZK4+nOPi+0gcDH0XiIuKpz1NgcAVe+qP5l+tDlxripgL bRPWzmEBxmEb/qSdSmOJCNWYLn6dJPabIAvLjXAz2zY4K8ff8K2/yVx4VKUms/2Ayvhi 3F/t3ghtTCR6MjQg7LQj43o+FwfQCTTaXNrAob/CbL2vmwvDfNouFEDnJg2f4tyCyrBR WU/CAX8vfHym5Ct780GjwoRNHlEw4/tN3hLhLoLs4fS/gftMetyl7dCep7HbX4QsEHDM xFzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793333; x=1730398133; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qArcyT9B1tS2X2BzAtvme6q83X0H/CDdvhzRr8ACm7k=; b=ocbRrsoMU/kMvB949jnTxBmaSIl6ktAhNoN6w2H4sHVy9hVXWchB4dPyRykuy4AeVB MOxMpzevmH0N8uroPhFm9fIyav3VIxyRALmmwUmbMCbZon6FxF5EWU7GBj6HG+Rz9+b6 pNKRoofAXOcR6kvbsdRWwQxG3BS4mmAt6pn5CDdc+iDbspRXn0Tf4R2BfBSk20R572JS j8dx/aDMKw7vaFTPMXrYjzp3GQJzULjvjun/I5OlL+B3GwyUD6J2rVK357ypGjceuxmC vNPfBfuoPMMVobfHzCYHMTkex7drfeY3UBdCgvrNAi+tIrhF6qupyYbUtfcr1y8V01lz A+vA== X-Gm-Message-State: AOJu0YwoMvvtYTZR3yCJXeHkOH8NrcKpsYfUs1aMgAhCmJcCKK7ugZ2y v0DkqTKxYJ8QtVw4gKVAVyC6DAJnkzHf8TGSlxhtTEUva6DmbWpbp7AkJRAItzym/Tb41axpJxm rR3fVatCrTNMF9tuoAHx2Xen/W6lYiCPCGv+eXH0pf8L6M0RfpfjH1OESNf/Oh0UOKlE1yfC/vF RkSm5qRF+UzTEei5E55ZDU/DiV1+vF8QwtEj3lVlMPItCNm0VQsck1Tt86Dawz/Jmd4g== X-Google-Smtp-Source: AGHT+IFVSLV/f8xsxbgph6Z0IKenor3WBChOCwyF7woO9CadXbVtY8BKOY3WLYNRtZaWfSUT3XhOWcTw0ZYNiaBWkP6W X-Received: from jonathantanmy0.svl.corp.google.com ([2620:15c:2d3:204:3554:17cc:309d:28c9]) (user=jonathantanmy job=sendgmr) by 2002:a25:d810:0:b0:e29:7479:402a with SMTP id 3f1490d57ef6-e2f2fc4964dmr3307276.10.1729793332977; Thu, 24 Oct 2024 11:08:52 -0700 (PDT) Date: Thu, 24 Oct 2024 11:08:41 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Message-ID: Subject: [PATCH 2/5] t0410: make test description clearer From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , calvinwan@google.com, hanyang.tony@bytedance.com Commit 9a4c507886 (t0410: test fetching from many promisor remotes, 2019-06-25) adds some tests that demonstrate not the automatic fetching of missing objects, but the direct fetching from another promisor remote (configured explicitly in one test and implicitly via --filter on the "git fetch" CLI invocation in the other test) - thus demonstrating support for multiple promisor remotes, as described in the commit message. Change the test descriptions accordingly to make this clearer. Signed-off-by: Jonathan Tan --- t/t0410-partial-clone.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index 818700fbec..eadb69473f 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -241,7 +241,7 @@ test_expect_success 'fetching of missing objects works with ref-in-want enabled' grep "fetch< fetch=.*ref-in-want" trace ' -test_expect_success 'fetching of missing objects from another promisor remote' ' +test_expect_success 'fetching from another promisor remote' ' git clone "file://$(pwd)/server" server2 && test_commit -C server2 bar && git -C server2 repack -a -d --write-bitmap-index && @@ -264,7 +264,7 @@ test_expect_success 'fetching of missing objects from another promisor remote' ' grep "$HASH2" out ' -test_expect_success 'fetching of missing objects configures a promisor remote' ' +test_expect_success 'fetching with --filter configures a promisor remote' ' git clone "file://$(pwd)/server" server3 && test_commit -C server3 baz && git -C server3 repack -a -d --write-bitmap-index && From patchwork Thu Oct 24 18:08:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 13849538 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8827201012 for ; Thu, 24 Oct 2024 18:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793337; cv=none; b=X0tsfIIvawNo+DOJxsjlb1zWmxv095H/G4JlBZhOgSxy/tvHE5c5XRr6AWQ8gPG+1jm2d2ey4byxFKbDNqYnxyZ7ne10dsMTv415E9ts95s4YzffypyyJOPhIBx3NCWZrulW3OM2biJFnkCg3+iQ46UGN6doN2e1Wu5sY2l98+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793337; c=relaxed/simple; bh=CBY6ZRcItV8jd3RaKg0oqcyEvANKGc3oambRlLKpO88=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AYQibLvPt8FffD6fk8OiWbkFokmqyBWWUnV4NidBpg306LkC2Sjq5JT1iN+wVN1HhL9ELB6S8VEyjOFbXPWG26sy+OPybipQr/PlqZaAZewIfdK1K1DK4U0A3yAhBgj65wSJ2syelFtD8khAbelPE/0vR7WuPQrGtIqjfeVhSkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jonathantanmy.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=j1N2dYVQ; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jonathantanmy.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="j1N2dYVQ" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e59dc7df64so15503167b3.1 for ; Thu, 24 Oct 2024 11:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729793335; x=1730398135; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=IenHT4ncR9jBiOFQaeJAxLJEe8uXsfg94YgBvVnmQAs=; b=j1N2dYVQdPij/JKyAUjch66BcXX1oaPzhuLBy08r5pqLrTIaiPRb+4KagHzxSgGPWX zFJWVAogI0G070KS/9xc1awqlR/OzfAzKWu3DaMOAiF9Cb+GLD2QVNf+RKcAN5lFFyyE xLIlA55BuhWcCO5deEGuAxtrXUO0ssteTzNzRWVASyjcMPfp5eBSz8IS+ZwVyeTfAm/b WC2kH8ydz+jBBqZb8j8RiwhqvEVFj2hnA4U4+t2gLY9Q85e/UHlA8+R3ru222pNcpRro LIBKC4Hvzivvwo8NE8hczvXGM1Kn1UygCTu2dGeT4sEKDLffJc/ulmM4nPYohlS948dR c7CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793335; x=1730398135; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IenHT4ncR9jBiOFQaeJAxLJEe8uXsfg94YgBvVnmQAs=; b=XHb4Ww2GmBmadKMEKIbbM6IYIc9PhGgv33ObdGkTqz/sqp0kx5yGp+JjhDPvhbOFLt D5nSlJFN3BjpddqsgjfXUNhNkwc8skX7Sv+dQv3xMNzoxbbLwGLD5eLswWLEeIYsftF2 z4xMrDzDInZjtT8h9pYGD6o9MCf4LCTcX3iqAKWvDIXfPJ1VCN+DS+9nXnLtfZVtHR1H yDZf8v1Q1l+WzgnSs4IFB4zzy0F2tSeaEgnXnGD92ZBWWIgtDklL7J59iHgUQO88ZITJ PnWzIi1uw+7nne6ZPZLqAfx71VWfbSyFke/C2mGgrt0koJi0OFZGEC91E2APs6QCWvnE Lj/Q== X-Gm-Message-State: AOJu0YxxFOO3vBiQ6zXLSJ7ieR9xMVcLd2C+sx+WX9UjAWP82n4vg94S y+Bv58Z85OnzyfpRw0Qi8++JbPLp9NwzpHHF38HV+bsOLblrLkicDPRrw0ipiy2Ww3zHYenqGvy +E0zE+PXU4uxGi1dYmH4T6TeUUHgRsH0aOgbLwsVh/kUqfhmgtyaKoBl1UpIbgFhhYfCxTP8Bxc C4EcshWqgFb71yn3rjGskN9iEQzgTBI4jwSfphOGWogzipojqecJGMqheTQoQSJYgqyg== X-Google-Smtp-Source: AGHT+IHbfLt8oC509odXwuprq4J3IqN6Mcype+VnXhtJ5Qa9OQqAjaNFsidXVrWlm/ZadyiyEdBH02ePfq5NcABM+8ZG X-Received: from jonathantanmy0.svl.corp.google.com ([2620:15c:2d3:204:3554:17cc:309d:28c9]) (user=jonathantanmy job=sendgmr) by 2002:a05:690c:3387:b0:6dd:bb6e:ec89 with SMTP id 00721157ae682-6e8792879e5mr1027837b3.2.1729793334771; Thu, 24 Oct 2024 11:08:54 -0700 (PDT) Date: Thu, 24 Oct 2024 11:08:42 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Message-ID: <08750988e0498db7de9b3c8766137592adb84194.1729792911.git.jonathantanmy@google.com> Subject: [PATCH 3/5] t0410: use from-scratch server From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , calvinwan@google.com, hanyang.tony@bytedance.com A subsequent commit will add functionality: when fetching from a promisor remote, existing non-promisor objects that are ancestors of any fetched object will be repacked into promisor packs (since if a promisor remote has an object, it also has all its ancestors). This means that sometimes, a fetch from a promisor remote results in 2 new promisor packs (instead of the 1 that you would expect). There is a test that fetches a descendant of a local object from a promisor remote, but also specifically tests that there is exactly 1 promisor pack as a result of the fetch. This means that this test will fail when the subsequent commit is added. Since the ancestry of the fetched object is not the concern of this test, make the fetched objects have no ancestry in common with the objets in the client repo. This is done by making the server from scratch, instead of using an existing repo that has objects in common with the client. Signed-off-by: Jonathan Tan --- t/t0410-partial-clone.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index eadb69473f..e2b317db65 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -265,7 +265,7 @@ test_expect_success 'fetching from another promisor remote' ' ' test_expect_success 'fetching with --filter configures a promisor remote' ' - git clone "file://$(pwd)/server" server3 && + test_create_repo server3 && test_commit -C server3 baz && git -C server3 repack -a -d --write-bitmap-index && HASH3=$(git -C server3 rev-parse baz) && From patchwork Thu Oct 24 18:08:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 13849539 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E9DF201019 for ; Thu, 24 Oct 2024 18:08:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793339; cv=none; b=u20YRVh2aV5FGnlaDAWoBVzAjXghwdF2iEi/oKmankAZfubv6kRNF5z7iPLR8+OtegTrW2Frv0tUyEJ26s7T7whYViFZ57xq/p19vcWMagOtf6uk1X7/HbC13ttNxW1kkYbZz+02dOHZL7KBAZ5QcKuamz3vt/rem482w0h2Oqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793339; c=relaxed/simple; bh=MT35PItDqDIxgCQxfKH+QfFAmPdf1PeByGLje6WRoWo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rhAfSFZsSSfT6qKvVOL2dWlTkaynQULR4UDcb8bTvyfmcfhwO2x/NJ1EzCvlZYcq234S8it8MesxahGswXF+3VnWofYnNhqMCsMY4c8nYpb1kQ0b9yXnyIzaQvzEaKk7TRFfD04LPlyJx0S5cGH9wyVNLyHegqsPQhzDJw355iM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jonathantanmy.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IoG1bQod; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jonathantanmy.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IoG1bQod" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e355f1ff4bso22706517b3.2 for ; Thu, 24 Oct 2024 11:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729793336; x=1730398136; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=rsd80GHaUtupo/563Ne78tyyAJqH7sbFStokHjf9UPw=; b=IoG1bQod/6+UuGCaIpF62cfdR5qrDqqBOzHsm2oJSisiyZxRYg04H8p7bQsXEUjGwQ vVs115adEwxy24g/V+i+AcDz3wWb1bTJLicXHmffOvTdDFrp1IXqb1qKjj0oWdB1BOAC /Ic/GTlAMK3acUPfsq5Q/O+GwF/2dhDyGcDtAXj+U0EOo3YkFrLeec0UEkvxuAPptOpx RHwY/tFezhg75M560zwZbmgM/zXqnc8Q7XjgD28CocqSqQyVlrhO5oMbGpEglIOtLxQ/ uePEoI+wpeXEHapQU1sJa+QVTieXrieiGWP0pBVh50X+B7YUUq7xrALw7DQkZqIOt5IU IeRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793336; x=1730398136; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rsd80GHaUtupo/563Ne78tyyAJqH7sbFStokHjf9UPw=; b=FhaODn12pSKaOdefTkWt3a1XHTPkJbODUB0BlVkvF0ZHgr/6DkIN1TDUgG8RV0Uiog F/pIaKWWED0U5pQTZCJslKd2u+2SJYLrrFURjyBA7d436CQ19mYMjnNMGH48rt6p1tpB +0wsg/hSHKOtX/41fW8PEFwyns5xycQxy2wVeZtrSj+/U71zJNQ7c6moAtbE1ZUW9v+l hTP/+VWK5pf/GIzU61vz706XYEyHu/cCnZ/m0aBkn02aLF6mw0U+pWuvS5gb5KkC3Vz7 8O5o60JTM+gY2h+RJ7Osc2Ip9ufbqAxvdF6+QvdfFBx0SjiEjyu78NyL1VwmDhkMhSdQ MvYQ== X-Gm-Message-State: AOJu0YyVOOUVvGYO+mf2xqy6YJ/oFBQsdcTqX/tYKHbuBVWXAzZYpJKY kFbR9WhASh0V1r9RjICg47RS/ItwAWaFwnHA+ZK9ibB0U/7jq1iOY0Ff7UWNdY/RkdBA/6SAppK T+T0Ae4YP6cvjuuwIRfZ8ABQCmILnLdCMA/EicYst19xytPsbDOVWHs0+RB4L9ypvsjPFh+lchs QKg2ZtmQCadUDmMkTr3LOurYS1CMWEHOVbtVdxNA2m7eCsFQssvPxcZIjBM46Qqk5gcg== X-Google-Smtp-Source: AGHT+IEs8Qq8jGHw2dqIqPn+UUpFXC9vcQ0PJ9GazHcDBfG4udJfkLSSu1Svq85c28nn85YnNitmLa/ViQ/CgOoXmhg/ X-Received: from jonathantanmy0.svl.corp.google.com ([2620:15c:2d3:204:3554:17cc:309d:28c9]) (user=jonathantanmy job=sendgmr) by 2002:a05:690c:9c10:b0:6e3:2bc1:da17 with SMTP id 00721157ae682-6e8663023bbmr1897467b3.4.1729793336470; Thu, 24 Oct 2024 11:08:56 -0700 (PDT) Date: Thu, 24 Oct 2024 11:08:43 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Message-ID: <85fc3fa77e1df835721bc702c6e1df92e7b5b4bf.1729792911.git.jonathantanmy@google.com> Subject: [PATCH 4/5] t5300: move --window clamp test next to unclamped From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , calvinwan@google.com, hanyang.tony@bytedance.com A subsequent commit will change the behavior of "git index-pack --promisor", which is exercised in "build pack index for an existing pack", causing the unclamped and clamped versions of the --window test to exhibit different behavior. Move the clamp test closer to the unclamped test that it references. Signed-off-by: Jonathan Tan --- t/t5300-pack-object.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 3b9dae331a..aff164ddf8 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -156,6 +156,11 @@ test_expect_success 'pack without delta' ' check_deltas stderr = 0 ' +test_expect_success 'negative window clamps to 0' ' + git pack-objects --progress --window=-1 neg-window stderr && + check_deltas stderr = 0 +' + test_expect_success 'pack-objects with bogus arguments' ' test_must_fail git pack-objects --window=0 test-1 blah blah stderr && - check_deltas stderr = 0 -' - for hash in sha1 sha256 do test_expect_success "verify-pack with $hash packfile" ' From patchwork Thu Oct 24 18:08:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 13849540 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A26C2010E5 for ; Thu, 24 Oct 2024 18:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793342; cv=none; b=n5POSkWqXmY72RJ/ORvib7kANXzZfHocGS5sHxRI7u21LIc79KKT+jc17A17eozskKy41Zqz1KDF8u4Sk0jTYqpa4ezXn/shQvPlLetxR5EAdRRegYyMM9RdcpfG0zh97ksk7/24NyTin/DLIPiVC5RGOIHzzOqT5N7mx2E57ac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793342; c=relaxed/simple; bh=bpkPEVwIDU/x2OFnzj3kBbZlU0SHN2oG4/tI5EakEr8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=r2ahRV126+qy6RVuuyqApypmLkFxxY+3Vcx8OqMUmhIXqLHJPE2iORWaLXXjOUuORrTysBNEvuSep2Za07EcbMcXw9UH0q75EZih88LsHiEe5GGnTPrQjncT83bXwPcsjxFddfdrPCarTkcUYCXSefjPcaR45rCnU6vS0Y6eMh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jonathantanmy.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=O8vepBnz; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jonathantanmy.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="O8vepBnz" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e7e7568ed3so28430957b3.1 for ; Thu, 24 Oct 2024 11:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729793338; x=1730398138; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=i+15GglqQmFUYeNryOd6fkUWo33t1bFbXyeOXfj1z/c=; b=O8vepBnz/80tR0A2QJmbkIEj9TL8d1FtFTZEWq+PSqcavktS+ieJjT5IwREkmp0qhW 8z0yke28TaaD+eRfjd63aZuXPxY3AHl6dYGy+qqoZFU0zENezf3YABoIdjg/Vg9r+N2+ KqNE0IT0yCEohYOwbCYjKI1g96eBYjI8ylBeEVVBgQjDicCPHi3Cu46fvtqVRz2EDfG9 uOINRR0ovCxiNZWPGZL2Z1ZN3eetx+y6I+6yzmNfhW/YCvpLQ4ipH/VZ7RF5mF/OBMy2 00129L0WClyFql1mC8IYA30920Sp/NduMPuovWkTcj3hYWaJXsnoiX4qicvB6ebllIDE K0hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793338; x=1730398138; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i+15GglqQmFUYeNryOd6fkUWo33t1bFbXyeOXfj1z/c=; b=ExjI4LxxgwoiLOqKvRBlv6pu/t/g+MZCTCfTcRsDNYQ6CuiwgOG+ODJSNjI6XU50VO /UHB1zvc/TDJyvPjM1hZNyxiHB80WX5rHtA3GpAfZvnXyA99kc+6O07qSvAJK89VsvtC UMKMfb/h0hLWzeqSgWs4clXOmr4OEnmN7cS/2qsJJudA6iL3INaPOP2YXIk76C9pP+Wr TrXbR1VUZO/Eq+e40jV0dRblMBjQmk7GmiOCcxG5MzcuEsFH/aVjQQ/wf+r0JqHRnKbk n+N2PctZG/3bOH/WEYebOC69y1YY4+z7KyBN1xX+K0k4W8McpSY8jmOlK/iIjwpqL0iL 2mWg== X-Gm-Message-State: AOJu0YwNrNgEjQoSXtShJrfX6hcwz+i4W6cQYFogh/K1IqBdjPLc6rN2 VC6lVMBV/cPhQMLKMMwQCXNxoQyDwz8LVI6nX8FjCEKyX26sNpe2o15B9qXvYSnI2Js/i17qIMn bgUn4zgpPVXIiXXA5yXQRPjVI9quxl3SLlvD+gaLEsqnjBYNhCC2h+/47PexNooa5DM21p/uN8I 6l2GWLnUo/p0rQiExhcZa2TV65L7MgQMJuu2J6Vzxks2vXMwE0r6eeKzKr5sZi/KDnXQ== X-Google-Smtp-Source: AGHT+IFppQXnoqbbMzvhCDqbserr2wuwjeVWVWneJGKJGnsW5JtP7FvllnAtWBgr2+BGBM8uJ9l6bSWeDuCnTpbwgcld X-Received: from jonathantanmy0.svl.corp.google.com ([2620:15c:2d3:204:3554:17cc:309d:28c9]) (user=jonathantanmy job=sendgmr) by 2002:a25:9703:0:b0:e29:7454:e773 with SMTP id 3f1490d57ef6-e2eb86e273fmr33609276.5.1729793338229; Thu, 24 Oct 2024 11:08:58 -0700 (PDT) Date: Thu, 24 Oct 2024 11:08:44 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Message-ID: <5dd7fdc16df7757ee1b24997ad9fbe3f923d5e93.1729792911.git.jonathantanmy@google.com> Subject: [PATCH 5/5] index-pack: repack local links into promisor packs From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , calvinwan@google.com, hanyang.tony@bytedance.com Teach index-pack to, when processing the objects in a pack with --promisor specified on the CLI, repack local objects (and the local objects that they refer to, recursively) referenced by these objects into promisor packs. This prevents the situation in which, when fetching from a promisor remote, we end up with promisor objects (newly fetched) referring to non-promisor objects (locally created prior to the fetch). This situation may arise if the client had previously pushed objects to the remote, for example. One issue that arises in this situation is that, if the non-promisor objects become inaccessible except through promisor objects (for example, if the branch pointing to them has moved to point to the promisor object that refers to them), then GC will garbage collect them. There are other ways to solve this, but the simplest seems to be to enforce the invariant that we don't have promisor objects referring to non-promisor objects. This repacking is done from index-pack to minimize the performance impact. During a fetch, the only time most objects are fully inflated in memory is when their object ID is computed, so we also scan the objects (to see which objects they refer to) during this time. Also to minimize the performance impact, an object is calculated to be local if it's a loose object or present in a non-promisor pack. (If it's also in a promisor pack or referred to by an object in a promisor pack, it is technically already a promisor object. But a misidentification of a promisor object as a non-promisor object is relatively benign here - we will thus repack that promisor object into a promisor pack, duplicating it in the object store, but there is no correctness issue, just an issue of inefficiency.) Signed-off-by: Jonathan Tan --- Documentation/git-index-pack.txt | 5 ++ builtin/index-pack.c | 110 ++++++++++++++++++++++++++++++- builtin/pack-objects.c | 28 ++++++++ t/t5616-partial-clone.sh | 30 +++++++++ 4 files changed, 171 insertions(+), 2 deletions(-) diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt index 5a20deefd5..4be09e58e7 100644 --- a/Documentation/git-index-pack.txt +++ b/Documentation/git-index-pack.txt @@ -139,6 +139,11 @@ include::object-format-disclaimer.txt[] written. If a `` is provided, then that content will be written to the .promisor file for future reference. See link:technical/partial-clone.html[partial clone] for more information. ++ +Also, if there are objects in the given pack that references non-promisor +objects (in the repo), repacks those non-promisor objects into a promisor +pack. This avoids a situation in which a repo has non-promisor objects that are +accessible through promisor objects. NOTES ----- diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 9d23b41b3a..e4afd6725f 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -9,6 +9,7 @@ #include "csum-file.h" #include "blob.h" #include "commit.h" +#include "tag.h" #include "tree.h" #include "progress.h" #include "fsck.h" @@ -20,9 +21,14 @@ #include "object-file.h" #include "object-store-ll.h" #include "oid-array.h" +#include "oidset.h" +#include "path.h" #include "replace-object.h" +#include "tree-walk.h" #include "promisor-remote.h" +#include "run-command.h" #include "setup.h" +#include "strvec.h" static const char index_pack_usage[] = "git index-pack [-v] [-o ] [--keep | --keep=] [--[no-]rev-index] [--verify] [--strict[==...]] [--fsck-objects[==...]] ( | --stdin [--fix-thin] [])"; @@ -148,6 +154,13 @@ static uint32_t input_crc32; static int input_fd, output_fd; static const char *curr_pack; +/* + * local_links is guarded by read_mutex, and record_local_links is read-only in + * a thread. + */ +static struct oidset local_links = OIDSET_INIT; +static int record_local_links; + static struct thread_local *thread_data; static int nr_dispatched; static int threads_active; @@ -799,6 +812,44 @@ static int check_collison(struct object_entry *entry) return 0; } +static void record_if_local_object(const struct object_id *oid) +{ + struct object_info info = OBJECT_INFO_INIT; + if (oid_object_info_extended(the_repository, oid, &info, 0)) + /* Missing; assume it is a promisor object */ + return; + if (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor) + return; + oidset_insert(&local_links, oid); +} + +static void do_record_local_links(struct object *obj) +{ + if (obj->type == OBJ_TREE) { + struct tree *tree = (struct tree *)obj; + struct tree_desc desc; + struct name_entry entry; + if (init_tree_desc_gently(&desc, &tree->object.oid, + tree->buffer, tree->size, 0)) + /* + * Error messages are given when packs are + * verified, so do not print any here. + */ + return; + while (tree_entry_gently(&desc, &entry)) + record_if_local_object(&entry.oid); + } else if (obj->type == OBJ_COMMIT) { + struct commit *commit = (struct commit *) obj; + struct commit_list *parents = commit->parents; + + for (; parents; parents = parents->next) + record_if_local_object(&parents->item->object.oid); + } else if (obj->type == OBJ_TAG) { + struct tag *tag = (struct tag *) obj; + record_if_local_object(get_tagged_oid(tag)); + } +} + static void sha1_object(const void *data, struct object_entry *obj_entry, unsigned long size, enum object_type type, const struct object_id *oid) @@ -845,7 +896,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, free(has_data); } - if (strict || do_fsck_object) { + if (strict || do_fsck_object || record_local_links) { read_lock(); if (type == OBJ_BLOB) { struct blob *blob = lookup_blob(the_repository, oid); @@ -877,6 +928,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, die(_("fsck error in packed object")); if (strict && fsck_walk(obj, NULL, &fsck_options)) die(_("Not all child objects of %s are reachable"), oid_to_hex(&obj->oid)); + if (record_local_links) + do_record_local_links(obj); if (obj->type == OBJ_TREE) { struct tree *item = (struct tree *) obj; @@ -1719,6 +1772,57 @@ static void show_pack_info(int stat_only) free(chain_histogram); } +static void repack_local_links(void) +{ + struct child_process cmd = CHILD_PROCESS_INIT; + FILE *out; + struct strbuf line = STRBUF_INIT; + struct oidset_iter iter; + struct object_id *oid; + char *base_name; + + if (!oidset_size(&local_links)) + return; + + base_name = mkpathdup("%s/pack/pack", repo_get_object_directory(the_repository)); + + strvec_push(&cmd.args, "pack-objects"); + strvec_push(&cmd.args, "--exclude-promisor-objects-best-effort"); + strvec_push(&cmd.args, base_name); + cmd.git_cmd = 1; + cmd.in = -1; + cmd.out = -1; + if (start_command(&cmd)) + die(_("could not start pack-objects to repack local links")); + + oidset_iter_init(&local_links, &iter); + while ((oid = oidset_iter_next(&iter))) { + if (write_in_full(cmd.in, oid_to_hex(oid), the_hash_algo->hexsz) < 0 || + write_in_full(cmd.in, "\n", 1) < 0) + die(_("failed to feed local object to pack-objects")); + } + close(cmd.in); + + out = xfdopen(cmd.out, "r"); + while (strbuf_getline_lf(&line, out) != EOF) { + unsigned char binary[GIT_MAX_RAWSZ]; + if (line.len != the_hash_algo->hexsz || + !hex_to_bytes(binary, line.buf, line.len)) + die(_("index-pack: Expecting full hex object ID lines only from pack-objects.")); + + /* + * pack-objects creates the .pack and .idx files, but not the + * .promisor file. Create the .promisor file, which is empty. + */ + write_special_file("promisor", "", NULL, binary, NULL); + } + + fclose(out); + if (finish_command(&cmd)) + die(_("could not finish pack-objects to repack local links")); + strbuf_release(&line); +} + int cmd_index_pack(int argc, const char **argv, const char *prefix, @@ -1794,7 +1898,7 @@ int cmd_index_pack(int argc, } else if (skip_to_optional_arg(arg, "--keep", &keep_msg)) { ; /* nothing to do */ } else if (skip_to_optional_arg(arg, "--promisor", &promisor_msg)) { - ; /* already parsed */ + record_local_links = 1; } else if (starts_with(arg, "--threads=")) { char *end; nr_threads = strtoul(arg+10, &end, 0); @@ -1970,6 +2074,8 @@ int cmd_index_pack(int argc, free((void *) curr_index); free(curr_rev_index); + repack_local_links(); + /* * Let the caller know this pack is not self contained */ diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index e15fbaeb21..a565ab9b40 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -4310,6 +4310,18 @@ static int option_parse_cruft_expiration(const struct option *opt UNUSED, return 0; } +static int should_include_obj(struct object *obj, void *data UNUSED) +{ + struct object_info info = OBJECT_INFO_INIT; + if (oid_object_info_extended(the_repository, &obj->oid, &info, 0)) + BUG("should_include_obj should only be called on existing objects"); + return info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor; +} + +static int should_include(struct commit *commit, void *data) { + return should_include_obj((struct object *) commit, data); +} + int cmd_pack_objects(int argc, const char **argv, const char *prefix, @@ -4326,6 +4338,7 @@ int cmd_pack_objects(int argc, struct list_objects_filter_options filter_options = LIST_OBJECTS_FILTER_INIT; int exclude_promisor_objects = 0; + int exclude_promisor_objects_best_effort = 0; struct option pack_objects_options[] = { OPT_CALLBACK_F('q', "quiet", &progress, NULL, @@ -4423,6 +4436,9 @@ int cmd_pack_objects(int argc, option_parse_missing_action), OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects, N_("do not pack objects in promisor packfiles")), + OPT_BOOL(0, "exclude-promisor-objects-best-effort", + &exclude_promisor_objects_best_effort, + N_("implies --missing=allow-any")), OPT_BOOL(0, "delta-islands", &use_delta_islands, N_("respect islands during delta compression")), OPT_STRING_LIST(0, "uri-protocol", &uri_protocols, @@ -4503,10 +4519,18 @@ int cmd_pack_objects(int argc, strvec_push(&rp, "--unpacked"); } + if (exclude_promisor_objects && exclude_promisor_objects_best_effort) + die(_("options '%s' and '%s' cannot be used together"), + "--exclude-promisor-objects", "--exclude-promisor-objects-best-effort"); if (exclude_promisor_objects) { use_internal_rev_list = 1; fetch_if_missing = 0; strvec_push(&rp, "--exclude-promisor-objects"); + } else if (exclude_promisor_objects_best_effort) { + use_internal_rev_list = 1; + fetch_if_missing = 0; + option_parse_missing_action(NULL, "allow-any", 0); + /* revs configured below */ } if (unpack_unreachable || keep_unreachable || pack_loose_unreachable) use_internal_rev_list = 1; @@ -4626,6 +4650,10 @@ int cmd_pack_objects(int argc, repo_init_revisions(the_repository, &revs, NULL); list_objects_filter_copy(&revs.filter, &filter_options); + if (exclude_promisor_objects_best_effort) { + revs.include_check = should_include; + revs.include_check_obj = should_include_obj; + } get_object_list(&revs, rp.nr, rp.v); release_revisions(&revs); } diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh index c53e93be2f..2e67f59f89 100755 --- a/t/t5616-partial-clone.sh +++ b/t/t5616-partial-clone.sh @@ -694,6 +694,36 @@ test_expect_success 'lazy-fetch in submodule succeeds' ' git -C client restore --recurse-submodules --source=HEAD^ :/ ' +test_expect_success 'after fetching descendants of non-promisor commits, gc works' ' + # Setup + git init full && + git -C full config uploadpack.allowfilter 1 && + git -C full config uploadpack.allowanysha1inwant 1 && + touch full/foo && + git -C full add foo && + git -C full commit -m "commit 1" && + git -C full checkout --detach && + + # Partial clone and push commit to remote + git clone "file://$(pwd)/full" --filter=blob:none partial && + echo "hello" > partial/foo && + git -C partial commit -a -m "commit 2" && + git -C partial push && + + # gc in partial repo + git -C partial gc --prune=now && + + # Create another commit in normal repo + git -C full checkout main && + echo " world" >> full/foo && + git -C full commit -a -m "commit 3" && + + # Pull from remote in partial repo, and run gc again + git -C partial pull && + git -C partial gc --prune=now +' + + . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd