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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, 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 75C761F934 for ; Tue, 22 Dec 2020 00:14:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726039AbgLVAOB (ORCPT ); Mon, 21 Dec 2020 19:14:01 -0500 Received: from mail-ej1-f49.google.com ([209.85.218.49]:34977 "EHLO mail-ej1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbgLVAOB (ORCPT ); Mon, 21 Dec 2020 19:14:01 -0500 Received: by mail-ej1-f49.google.com with SMTP id q22so15930693eja.2 for ; Mon, 21 Dec 2020 16:13:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=b/6IDlgIuaPiFi3PCG/EBlRQiQL0G1n8iKguDE6+xZs=; b=nBgdV7MqqCi0jrnNL0G5vCziPP3hWR5CxMMEFzhlMbSZKDLyYRaNvarFKnJGJNLupm +bIB8bRJR9lFOtWcAUAsUPqzb/tS3vHExbRZyl9uIfv6lbu30Hvy/XX457A1oTo317ac LlD2spD6FeeMDFwX53Sc2fzxV8efDYFf92gN7v5/VBxc2jllt0sFDXzf04g2aypgVa4P kNElU/DJXRSAN5jkLafrH3+j7v4l9UuDRclGdwcjjuFIPn+Ijc69jOgbv1OZgREbU/z4 DHFTwyyFx3AN3dWJZdsU18VODPzJai1ntmmvTF6wIGttM6vI1/RcDla5a5jDrzDNhaJ9 IcQg== X-Gm-Message-State: AOAM530iGpFFPkhAm4hKEARtVv7OeP9Ia9VV0/naLdD/XEpxnAsGwdF1 F8gahUh4/9D7m3MTNOUZ4cED4SWb6awQz1IKoHE= X-Google-Smtp-Source: ABdhPJzusk7X/ayupfGQdchbsOaHir2dwkdQ2cTOdWE2vHf6WDcVndleY7zPlgpU8xdEQXTPBc8a10jRzt1zFHvyTCA= X-Received: by 2002:a17:906:6b88:: with SMTP id l8mr17610287ejr.482.1608595999140; Mon, 21 Dec 2020 16:13:19 -0800 (PST) MIME-Version: 1.0 References: <733c674bd1901c931a8917045eb72f661872f462.1608516320.git.gitgitgadget@gmail.com> In-Reply-To: From: Eric Sunshine Date: Mon, 21 Dec 2020 19:13:08 -0500 Message-ID: Subject: Re: [PATCH v3 1/3] test-lib-functions: handle --add in test_config To: Nipunn Koorapati Cc: Junio C Hamano , Nipunn Koorapati via GitGitGadget , Git List , Nipunn Koorapati Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Dec 21, 2020 at 7:00 PM Nipunn Koorapati wrote: > I found that since test_unconfig uses --unset-all, I can write a test as such > > test_config -C two remote.one.push +: && > test_must_fail git -C two push one && > git -C two config --add remote.one.push ^refs/heads/master && > git -C two push one > > The unconfig of the test_config will --unset-all remote.one.push. I can > use this technique and add a comment to that extent. Yes, you could do that, though it is somewhat subtle and increases cognitive load since the reader has to reason about it a bit more -- and perhaps study the internal implementation of test_config() -- to convince himself or herself that the different methods of setting configuration (test_config() vs. `git config`) used in the same test is intentional and works as intended. The example presented earlier, on the other hand, in which cleanup is explicit via `test_when_finished "test_unconfig ..."` does not suffer from such increased cognitive load since it uses `git config` consistently to set configuration rather than a mix of `git config` and test_config(). This sort of consideration is important not just for reviewers, but for people who need to understand the code down the road. For this reason, I think I favor the version in which the cleanup is explicit. (But that's just my opinion...)