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-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,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 CC61F1F8C6 for ; Wed, 30 Jun 2021 20:44:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233400AbhF3Uqg (ORCPT ); Wed, 30 Jun 2021 16:46:36 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:52976 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbhF3Uqg (ORCPT ); Wed, 30 Jun 2021 16:46:36 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id C6999CBECA; Wed, 30 Jun 2021 16:44:05 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=Xa18OSnPztzR X8Zd/t7oA9SJqyK/i2I98A+Hp9w81U4=; b=ZTr74DNMrqhKAEbDG90mqK8EaOjf y+P9JBuF2WoKpEr46mZ2KsHEg13MaQ+7AuZlUYr0TRZ3qQ9ITMbx+yoIqNICBDZz gX+4IX0ETEdQ72Cd/9f4Adq+VRXu7tKfZ0qMW4MUiQAM2pods879pTSfXtas68AB MeIaZpeqAyAO4pk= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id BC7F7CBEC9; Wed, 30 Jun 2021 16:44:05 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.74.3.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 2B73FCBEC8; Wed, 30 Jun 2021 16:44:05 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: =?utf-8?B?xJBvw6BuIFRy4bqnbiBDw7RuZw==?= Danh Cc: Eric Sunshine , Git List , =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Bagas Sanjaya , Phillip Wood , Felipe Contreras Subject: Re: [PATCH v4 1/2] t6400: preserve git ls-files exit status code References: <20210615172038.28917-1-congdanhqx@gmail.com> <49104273b8b801fc61811347120c5f4c42a3700b.1624974969.git.congdanhqx@gmail.com> Date: Wed, 30 Jun 2021 13:44:04 -0700 In-Reply-To: (=?utf-8?B?IsSQb8OgbiBUcuG6p24g?= =?utf-8?B?Q8O0bmc=?= Danh"'s message of "Wed, 30 Jun 2021 18:01:37 +0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Pobox-Relay-ID: E8D67232-D9E3-11EB-9CC2-FD8818BA3BAF-77302942!pb-smtp2.pobox.com Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org =C4=90o=C3=A0n Tr=E1=BA=A7n C=C3=B4ng Danh writes= : >> Could be, except that I recall we saw extra noises like --out/--err >> that weren't used and contaminating the current working directory, >> which are gone from the latest iteration. > > Yes, in v{1,2}, there's the extra noises of --out and --err, > but it's gone in v3. > > I guess you're thinking about the contamination of $PWD iff it's not > a git worktree. That could be simplified by BUG-ging if $PWD is not > a git worktree. No. I am not thinking about that. I do not think it is a big loss if the helper cannot be used in non-repository. > Maybe, you're thinking about the extra noises to handle the failure run > of command under check? That could be dropped, too. No. I am not thinking about that, either. > Would you mind looking at v3 1/4 again to see what is your opinion > there? I don't mind re-roll a same or simplified version of v3, > with s/test_line_count_cmd/test_output_wc_l/ if you see fit. Let's not go back that far. This is taken from v4 (t/t6400) ... local ops val && if test "$#" -le 2 then BUG "Expect 2 or more arguments" fi && ops=3D"$1" && val=3D"$2" && shift 2 && mkdir -p .git/trash && "$@" >.git/trash/output && test_line_count "$ops" "$val" .git/trash/output ... except that it runs '"$@"' instead of 'git ls-files "$@"', so that we could try running things other than ls-files, and that would be mostly good enough. We may want to be prepared for a caller who wants to use the helper from within a subdirectory by not hardcoding ".git/trash", though. Something along the lines of ... local ops val && + local trashdir=3D$(git rev-parse --git-dir)/trash && if test ... ... - mkdir -p .git/trash && - "$@" >".git/trash/output" && - test_line_count "$ops" "$val" .git/trash/output + mkdir -p "$trashdir" && + "$@" >"$trashdir/output" && + test_line_count "$ops" "$val" "$trashdir/output"