From patchwork Mon Dec 21 02:05:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nipunn Koorapati X-Patchwork-Id: 11984221 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,URIBL_BLOCKED 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 92C65C433E0 for ; Mon, 21 Dec 2020 05:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B00C22CB8 for ; Mon, 21 Dec 2020 05:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725955AbgLUFVd (ORCPT ); Mon, 21 Dec 2020 00:21:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbgLUFVd (ORCPT ); Mon, 21 Dec 2020 00:21:33 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2772C0613D3 for ; Sun, 20 Dec 2020 21:20:52 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id ce23so11692937ejb.8 for ; Sun, 20 Dec 2020 21:20:52 -0800 (PST) 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=HsX38x3guYJjqUzpNA0ygfVw5UoIG0mDU0pbQXzHWVM=; b=bQWw29wT3G7r8QYRIWYByEEBpZM5znKLrQtPXKGCEB6ZFXvy1dVbgN5LjBYeVMtzQW TL+3KdXPcPyBYxpcXgV9QpJSVTEn8d/mDKS53MpNaXIuhfqflKJ7ew/gRKa3f/d2YsCr TU1fBSMIkiXSGSDyXxBPcMknSpxMsOotJWeBInW6+yw/glBllIPNSgoUY0nu2DBoHRkv fHIMlNsZblRwQzVmZYo3d2blpcuTx2WI+lLdO1a6lsX1Xl0w2dRefJ7dR9ip0qBhBZ8A Li+/ygU14sjbjNUkWsIrnKtdBDMxuV/lRPuUyId6M3lLcNNr05AxAeFEEol4IQGbayoT S61Q== 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=HsX38x3guYJjqUzpNA0ygfVw5UoIG0mDU0pbQXzHWVM=; b=C8tLdIRiVidoIzdjO9AJVUC2y+WpLQQsnEKb7H7kHrrZmw1fBjwpTt5718MexNlE2g wZzJxxToLHs3k4LXDOE5Rxbzts7UVtqM7kGNlpX/6xAWkx9eUxxVeQtPbbZgXuZ2WFFp VxDdV0zJOEndp8ccvxytC2SOwMpLW0/Ig6CVzziIJE4/927NH47XzxAllSq8+iHU3NWP JcZ3JowTlxu5zj91jN2so2qpHPQ2dStP20pB9RduvJzQ2h9XPV48I2ARczcxx8iygWp3 5AIhUKDD07CeVw99y3n6rLe5BTo4pOFijscKUHk8HSohh31CIejV4WljzHdMSvKTH/id 0TQA== X-Gm-Message-State: AOAM531kYmB10c101+iESwaTec/hXFgRuUC5LdhSEZvO9kOJwqgqh6JN rFvOVtxsekrgoe10I9hjUh6MN7p4zx0= X-Google-Smtp-Source: ABdhPJwLU2H42Nn28kKwZVllEbRIqsdUNPS73BUQ4fPqtiqgWz8ZkYd498paQKvR9J/yETN2/TzaCg== X-Received: by 2002:a5d:69c2:: with SMTP id s2mr15843419wrw.36.1608516323125; Sun, 20 Dec 2020 18:05:23 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h16sm11033128wmb.41.2020.12.20.18.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 18:05:22 -0800 (PST) Message-Id: <733c674bd1901c931a8917045eb72f661872f462.1608516320.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 21 Dec 2020 02:05:18 +0000 Subject: [PATCH v3 1/3] test-lib-functions: handle --add in test_config Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Eric Sunshine , Nipunn Koorapati , Nipunn Koorapati Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Nipunn Koorapati From: Nipunn Koorapati test_config fails to unset the configuration variable when using --add, as it tries to run git config --unset-all --add Tell test_config to invoke test_unconfig with the arg $2 when the arg $1 is --add Signed-off-by: Nipunn Koorapati --- t/test-lib-functions.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 999982fe4a9..1fdd7129d51 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -381,6 +381,7 @@ test_unconfig () { config_dir=$1 shift fi + echo git ${config_dir:+-C "$config_dir"} config --unset-all "$@" git ${config_dir:+-C "$config_dir"} config --unset-all "$@" config_status=$? case "$config_status" in @@ -400,7 +401,13 @@ test_config () { config_dir=$1 shift fi - test_when_finished "test_unconfig ${config_dir:+-C '$config_dir'} '$1'" && + + first_arg=$1 + if test "$1" = --add; then + first_arg=$2 + fi + + test_when_finished "test_unconfig ${config_dir:+-C '$config_dir'} '$first_arg'" && git ${config_dir:+-C "$config_dir"} config "$@" } From patchwork Mon Dec 21 02:05:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nipunn Koorapati X-Patchwork-Id: 11984211 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,URIBL_BLOCKED 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 6AEEFC433DB for ; Mon, 21 Dec 2020 04:50:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29DC622CB2 for ; Mon, 21 Dec 2020 04:50:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727804AbgLUEtp (ORCPT ); Sun, 20 Dec 2020 23:49:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727658AbgLUEtp (ORCPT ); Sun, 20 Dec 2020 23:49:45 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92B52C0613D3 for ; Sun, 20 Dec 2020 20:49:04 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id o13so20613536lfr.3 for ; Sun, 20 Dec 2020 20:49:04 -0800 (PST) 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=lVSk/0eg+VzE8sES68ypaAs1tKpJNEqgg3qp7LS0ezg=; b=pEEI2YTBZu9MmItMbX+O8lsb+nQhBhlWQbD5wVJUE5lea6dZ9VCLmOOoxCBvioOI9D w6UAu/JHgizqdwdWlR2ePg5+7asxP2NFLaXZqGh1g1FmnP1+Fr6fJIz5vaA0cjERTnGM sJhTqUNGe7Aytzxg5cAoR0XaDDEczG9iTzSGNQk2zfFJj3c0zgL0Y99rDX4xO77wlwxS TJJYoig5rIQFqYsN0Wiy4OF3NgqtKKRWg1LAvxjVL7Jon6oWlmGvLwzHkY+opm5UGzmA X8wAOXznr7FJbJMnDNqu4+aD+o/KZ4ZQAbVmPSwMvZo3t6Iao82RMX6YQYxvNSzfuYQX y1Aw== 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=lVSk/0eg+VzE8sES68ypaAs1tKpJNEqgg3qp7LS0ezg=; b=s+fe9bC3QLSoWxCcfsxwmLQzescJVgd3sDkUIIr4C9zbkaAeJtr76UMuIdr/HnyaoH f4z80YW22WVR1yr2GaneUvMl/dl4icYlH5a/Xm7Zfi1uaaIAJ3gEoSUIjvmRW8P4pmYO ZMhSRgzUH3zDcFZHDdMNJbztnlnwoiqpNiCPbuqSAR9zAQVoCoUfSO7Bkny33OoWanqp aW4UqXpJnQs0h0p7ErkgNqFrlTOgnAtgWfh7ReyDK4hauX4FRgliHj8cvBjQHyF7YOR7 1mJD3bVdxRqS3kc0gqyKZuts7wvMxzoq8YpeGE8y67CGeiTIZDm3N4T29NxU4Geh/z3q aNig== X-Gm-Message-State: AOAM533G3ISu6zTT5rDWy1PBVoMLV5J3hbY6ORp2xVLhpN3gtBXS7GG/ LL54sfSoqndoJKxt2lRbncWlfStg14w= X-Google-Smtp-Source: ABdhPJw+uImXPo1fRx9ZjC57wNxhtZaqnl7Rse+UPHb1fosQAI49XLkEZyLv2KzdYyPcOOoTT9WS0w== X-Received: by 2002:a5d:4491:: with SMTP id j17mr15783077wrq.78.1608516323952; Sun, 20 Dec 2020 18:05:23 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t13sm25311950wrs.26.2020.12.20.18.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 18:05:23 -0800 (PST) Message-Id: <20cff2f5c59adb1076c845657aabed7ebbf0a6b5.1608516320.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 21 Dec 2020 02:05:19 +0000 Subject: [PATCH v3 2/3] negative-refspec: fix segfault on : refspec Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Eric Sunshine , Nipunn Koorapati , Nipunn Koorapati Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Nipunn Koorapati From: Nipunn Koorapati The logic added to check for negative pathspec match by c0192df630 (refspec: add support for negative refspecs, 2020-09-30) looks at refspec->src assuming it is never NULL, however when remote.origin.push is set to ":", then refspec->src is NULL, causing a segfault within strcmp Tell git to handle matching refspec by adding the needle to the set of positively matched refspecs, since matching ":" refspecs match anything as src. Added testing for matching refspec pushes fetch-negative-refspec both individually and in combination with a negative refspec Signed-off-by: Nipunn Koorapati --- remote.c | 10 +++++++--- t/t5582-fetch-negative-refspec.sh | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/remote.c b/remote.c index 9f2450cb51b..7323694b163 100644 --- a/remote.c +++ b/remote.c @@ -751,9 +751,13 @@ static int query_matches_negative_refspec(struct refspec *rs, struct refspec_ite if (match_name_with_pattern(key, needle, value, &expn_name)) string_list_append_nodup(&reversed, expn_name); - } else { - if (!strcmp(needle, refspec->src)) - string_list_append(&reversed, refspec->src); + } else if (refspec->matching) { + /* For the special matching refspec, any query should match */ + string_list_append(&reversed, needle); + } else if (!refspec->src) { + BUG("refspec->src should not be null here"); + } else if (!strcmp(needle, refspec->src)) { + string_list_append(&reversed, refspec->src); } } diff --git a/t/t5582-fetch-negative-refspec.sh b/t/t5582-fetch-negative-refspec.sh index 8c61e28fec8..30209e98a62 100755 --- a/t/t5582-fetch-negative-refspec.sh +++ b/t/t5582-fetch-negative-refspec.sh @@ -186,4 +186,26 @@ test_expect_success "fetch --prune with negative refspec" ' ) ' +test_expect_success "push with matching ':' refspec" ' + test_config -C two remote.one.push : && + # Fails w/ tip behind counterpart - but should not segfault + test_must_fail git -C two push one +' + +test_expect_success "push with matching '+:' refspec" ' + test_config -C two remote.one.push +: && + # Fails w/ tip behind counterpart - but should not segfault + test_must_fail git -C two push one +' + +test_expect_success "push with matching and negative refspec" ' + test_config -C two --add remote.one.push : && + # Fails to push master w/ tip behind counterpart + test_must_fail git -C two push one && + + # If master is in negative refspec, then the command will succeed + test_config -C two --add remote.one.push ^refs/heads/master && + git -C two push one +' + test_done