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 X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3A57C433ED for ; Fri, 16 Apr 2021 12:50:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C67B611AC for ; Fri, 16 Apr 2021 12:50:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242375AbhDPMuh (ORCPT ); Fri, 16 Apr 2021 08:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235528AbhDPMua (ORCPT ); Fri, 16 Apr 2021 08:50:30 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E69EFC061756 for ; Fri, 16 Apr 2021 05:50:03 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id 12so26605671wrz.7 for ; Fri, 16 Apr 2021 05:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=BKZMXuN/+p8qrPdSacUofbQM5WONxi8AP2yKhlLmgCo=; b=ns/zWD/Og2IGmukPJzQgyQrzgyhqsILr0alqh2QGaTFe52xSyE8qzhwxg+n8e+lqsh zhIn1t0V+HLgIxWvGmbHhMkLqb3z/ll5Ncw/moRXT5N5Ppbh6MbzRwbZ3YYFB74gA7fn vA2EdtIY4ubvyHaEd4iz3qfsPuE7d4r4K/z1a5/g46fasI5d1RAyRRJTWdOdOdqJB7bD T/chIf+r1PCe1XiapiVLQQ2xdSXAZaLUaqGct9XmixYGSWmz3BnADRCLQry1vFylyl81 VZgmXMEi0rD1Fm9GckVPnHX8Uaw5oQ26QOzVXdl7VPOtt+MJxneaG0vMULlBtL64YwEK v0pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=BKZMXuN/+p8qrPdSacUofbQM5WONxi8AP2yKhlLmgCo=; b=qDUGtMV6KGOzb1V4fnL6RCKZQCQb3CMGmjfRZItUSLl/RruG5T+E6A2MrDF92nh0x7 O0Ug82qxRtEQ0zxO6bUBX5bqtIJJuktnXjdPUHSqT7sQm0Z7rIkwuuuG+efX8jRoApQ7 DUEtaDdyeYTt1Y37UNAwdv+ASylJlUtKA/ZE5WHD/4rzI4FI0ttelR1nAoW2pHVlFl30 nCVITVJ45YzB+U/ty6pnzP/4UmD2hD4byx/pmfaA+dvyVeQuWzSc9tfvNsLgs4m499kz yxuJgIiiCAKE3La8RsfTNIxRrEtt7zg5kMMuXUYS4uNHGaeTyjK/BOo8IZMRjK3hZ9ia kkKQ== X-Gm-Message-State: AOAM531x0LjS/dQtgRMBd+3wL9IkjLxFBmoOzEhtSfq/ejFVfWzoF4c3 KEl5ZGEhvSAjQw1VoYqiFN3C/rJdwao= X-Google-Smtp-Source: ABdhPJzI2QCQtSnCnhWbv3lxgpNVs3sjrxAWhAejJKhQEtdOd/fVM/TU0GkzIPi0z71NEansyC0csg== X-Received: by 2002:a5d:640a:: with SMTP id z10mr8652671wru.276.1618577402716; Fri, 16 Apr 2021 05:50:02 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g9sm8949197wmh.21.2021.04.16.05.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Apr 2021 05:50:02 -0700 (PDT) Message-Id: <565ed8a1892946a75c1116b0f351725e64fa90ba.1618577399.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Derrick Stolee via GitGitGadget" Date: Fri, 16 Apr 2021 12:49:58 +0000 Subject: [PATCH v4 3/4] maintenance: use 'git fetch --prefetch' Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: tom.saeger@oracle.com, gitster@pobox.com, sunshine@sunshineco.com, Derrick Stolee , Josh Steadmon , Emily Shaffer , Ramsay Jones , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee The 'prefetch' maintenance task previously forced the following refspec for each remote: +refs/heads/*:refs/prefetch//* If a user has specified a more strict refspec for the remote, then this prefetch task downloads more objects than necessary. The previous change introduced the '--prefetch' option to 'git fetch' which manipulates the remote's refspec to place all resulting refs into refs/prefetch/, with further partitioning based on the destinations of those refspecs. Update the documentation to be more generic about the destination refs. Do not mention custom refspecs explicitly, as that does not need to be highlighted in this documentation. The important part of placing refs in refs/prefetch/ remains. Reported-by: Tom Saeger Signed-off-by: Derrick Stolee --- Documentation/git-maintenance.txt | 6 ++---- builtin/gc.c | 7 +++---- t/t7900-maintenance.sh | 14 +++++++------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Documentation/git-maintenance.txt b/Documentation/git-maintenance.txt index 80ddd33ceba0..1e738ad39832 100644 --- a/Documentation/git-maintenance.txt +++ b/Documentation/git-maintenance.txt @@ -92,10 +92,8 @@ commit-graph:: prefetch:: The `prefetch` task updates the object directory with the latest objects from all registered remotes. For each remote, a `git fetch` - command is run. The refmap is custom to avoid updating local or remote - branches (those in `refs/heads` or `refs/remotes`). Instead, the - remote refs are stored in `refs/prefetch//`. Also, tags are - not updated. + command is run. The configured refspec is modified to place all + requested refs within `refs/prefetch/`. Also, tags are not updated. + This is done to avoid disrupting the remote-tracking branches. The end users expect these refs to stay unmoved unless they initiate a fetch. With prefetch diff --git a/builtin/gc.c b/builtin/gc.c index fa8128de9ae1..9d35f7da50d8 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -879,15 +879,14 @@ static int fetch_remote(struct remote *remote, void *cbdata) struct child_process child = CHILD_PROCESS_INIT; child.git_cmd = 1; - strvec_pushl(&child.args, "fetch", remote->name, "--prune", "--no-tags", + strvec_pushl(&child.args, "fetch", remote->name, + "--prefetch", "--prune", "--no-tags", "--no-write-fetch-head", "--recurse-submodules=no", - "--refmap=", NULL); + NULL); if (opts->quiet) strvec_push(&child.args, "--quiet"); - strvec_pushf(&child.args, "+refs/heads/*:refs/prefetch/%s/*", remote->name); - return !!run_command(&child); } diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 2412d8c5c006..eadb800c08cc 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -141,15 +141,15 @@ test_expect_success 'prefetch multiple remotes' ' test_commit -C clone1 one && test_commit -C clone2 two && GIT_TRACE2_EVENT="$(pwd)/run-prefetch.txt" git maintenance run --task=prefetch 2>/dev/null && - fetchargs="--prune --no-tags --no-write-fetch-head --recurse-submodules=no --refmap= --quiet" && - test_subcommand git fetch remote1 $fetchargs +refs/heads/\\*:refs/prefetch/remote1/\\* log && -- gitgitgadget