From patchwork Wed Aug 5 23:06:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11702595 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0EE514DD for ; Wed, 5 Aug 2020 23:07:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE0ED22CAE for ; Wed, 5 Aug 2020 23:07:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ljjs5fqa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726517AbgHEXHC (ORCPT ); Wed, 5 Aug 2020 19:07:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726481AbgHEXG7 (ORCPT ); Wed, 5 Aug 2020 19:06:59 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD24C061574 for ; Wed, 5 Aug 2020 16:06:59 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id k21so25775430pls.2 for ; Wed, 05 Aug 2020 16:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=sGjqnareKE+4SgyC+B0Ohl5cA/K1RLZ5TkCckU85fM8=; b=Ljjs5fqaO8mbi78t2X6zx5CNmGGzYYMp1Bmmd2MAuKakgyowIEjk1UCkWaW5EmpzZF OGM8vMWJyeseWId9mLjLRHmr/wAFhI2LbSk5SuhhCY2h1YpfRbKkSOfmfAwMjvd0hadC BzT+umRWvBKO5AmrVyKRB6O+Czx7AEsEeMffUDB87KZBrZQMRyAffGCO1gA5jSjewKqH tMeH5tl28O3BEF60tSVBxPJ5t79oFi1bTTGDJbmLteEuo0dWL8/VP3OHa66vt54rwGru cdU+8+AmMIhVgbUxjuFK7NVsQyWkP+G6NCGaF9ueJuI8xih3d1gwE/J2fdqIsXvOtHeY QOpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=sGjqnareKE+4SgyC+B0Ohl5cA/K1RLZ5TkCckU85fM8=; b=IfY3LPbZ2WDzTFHIkUwD0XAnew5UNaN7hlp4DLIMqOk+TDr4eU2EG5Wa852UXU5MEC 8PFmlvZ4nvRVyIcBsXSK5H3Nf8DQtbp4S9UXYkh74/E4FJVE5K7a9NNj3kG7oSVuwINp t98mlrccLs/jTjMf7VGLVi0QNenzQ6vCafEZKoJuBHPB6+zrsID7OD/FuSGZjkQtnCuU op8kJT6IqpK8YCxOoptynTWpEWEl/KWbdXhl+gSP3STUexJOB8cN86OmsWPlw9cCBDuH 1IwxiVB8BoBpfFgZL5f8FkM6Dxgsa0byhjH47BQIFI5W7UQ/n3SrYSYER11UFGeD3VcN lf4w== X-Gm-Message-State: AOAM533MWLXamFUHcauQ9cglBUFpYFjeTGt7VuGKzTTq/Dz3P/Ltzj0g MqyF6vdROTsl8UzfDb1HD+dVZdnG+6ZkF6TmAA9dbppVfGKos3aa78c0l53D5fUCGGqjtv7Zd00 HbY4MvpHF23TYtAalKZNw+qrQbWsV7ackmPLCf/gPT+doDH/2AFgaozWKEV/p1p1fgWH8Nujsho XR X-Google-Smtp-Source: ABdhPJzld3hfcxP7tvsb+LFq0YgAxttz6XGOKy3xy7DJDfVZcd5NpGNSyUSZSC31QhBr18bqr8te04Na6eiLVcQd8V6q X-Received: by 2002:a62:3684:: with SMTP id d126mr5499604pfa.234.1596668818740; Wed, 05 Aug 2020 16:06:58 -0700 (PDT) Date: Wed, 5 Aug 2020 16:06:49 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: <20200728010403.95142-1-jonathantanmy@google.com> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [PATCH v2 1/4] sha1-file: introduce no-lazy-fetch has_object() From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , gitster@pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There have been a few bugs wherein Git fetches missing objects whenever the existence of an object is checked, even though it does not need to perform such a fetch. To resolve these bugs, we could look at all the places that has_object_file() (or a similar function) is used. As a first step, introduce a new function has_object() that checks for the existence of an object, with a default behavior of not fetching if the object is missing and the repository is a partial clone. As we verify each has_object_file() (or similar) usage, we can replace it with has_object(), and we will know that we are done when we can delete has_object_file() (and the other similar functions). Also, the new function has_object() has more appropriate defaults: besides not fetching, it also does not recheck packed storage. Signed-off-by: Jonathan Tan --- object-store.h | 25 +++++++++++++++++++++++-- sha1-file.c | 12 ++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/object-store.h b/object-store.h index f439d47af8..c4fc9dd74e 100644 --- a/object-store.h +++ b/object-store.h @@ -239,12 +239,33 @@ int read_loose_object(const char *path, unsigned long *size, void **contents); +/* Retry packed storage after checking packed and loose storage */ +#define HAS_OBJECT_RECHECK_PACKED 1 + +/* + * Returns 1 if the object exists. This function will not lazily fetch objects + * in a partial clone. + */ +int has_object(struct repository *r, const struct object_id *oid, + unsigned flags); + +/* + * These macros and functions are deprecated. If checking existence for an + * object that is likely to be missing and/or whose absence is relatively + * inconsequential (or is consequential but the caller is prepared to handle + * it), use has_object(), which has better defaults (no lazy fetch in a partial + * clone and no rechecking of packed storage). In the unlikely event that a + * caller needs to assert existence of an object that it fully expects to + * exist, and wants to trigger a lazy fetch in a partial clone, use + * oid_object_info_extended() with a NULL struct object_info. + * + * These functions can be removed once all callers have migrated to + * has_object() and/or oid_object_info_extended(). + */ #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS #define has_sha1_file_with_flags(sha1, flags) repo_has_sha1_file_with_flags(the_repository, sha1, flags) #define has_sha1_file(sha1) repo_has_sha1_file(the_repository, sha1) #endif - -/* Same as the above, except for struct object_id. */ int repo_has_object_file(struct repository *r, const struct object_id *oid); int repo_has_object_file_with_flags(struct repository *r, const struct object_id *oid, int flags); diff --git a/sha1-file.c b/sha1-file.c index ccd34dd9e8..ff444d7abb 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1988,6 +1988,18 @@ int force_object_loose(const struct object_id *oid, time_t mtime) return ret; } +int has_object(struct repository *r, const struct object_id *oid, + unsigned flags) +{ + int quick = !(flags & HAS_OBJECT_RECHECK_PACKED); + unsigned object_info_flags = OBJECT_INFO_SKIP_FETCH_OBJECT | + (quick ? OBJECT_INFO_QUICK : 0); + + if (!startup_info->have_repository) + return 0; + return oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0; +} + int repo_has_object_file_with_flags(struct repository *r, const struct object_id *oid, int flags) { From patchwork Wed Aug 5 23:06:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11702601 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1359F722 for ; Wed, 5 Aug 2020 23:07:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 008222086A for ; Wed, 5 Aug 2020 23:07:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="o5Kdgoft" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbgHEXHK (ORCPT ); Wed, 5 Aug 2020 19:07:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726481AbgHEXHC (ORCPT ); Wed, 5 Aug 2020 19:07:02 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 952A1C061574 for ; Wed, 5 Aug 2020 16:07:02 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id 41so27669510plb.23 for ; Wed, 05 Aug 2020 16:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=FAyVPvJu1WMhX0Rbh6CNZ4MCADqexJxcUbFl3cE+jqA=; b=o5KdgoftY1J9Z3xQkvt0r+VwvgaakDqNHlnWW4PoSlGv+s+3csDVSsmoylZMP6KSy9 TACiZ2iJl3sGgeC2fGndTUWAvZxT4km3Lj1jDfUHcIJB9SQB/JkPqXVcGnUdvfBie9/u 0KIQsGr0O55P43e3Myu+sly1bXDs3J8YPBHTWVDCy15gdKhBmrK2uz4vpAQwvwTVu6w9 63t/rvGq1pi7WghKwK1HugtOVb0fPqqCbeMLoWZucq04GqCVxrF7uLrMwmgo77Zykwrl 2IkDKtnAxN2W1CJnjvIl5uWSE8mrWmX0gc7IEuZSYlI/WPenAy3xrg7B3qsYy6pdvre9 4pEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=FAyVPvJu1WMhX0Rbh6CNZ4MCADqexJxcUbFl3cE+jqA=; b=orbF9tr97PvdJEKDxNFk9GU2RoSM9yiFTRnciq0MdPjICqw7rFZmjXmHhBe4vLXYxL y1DMecze3jGBtBL8OU06kYXzCHkstO3eo3QgXoZ5JgQ9KC7s7mVd21wx45WZTY7VBFIm 3ALTb7ZWdzfildhJGXX41m0MShj43xH6tFXnTD1N50hHtCR2Rxv9cBa5HNke/gmXv7xC 6S6pBMYnWh69yFNKQ6O0ox2bt8Gu8G1eMt32z/5bO1VDMq1CEKJUS48/93DiD5RYCceG oT9YfcxMvAPwDFQSvhHs8H3rN3RbxZwOZlIrzsL8uhL14KiOZY0zHKCy3DoTUCvVIB3j 5xwQ== X-Gm-Message-State: AOAM5322k6d/u7IAcaQY9XAJc1Y3fqjbkryjjn9AizRoxRudkd6qAgRW Wc9hCjieaQSrlX5WRmtbJpqOhhklGXmPwMr9LvMKEx9k3pN5DWGgdsxjpzd0MamqG3L7mlpLiyT xVcUzpuXbcnWLYhfkW3MDRNBZZU4wZ5E3ebdfVSoFBOYMUt6NCEJ+BJ3rClb4C4HOI415yFqNmi 8+ X-Google-Smtp-Source: ABdhPJz+YhFveAUi4AQTV4O5Ea97c5u5VnhVGmrIUijDjFqJbwPaKZ9lJmKFG2nqohb9DTYHj1V3s/PTesdrf7Y/0VnM X-Received: by 2002:a17:90a:1a13:: with SMTP id 19mr5013069pjk.167.1596668820567; Wed, 05 Aug 2020 16:07:00 -0700 (PDT) Date: Wed, 5 Aug 2020 16:06:50 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: <20200728010403.95142-1-jonathantanmy@google.com> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [PATCH v2 2/4] apply: do not lazy fetch when applying binary From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , gitster@pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When applying a binary patch, as an optimization, "apply" checks if the postimage is already present. During this fetch, it is perfectly expected for the postimage not to be present, so there is no need to lazy-fetch missing objects. Teach "apply" not to lazy-fetch in this case. Signed-off-by: Jonathan Tan --- apply.c | 2 +- t/t4150-am.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/apply.c b/apply.c index 8bff604dbe..402d80602a 100644 --- a/apply.c +++ b/apply.c @@ -3178,7 +3178,7 @@ static int apply_binary(struct apply_state *state, return 0; /* deletion patch */ } - if (has_object_file(&oid)) { + if (has_object(the_repository, &oid, 0)) { /* We already have the postimage */ enum object_type type; unsigned long size; diff --git a/t/t4150-am.sh b/t/t4150-am.sh index bda4586a79..94a2c76522 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -1133,4 +1133,20 @@ test_expect_success 'am and .gitattibutes' ' ) ' +test_expect_success 'apply binary blob in partial clone' ' + printf "\\000" >binary && + git add binary && + git commit -m "binary blob" && + git format-patch --stdout -m HEAD^ >patch && + + test_create_repo server && + test_config -C server uploadpack.allowfilter 1 && + test_config -C server uploadpack.allowanysha1inwant 1 && + git clone --filter=blob:none "file://$(pwd)/server" client && + test_when_finished "rm -rf client" && + + # Exercise to make sure that it works + git -C client am ../patch +' + test_done From patchwork Wed Aug 5 23:06:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11702597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6FC3414B7 for ; Wed, 5 Aug 2020 23:07:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E01022CAF for ; Wed, 5 Aug 2020 23:07:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mVwaqVeY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726604AbgHEXHK (ORCPT ); Wed, 5 Aug 2020 19:07:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbgHEXHD (ORCPT ); Wed, 5 Aug 2020 19:07:03 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32881C061575 for ; Wed, 5 Aug 2020 16:07:03 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id g127so15057405ybf.11 for ; Wed, 05 Aug 2020 16:07:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=dxfeIGH221XMLr4o9HpO94QXkExVdJ0qzWlq5Oab7Go=; b=mVwaqVeY4bY8TFkQDB/tfqJ5UBHK2w27IPhhQBvZ5s21qZr/+KzQN6NNW6m0Nt8w+t SrN9+kf5de07ECG8q2u2JWJCymSeetrocTjqJRYYDfO1nF1wLc46H6cD/RiQKDABJQqN 0E4sU2XYchDlrodiJ4w/b0zi6MiS37QptGIxZ44WIyB4RZ4baBd4ZLKjs6/BQutS/DqS zCUEG0GXFTAdKnSLIntjkPVGSfrBrE0g98Xi4pG9IsUzxAANGom7NF3qVJ3syBfab0Lx hiSFf7ojsR1bC1eBodPkcXlMHvrsTkp5htegvaoxSXl9CoWD7eOoNYIAyWfb4kkfqi65 EyGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=dxfeIGH221XMLr4o9HpO94QXkExVdJ0qzWlq5Oab7Go=; b=AJ+/x+OzHQMqwTHrrt0/ZNJ52P4lX5OCleQv4dMGyut56xqbShWvHXcxm2M5uwOuj/ 1Eu+Ve+Rc/NrfUB/ioo+uOFuXC3gzDkFtcRsZoGTK8w7423liEOJUKnEp08yWLelcCus 1TFULW5HTctMOyV7Kos6LbpI3SfkfHuqKbDl57rYmfWlp1FiFwP7XczK7jj1AqOvPTqj UjT1kuANp794GzWh2g1jDAm1QAiyOgvpkUyKzBoeKeThCJ/wAOwnKH6qCuc0GYp4yn6b 0TLu3OdofoSOJ/tlXE7VLTDKUdsU4SU0P7Cnr038rVMwwJJS+RKSPpSrp5Z8Nqkgo7P+ y41Q== X-Gm-Message-State: AOAM533M8hUE26FULoifO6eqmwzUq2RSIEbw1iWNP3c7jvx6khI6+paz yCFjjxMp7KzNKhVnNPDrH3IaTPRbCjLKZ6vLoj5KAyBAT4CUJyHTba98q3IOudvaSM5D/lM8U8r Q1fwaf4bkdHyI/7YnBqBcTkhoUJ7fVez0bs3XkD/Gt+OmTG3oc/AjFH/1ikq+s9/b9lK665zFrS hx X-Google-Smtp-Source: ABdhPJwLaRlR1CTyd0qfZDF80Vram4vyEWeNeyWFjHyxAhVJ3tBjrJ6BXt0czZP8Qb229ajBGt68cy0BU9W310eeZtVA X-Received: by 2002:a05:6902:706:: with SMTP id k6mr8698266ybt.416.1596668822302; Wed, 05 Aug 2020 16:07:02 -0700 (PDT) Date: Wed, 5 Aug 2020 16:06:51 -0700 In-Reply-To: Message-Id: <1b5e1f02d29b990497ad274e1e67b072feb77eec.1596668156.git.jonathantanmy@google.com> Mime-Version: 1.0 References: <20200728010403.95142-1-jonathantanmy@google.com> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [PATCH v2 3/4] pack-objects: no fetch when allow-{any,promisor} From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , gitster@pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The options --missing=allow-{any,promisor} were introduced in caf3827e2f ("rev-list: add list-objects filtering support", 2017-11-22) with the following note in the commit message: This patch introduces handling of missing objects to help debugging and development of the "partial clone" mechanism, and once the mechanism is implemented, for a power user to perform operations that are missing-object aware without incurring the cost of checking if a missing link is expected. The idea that these options are missing-object aware (and thus do not need to lazily fetch objects, unlike unaware commands that assume that all objects are present) are assumed in later commits such as 07ef3c6604 ("fetch test: use more robust test for filtered objects", 2020-01-15). However, the current implementations of these options use has_object_file(), which indeed lazily fetches missing objects. Teach these implementations not to do so. Also, update the documentation of these options to be clearer. Signed-off-by: Jonathan Tan --- Documentation/git-pack-objects.txt | 11 +++++++---- builtin/pack-objects.c | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index eaa2f2a404..54d715ead1 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -270,15 +270,18 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle. This option specifies how missing objects are handled. + The form '--missing=error' requests that pack-objects stop with an error if -a missing object is encountered. This is the default action. +a missing object is encountered. If the repository is a partial clone, an +attempt to fetch missing objects will be made before declaring them missing. +This is the default action. + The form '--missing=allow-any' will allow object traversal to continue -if a missing object is encountered. Missing objects will silently be -omitted from the results. +if a missing object is encountered. No fetch of a missing object will occur. +Missing objects will silently be omitted from the results. + The form '--missing=allow-promisor' is like 'allow-any', but will only allow object traversal to continue for EXPECTED promisor missing objects. -Unexpected missing object will raise an error. +No fetch of a missing object will occur. An unexpected missing object will +raise an error. --exclude-promisor-objects:: Omit objects that are known to be in the promisor remote. (This diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 7016b28485..2a2afb7cb1 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3016,7 +3016,7 @@ static void show_object__ma_allow_any(struct object *obj, const char *name, void * Quietly ignore ALL missing objects. This avoids problems with * staging them now and getting an odd error later. */ - if (!has_object_file(&obj->oid)) + if (!has_object(the_repository, &obj->oid, 0)) return; show_object(obj, name, data); @@ -3030,7 +3030,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name, * Quietly ignore EXPECTED missing objects. This avoids problems with * staging them now and getting an odd error later. */ - if (!has_object_file(&obj->oid) && is_promisor_object(&obj->oid)) + if (!has_object(the_repository, &obj->oid, 0) && is_promisor_object(&obj->oid)) return; show_object(obj, name, data); From patchwork Wed Aug 5 23:06:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11702599 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 615DB14B7 for ; Wed, 5 Aug 2020 23:07:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E55D2086A for ; Wed, 5 Aug 2020 23:07:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IHggdQiU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726609AbgHEXHK (ORCPT ); Wed, 5 Aug 2020 19:07:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726536AbgHEXHF (ORCPT ); Wed, 5 Aug 2020 19:07:05 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A567C061756 for ; Wed, 5 Aug 2020 16:07:05 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id p14so33608875plq.19 for ; Wed, 05 Aug 2020 16:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=FZ3BxXcIPe/Jq3g6sXokArDVa7F4Jzb+l1RE2xm8xjk=; b=IHggdQiUAZ2l2RWlEF/Y9VJ7Iyi5wOeSAe/UDwDMtpmKNbB6jOStj6cDs+t7wTwsJ1 3YMaWAelZ2kQAiDbssnjn2QgaYd4p7fcScOpvHt+/9JXGrzG7evH/3po6oq9kznpaRmP o4G6fr0DrwjAbxCb8zveE7WRHOlcDCiLwxKAzJgWKS8kUEaf98+pVjeMWpfbU5uq9MyH fcy+ylQgim+unEUrFoqobE3pBRIJmvsblJ51m3tdRq3jhksU6VWfqOptSYkcXtShayUI G/jQZjIxUF395weLWH/W2AKShzeXZLj3s6iUTyFZzhiaBhotbn4e0A9ZJqWotuDxo8Vo O48w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=FZ3BxXcIPe/Jq3g6sXokArDVa7F4Jzb+l1RE2xm8xjk=; b=VjwxLzSoiokrM0E0HLgOmfjleLcNDx6ZpSwgW8KsUE2zftHz9JbUJJOMl0xIiaeS6H AQSpSN056ZvOiYd9hwJjSM1NxOWq80KZToMckLJrL9+yO8mjv/MHWuhzoT/fY0Uif06Q zReKnWM0WseIV+F9XHCti9vOBtjxlIQfo6Ye969GJWdJ5br2FjdkXmi5+3eby7S6lvqQ HfYTBo7FQSfpFwuZ8/P10aU/IIlrJJFIdQPyGMFSEFf0g6JiolC2mZQHQRjCxODBcU8S ZAwoCtthzcfO76WUGjA0bmdjU68WzWXlbEo3e5eCDEwhaTtVNYLcW6uzw/d35jJkTKT2 rIOQ== X-Gm-Message-State: AOAM532BQL6MCkhwVfie6yZMrCCOYjVo588nminZhQyoSyQAYu7HdXmi chfPsPHKWU8b0hFh8rnRHdHyv6vWucCa1pdok5LdgnuNYX+8rvCaKKtutRTnjtyYyZGwdKsyUUQ tNXaGcvWoyPdCD8UqJLhzPGzowiTYT5wq/euueLNZrrDUwL7T9rwhzUkdwEcrdb7SFy9uy8UdaY al X-Google-Smtp-Source: ABdhPJwiOfKVm47SunKe37c4fYzyW2/2Z3rV1EUw9wcCumRE5eBA+2vtE4wd3WGIyO4y2HVvML39CtuIVEaTRDJ8hEO4 X-Received: by 2002:a17:90a:3488:: with SMTP id p8mr1189563pjb.1.1596668824026; Wed, 05 Aug 2020 16:07:04 -0700 (PDT) Date: Wed, 5 Aug 2020 16:06:52 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: <20200728010403.95142-1-jonathantanmy@google.com> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [PATCH v2 4/4] fsck: do not lazy fetch known non-promisor object From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , gitster@pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There is a call to has_object_file(), which lazily fetches missing objects in a partial clone, when the object is known to not be a promisor object. Change that call to has_object(), which does not do any lazy fetching. Signed-off-by: Jonathan Tan --- builtin/fsck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index 37aa07da78..fbf26cafcf 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -168,7 +168,7 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt return 0; if (!(obj->flags & HAS_OBJ)) { - if (parent && !has_object_file(&obj->oid)) { + if (parent && !has_object(the_repository, &obj->oid, 1)) { printf_ln(_("broken link from %7s %s\n" " to %7s %s"), printable_type(&parent->oid, parent->type),