From patchwork Wed Oct 23 23:34:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11208035 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 444FC13B1 for ; Wed, 23 Oct 2019 23:34:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D35F20663 for ; Wed, 23 Oct 2019 23:34:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FKLNKJxT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408036AbfJWXeJ (ORCPT ); Wed, 23 Oct 2019 19:34:09 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:35376 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389743AbfJWXeJ (ORCPT ); Wed, 23 Oct 2019 19:34:09 -0400 Received: by mail-pl1-f201.google.com with SMTP id p14so2309476plq.2 for ; Wed, 23 Oct 2019 16:34:07 -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=kI0jhB5bq1EVk7+e92uzEmWHWcjZ5S/tmzYeUaCvCuk=; b=FKLNKJxTqmjTEPKHlHnFfuvuhDUDGHW6I6vt1nk/wa9NvpWKcLTKO/t6eUf9MNfOTr o0WNmcknQyu34FS2T2IjfW4DBpkb7scgsifyGa/qFbsOqw5wJ7xVKB7CCo62SI1xS/r1 wn0thN09doennjZNR89xhrt5kEbe/EIUAqNUXr50FiZoF7vLeID8Iz3vpCOl4cgKMyJV JnM+Op7Otf3KLxXoqwaXuwzG+f92vxxhQkjd/aLpsITO33k6pxsaljhpzNztLjghy+32 myc1dAHiQPSCR4vdaP4MGolXYPX9zgksHfidxioLzIpL6SoTqubY0sTvzxhRViWw3wf5 EoLQ== 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=kI0jhB5bq1EVk7+e92uzEmWHWcjZ5S/tmzYeUaCvCuk=; b=iqxgmRQFxQyhu9DXQGCSr1kk9Q7KrxhRU6Qubx63n4IFP1xIGuqZsq8I1c9drjS+o9 KBrmE1nMamfLqIx+vVunolbNe/LXlcpYl/yr8p0odTBSPloQzrh2JNluyUeL0lV0osKU GofqqaPyyfVU1+mHjLC+xlnAm9L9f4w3uwv98HFNH63vv1+N+qTaSlOgsZ2R+xxMn4Sf YJqtrPcpAB+ygqznvRY/BhrayLdnD5306aFX/njFUQiyOttz8gOvw2yN6Gl0K7pd+sJq uZiUwD3K1x+jlNiOsQPQbq55P8t1TsxaKNDAitA/ucUKMJKcNSbnABZ7xcIiFt975Qr2 GXtw== X-Gm-Message-State: APjAAAX2BknZki9SDdcXoAYZzJmBceZGo64FMV4hb2yKXEfH7+mFJqdP BGAPOm3hvjvaXy1OT8qZF67RZGpRBPfAy7d2Lp/eiizienDsi891GuRL+fk4OWpCNbny0DfrzAq m3Fz3zD3RvLIH4Hfoxd53hLrY/4LI1EanEmpCBXkDI4tQiL0g2c1oU/mBTaIkhy/fZXIUHALBGt Sn X-Google-Smtp-Source: APXvYqz52n9u+tcsM6fTiDXYdzTSlpNWnBhasSDCoc0Ywx6Hlz6VsFhDDpqdR/yE4aR4eJ+CLvH6ZmFmn90rIhneCE4C X-Received: by 2002:a63:5619:: with SMTP id k25mr10609010pgb.439.1571873646544; Wed, 23 Oct 2019 16:34:06 -0700 (PDT) Date: Wed, 23 Oct 2019 16:34:03 -0700 In-Reply-To: <20191007181825.13463-1-jonathantanmy@google.com> Message-Id: <20191023233403.145457-1-jonathantanmy@google.com> Mime-Version: 1.0 References: <20191007181825.13463-1-jonathantanmy@google.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog Subject: [PATCH v3] fetch: delay fetch_if_missing=0 until after config From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , emilyshaffer@google.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Suppose, from a repository that has ".gitmodules", we clone with --filter=blob:none: git clone --filter=blob:none --no-checkout \ https://kernel.googlesource.com/pub/scm/git/git Then we fetch: git -C git fetch This will cause a "unable to load config blob object", because the fetch_config_from_gitmodules() invocation in cmd_fetch() will attempt to load ".gitmodules" (which Git knows to exist because the client has the tree of HEAD) while fetch_if_missing is set to 0. fetch_if_missing is set to 0 too early - ".gitmodules" here should be lazily fetched. Git must set fetch_if_missing to 0 before the fetch because as part of the fetch, packfile negotiation happens (and we do not want to fetch any missing objects when checking existence of objects), but we do not need to set it so early. Move the setting of fetch_if_missing to the earliest possible point in cmd_fetch(), right before any fetching happens. Signed-off-by: Jonathan Tan --- No change from v2 except that I've added Signed-off-by. --- builtin/fetch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 0c345b5dfe..863c858fde 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1755,8 +1755,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) packet_trace_identity("fetch"); - fetch_if_missing = 0; - /* Record the command line for the reflog */ strbuf_addstr(&default_rla, "fetch"); for (i = 1; i < argc; i++) @@ -1824,6 +1822,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) } } + fetch_if_missing = 0; + if (remote) { if (filter_options.choice || has_promisor_remote()) fetch_one_setup_partial(remote);