From patchwork Thu Jul 8 10:53:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12364923 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=-16.0 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,USER_AGENT_GIT 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 29EE7C07E9C for ; Thu, 8 Jul 2021 10:53:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07BE061494 for ; Thu, 8 Jul 2021 10:53:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231546AbhGHK4D (ORCPT ); Thu, 8 Jul 2021 06:56:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231512AbhGHK4C (ORCPT ); Thu, 8 Jul 2021 06:56:02 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A747C06175F for ; Thu, 8 Jul 2021 03:53:20 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso6402724wmh.4 for ; Thu, 08 Jul 2021 03:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I9aMTtyG5favo4OHeEDIcIyaAJX/mOAznYT32Y+BoMA=; b=D3shSi6JGrSHtg5bGduks48BtBToWtGdg3STaMVz+m8NU/RoknHL7RRGn3kXOEYO2k ZNpIF7lr8faeHTUj7LgPMxXkD5sTHky5mkFinl7JYFFNy0WTnnzhlhcE2eBpuqVhj+QT 57XrX2N7sejBi/gZZTdjs104QvN58L3WZM3OvylXtkA99b3yNWkSFQHie/3i8jkkxI5j Ii6b8MHq27nopDJn/8ZbvEnJB2m/at6Zo4J13oKVXJtsOtS7S3fBv7/h/SDR7bPecE8G TxM17qPTiu+fX9VwZcu1GLPhgX/qCLbgvBZ/zVJCm/yCPMBjpid5pHSKniR82N6QbPLd HlEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I9aMTtyG5favo4OHeEDIcIyaAJX/mOAznYT32Y+BoMA=; b=JELSSgDt469xOebdv+BrZ8dYFDXnWQ8v9QiS3SWR5ZqTwakXreBQZbMBnUaHiBPW/Q TtQToYrufrAWvV3sEarGWNlfhTrTv3zyBvOu8NBpOT49LKe9Vov4IM15Jc34HF1SSW5R G3YVQAZqGryDU/rne691Slll4fjNeZl2TOa5k0ooGBkDIs11XLgmZ5u50n6iRqUj8tR6 xM799Ao4MJIwyHxEYUI+mJ+CYPghEKp833SoxCYjeZj/tP6xboTtj5IfNEdh8f/2Wnyz aqTEV+/9tTS71KKB51mseMKoUOkz+423UV1sDqXy7kt67g4qp5pQdZa0ptXswmopGVn3 3G5Q== X-Gm-Message-State: AOAM533LL0EhzNK+s403O2GCXxo+IMpZ97u3bf5QHRAdFxFmTxoGIbeJ 1dhbal41a8+yT4en16+porHAjssCMr41Ww== X-Google-Smtp-Source: ABdhPJx2pMJyhtQSZJRUu5u06r9v5jyNgZz1zQeFm8aLevzEUrasnLUo0p8F/BTIiXCA7FJG8LdFcA== X-Received: by 2002:a1c:4d05:: with SMTP id o5mr4548692wmh.23.1625741598700; Thu, 08 Jul 2021 03:53:18 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e15sm1838920wrp.29.2021.07.08.03.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 03:53:18 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jonathan Tan , Derrick Stolee , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 1/3] send-pack.c: move "no refs in common" abort earlier Date: Thu, 8 Jul 2021 12:53:13 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.636.g43e71d69cff In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the early return if we have no remote refs in send_pack() earlier. When this was added in 4c353e890c0 (Warn when send-pack does nothing, 2005-12-04) one of the first things we'd do was to abort, but as of cfee10a773b (send-pack/receive-pack: allow errors to be reported back to pusher., 2005-12-25) we've added numerous server_supports() conditions that are acted on later in the function, that won't be used if we don't have remote refs. Then as of 477673d6f39 (send-pack: support push negotiation, 2021-05-04) we started doing even more work on the assumption that we had some remote refs to feed to --negotiation-tip=* options. We only hit this condition if we have nothing to push, so we don't need to consider "push.negotiate" etc. only to do nothing with that information. Signed-off-by: Ævar Arnfjörð Bjarmason --- send-pack.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/send-pack.c b/send-pack.c index 9cb9f716509..5a79e0e7110 100644 --- a/send-pack.c +++ b/send-pack.c @@ -486,6 +486,12 @@ int send_pack(struct send_pack_args *args, const char *push_cert_nonce = NULL; struct packet_reader reader; + if (!remote_refs) { + fprintf(stderr, "No refs in common and none specified; doing nothing.\n" + "Perhaps you should specify a branch.\n"); + return 0; + } + git_config_get_bool("push.negotiate", &push_negotiate); if (push_negotiate) get_commons_through_negotiation(args->url, remote_refs, &commons); @@ -534,11 +540,6 @@ int send_pack(struct send_pack_args *args, } } - if (!remote_refs) { - fprintf(stderr, "No refs in common and none specified; doing nothing.\n" - "Perhaps you should specify a branch.\n"); - return 0; - } if (args->atomic && !atomic_supported) die(_("the receiving end does not support --atomic push")); From patchwork Thu Jul 8 10:53:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12364925 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=-16.0 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,USER_AGENT_GIT 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 92F80C07E99 for ; Thu, 8 Jul 2021 10:53:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7237B6157E for ; Thu, 8 Jul 2021 10:53:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231549AbhGHK4E (ORCPT ); Thu, 8 Jul 2021 06:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231493AbhGHK4C (ORCPT ); Thu, 8 Jul 2021 06:56:02 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 210B2C061574 for ; Thu, 8 Jul 2021 03:53:21 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id q17so6964348wrv.2 for ; Thu, 08 Jul 2021 03:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DKSmngizrES+yuw4Ird1aAqeHyUOGZfBrw2oTaSDKiU=; b=OxO6S7wC1Hd/O3CJWlTAOOizazIh6MXhloUaKrM1t2eotfG2di2FTARnGPCCwW6VI3 lpmhFNVCtyvpLNGyiqFiSYVwkFqm1lPOAAIahFh/tmMt3vdgCgcWu1TQs5WNdiZJm6fF 6JG4KhdQ0AuZfXQfMU1jPMUBueyCj0ChsJuPZLzxNF+/luOHyiP1RF9VCsZFCSIDu8qk 7399ERj8TKIbn+DgfvO1eP3IOt54a+fcUGh3giapnXYIo27FnDOc3SBVWoYYkb2pWNKH H8Zf9eFpzidRp4tWWbT4deVlLf+C76GgQjiNTRvHZyIySX/Q76KFYcUTU0hnSmkzZoX6 Og/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DKSmngizrES+yuw4Ird1aAqeHyUOGZfBrw2oTaSDKiU=; b=D5pdPPb4aJkl1N906ZgQ5K/7lTx4tyPLU5qdoxyX+hJbPlPumlbtlI2w81oodYuS54 c1LrjzHCiIc62JYqqsSxLTEIi+3i7fHWhXDQKFXnkrbrfOhG+ehh9H2x7RpiALRgpoJ4 rSfLTrgUPOQ82IhhEbxPchMma/QzJk73Hb3mwRuVD4FfR3SUDahkTPgWm78s+4YvdS1t WmIqugwpX+JMca4yHdBu6UoeTa+6ekLrtbhbBLmqW5aAjMqcsGKgnypGAqQ89Nn3lK12 HmWVh7GleUZsR+e+aHr3Fv428prR5qXs4Y8Newtux0mErcYQcbgGkwxYIFuF119grIiW hfcw== X-Gm-Message-State: AOAM531SuDMXCra/nYHO9NbNoxL85xMXvCpUTsSSPEjrKzBnpYNhZXTX MvRTwoJjFIeLhGviZq/Tdbx5PcKC3OhmmQ== X-Google-Smtp-Source: ABdhPJyDg7BCfLHuYCFkVErQfrhQTRPA8ojFaNiD7/AUDTgn9qyGvAHAgi8CoFnY895fM+o0JDppkg== X-Received: by 2002:a5d:6085:: with SMTP id w5mr33797007wrt.199.1625741599443; Thu, 08 Jul 2021 03:53:19 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e15sm1838920wrp.29.2021.07.08.03.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 03:53:18 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jonathan Tan , Derrick Stolee , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 2/3] fetch: document the --negotiate-only option Date: Thu, 8 Jul 2021 12:53:14 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.636.g43e71d69cff In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There was no documentation for the --negotiate-only option added in 9c1e657a8fd (fetch: teach independent negotiation (no packfile), 2021-05-04), only documentation for the related push.negotiation option added in the following commit in 477673d6f39 (send-pack: support push negotiation, 2021-05-04). Let's document it, and update the cross-linking I'd added between --negotiation-tip=* and 'fetch.negotiationAlgorithm' in 526608284a7 (fetch doc: cross-link two new negotiation options, 2018-08-01). I think it would be better to say "in common with the remote" here than "...the server", but the documentation for --negotiation-tip=* above this talks about "the server", so let's continue doing that in this related option. See 3390e42adb3 (fetch-pack: support negotiation tip whitelist, 2018-07-02) for that documentation. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/config/fetch.txt | 3 ++- Documentation/fetch-options.txt | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Documentation/config/fetch.txt b/Documentation/config/fetch.txt index 6af6f5edb27..63748c02b72 100644 --- a/Documentation/config/fetch.txt +++ b/Documentation/config/fetch.txt @@ -69,7 +69,8 @@ fetch.negotiationAlgorithm:: setting defaults to "skipping". Unknown values will cause 'git fetch' to error out. + -See also the `--negotiation-tip` option for linkgit:git-fetch[1]. +See also the `--negotiate-only` and `--negotiation-tip` options to +linkgit:git-fetch[1]. fetch.showForcedUpdates:: Set to false to enable `--no-show-forced-updates` in diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt index 9e7b4e189ce..e967ff1874c 100644 --- a/Documentation/fetch-options.txt +++ b/Documentation/fetch-options.txt @@ -62,8 +62,17 @@ The argument to this option may be a glob on ref names, a ref, or the (possibly abbreviated) SHA-1 of a commit. Specifying a glob is equivalent to specifying this option multiple times, one for each matching ref name. + -See also the `fetch.negotiationAlgorithm` configuration variable -documented in linkgit:git-config[1]. +See also the `fetch.negotiationAlgorithm` and `push.negotiate` +configuration variables documented in linkgit:git-config[1], and the +`--negotiate-only` option below. + +--negotiate-only:: + Do not fetch anything from the server, and instead print the + ancestors of the provided `--negotiation-tip=*` arguments, + which we have in common with the server. ++ +Internally this is used to implement the `push.negotiate` option, see +linkgit:git-config[1]. --dry-run:: Show what would be done, without making any changes. From patchwork Thu Jul 8 10:53:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12364927 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=-16.0 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,URIBL_BLOCKED,USER_AGENT_GIT 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 932D5C07E9C for ; Thu, 8 Jul 2021 10:53:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 732C56157E for ; Thu, 8 Jul 2021 10:53:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231561AbhGHK4G (ORCPT ); Thu, 8 Jul 2021 06:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231493AbhGHK4E (ORCPT ); Thu, 8 Jul 2021 06:56:04 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D066FC061574 for ; Thu, 8 Jul 2021 03:53:21 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id w13so3795973wmc.3 for ; Thu, 08 Jul 2021 03:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zIMHbyJi8ETSO35wjC1q+JADw0hQGH17jc457oFj1dA=; b=VjIDBNkOh1lbg0yweKEzW46HDxPhnH8TiF28wcv8R7Z4Gk0RZ/OLg6wU7KajM4exI7 4srw5MbwZDHZel5B1TknbbsdL/14gSpAIpCPbgLPwux8uh4H6/HVCxdkq5dDgu5ZSme2 pNnvr3f5H3j8ftRpyeACOI6nEGTirFo4Fj28X86lo6XLxXW6oOMPih0Q11oW8OhreJsi K3yETGbvdT1zKLi6o9d9CFS2SOPsdvG1JxiODZc/zb8glx4Wda2WsjYLI/k5AXpqZsJe oQP+Fmskwrw5OogB03MIZ7z8CeVjyQ06T9a2kgR6iiXLMx5skyWaXYW0FJD4WLc2qy3D bgyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zIMHbyJi8ETSO35wjC1q+JADw0hQGH17jc457oFj1dA=; b=OKHxBlEgGn/36Vz8fQXSTA6FbiLs1eh+fe/kDd9hmJ1qVGyjb8UpC+qOVG5SfNK1Gq Ry8cUUx8g0JqGQdG1ewKc16cEebLKdgwXoHUtuzY6H1F0g6M5qV2LOp8qVlWTHyYndkn nPyPkJdNZPzY00NvQK5F+JDUNqj4ZhrscS8bTV7qGF0BNmUHu/YCoi7EVN40Q+IY2m6t jnyRRF9GWtrgxDa3jSdRKpebqrtGNm+EckyLg2zegvsL90h+QosgV3IOD7FMzCcVD0U8 fENUAHw3y8qA2ytV9tWtGb7e6KmAstsJEP2d85asDxmpNYeeHRFxOUKeceo5n9Fo9SQ7 Gv6w== X-Gm-Message-State: AOAM533M6yLGIlNq9Xnf2Rodswj81Xqcu5NXSCyzEqtKp8T59tCm+eLc 4Fh9q8bYY1T/7Yjw9Dj/YOul62TZvdYTmg== X-Google-Smtp-Source: ABdhPJxR3UOExAh+xGriiXB26ceY0k0DVHaO1srQzt1b75tAqbpblAPw2oe/Qx9wcMmzirmsxXONyA== X-Received: by 2002:a7b:c3c6:: with SMTP id t6mr32467392wmj.35.1625741600289; Thu, 08 Jul 2021 03:53:20 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e15sm1838920wrp.29.2021.07.08.03.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 03:53:19 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jonathan Tan , Derrick Stolee , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 3/3] fetch: fix segfault in --negotiate-only without --negotiation-tip=* Date: Thu, 8 Jul 2021 12:53:15 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.636.g43e71d69cff In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The recent --negotiate-only option would segfault in the call to oid_array_for_each() in negotiate_using_fetch() unless one or more --negotiation-tip=* options were provided. All of the other tests for the feature combine both, but nothing was checking this assumption, let's do that and add a test for it. Fixes a bug in 9c1e657a8fd (fetch: teach independent negotiation (no packfile), 2021-05-04). Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/fetch.c | 3 +++ t/t5702-protocol-v2.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/builtin/fetch.c b/builtin/fetch.c index 9191620e50c..25740c13df1 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1990,6 +1990,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) fetch_config_from_gitmodules(sfjc, rs); } + if (negotiate_only && !negotiation_tip.nr) + die(_("--negotiate-only needs one or more --negotiate-tip=*")); + if (deepen_relative) { if (deepen_relative < 0) die(_("Negative depth in --deepen is not supported")); diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 66af411057c..78de1ff2ad5 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -599,6 +599,22 @@ setup_negotiate_only () { test_commit -C client three } +test_expect_success 'usage: --negotiate-only without --negotiation-tip' ' + SERVER="server" && + URI="file://$(pwd)/server" && + + setup_negotiate_only "$SERVER" "$URI" && + + cat >err.expect <<-\EOF && + fatal: --negotiate-only needs one or more --negotiate-tip=* + EOF + + test_must_fail git -c protocol.version=2 -C client fetch \ + --negotiate-only \ + origin 2>err.actual && + test_cmp err.expect err.actual +' + test_expect_success 'file:// --negotiate-only' ' SERVER="server" && URI="file://$(pwd)/server" &&