From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 59AE11F66F for ; Thu, 19 Nov 2020 15:52:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728790AbgKSPw1 (ORCPT ); Thu, 19 Nov 2020 10:52:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727937AbgKSPw0 (ORCPT ); Thu, 19 Nov 2020 10:52:26 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A737C0613CF for ; Thu, 19 Nov 2020 07:52:26 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id p1so6893721wrf.12 for ; Thu, 19 Nov 2020 07:52:26 -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=1GgAmuFPRJYZ+FUW0eyYH5o0bmzoEDvVV5Hz6ckF9j8=; b=TwN51CiDsLbRdGqFdoBT0mraWO0deR6IaVnVN/E1ddybXIN3Nycu0DnVZkz8FVuRCk jwEURCwkQKpDart3ukUs+VTX7sA+iWk0nqBmkMo742/KjRct8YK+bAUiC2XUTnUTM+jJ LoPHpOHNOnFMlDU4h3E9WCA+mpFPJQiiDQMUhhXHsZEOWh4raIpTZYSLRyBChXi13NkF q/okd+E9YRVaFYC8s7uykss8tcLakN72BrTUS67FHENGxQcUebVzBfzpa2ypplHtLW0c FTtiGj2Ezx2kYEtDG6tFaMFDMuwjMIF/ZMY9ROlW0Urf9T7st1laWPC5cvdZLeTGFXkR PzWg== 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=1GgAmuFPRJYZ+FUW0eyYH5o0bmzoEDvVV5Hz6ckF9j8=; b=g2jsVlzPVHp6OU4R7Mn2cS9vbSOax603Mt1PeKIZqg7kHyqLyXdANMMOJ8LMlbjH3d 88RBWFodcPtGvyI9J3fsUdPCRxC6YkFyfN8g7EWG8ckrsj6/Cud1JEiKm1cYPLUDcWvL k3KQ0puxYcWVPAxGJmURfUbN/P76HNGNI7N/hb/i8oPErsgjqlPDYlv65dZhntg1tC4j ZjoXwZLv5GJunoJESii1AOHG4r78q/7Tu5cPlWjb/cDruVdiLRMkkBE2Rdt+fAiIi5vd NAxvcaLjNHt8sMlaTb3co6mQs10oEUdBDcbKBCTJFQpUrvhSC6CyiQryS74dsb47rMDQ Telw== X-Gm-Message-State: AOAM530PIQVw49cXfOSaUJTRFQ/XPPLbitE9z+HISMXJOXyhLjQ3M7FM YZ9aoAu27emnEGOs3ePcjmtFjRvbNMo= X-Google-Smtp-Source: ABdhPJwkmW1ggq2CYymRbr9oqEt+YClaurrgE8vWa/vUfe0Mvslr+Nj56WIaDeUjLwE4bebNyT4/+w== X-Received: by 2002:a05:6000:1292:: with SMTP id f18mr10865761wrx.196.1605801145120; Thu, 19 Nov 2020 07:52:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q7sm148492wrg.95.2020.11.19.07.52.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 07:52:24 -0800 (PST) Message-Id: <2da2131114eb47e70ccaf8fb9c51bf7fb5b173b0.1605801143.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Derrick Stolee via GitGitGadget" Date: Thu, 19 Nov 2020 15:52:17 +0000 Subject: [PATCH 1/7] t1300: test "set all" mode with value_regex Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jonathan Nieder , Emily Shaffer , Johannes Schindelin , Jeff King , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee Without additional modifiers, 'git config' attempts to set a single value in the .git/config file. When the value_regex parameter is supplied, this command behaves in a non-trivial manner. Consider 'git config key value value_regex'. The expected behavior is as follows: 1. If there are multiple existing values that match 'value_regex', then the command fails. Users should use --replace-all instead. 2. If there is one existing value that matches 'value_regex', then the new config has one entry where 'key=value'. 3. If there is no existing values match 'value_regex', then the 'key=value' pair is appended, making this 'key' a multi-valued config setting. Add a test that demonstrates these options. Signed-off-by: Derrick Stolee --- t/t1300-config.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 97ebfe1f9d..ef56b08070 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -1914,4 +1914,39 @@ test_expect_success '--replace-all does not invent newlines' ' test_cmp expect .git/config ' +test_expect_success 'set all config with value_regex' ' + q_to_tab >initial <<-\EOF && + [abc] + Qkey = one + EOF + + cp initial .git/config && + git config abc.key two a+ && + q_to_tab >expect <<-\EOF && + [abc] + Qkey = one + Qkey = two + EOF + test_cmp expect .git/config && + + test_must_fail git config abc.key three o+ 2>err && + test_i18ngrep "has multiple values" err && + git config abc.key three a+ && + q_to_tab >expect <<-\EOF && + [abc] + Qkey = one + Qkey = two + Qkey = three + EOF + test_cmp expect .git/config && + + cp initial .git/config && + git config abc.key three o+ && + q_to_tab >expect <<-\EOF && + [abc] + Qkey = three + EOF + test_cmp expect .git/config +' + test_done -- gitgitgadget