git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>,
	Jeff King <peff@peff.net>,
	git@vger.kernel.org, Elijah Newren <newren@gmail.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2 0/2] t/helper/test-tool: implement 'sha1-unsafe' helper
Date: Thu, 7 Nov 2024 16:33:56 -0500	[thread overview]
Message-ID: <Zy0yRLt5dM554yq1@nand.local> (raw)
In-Reply-To: <ZywgZt419SfPUVkQ@tapette.crustytoothpaste.net>

On Thu, Nov 07, 2024 at 02:05:26AM +0000, brian m. carlson wrote:
> On 2024-11-07 at 01:47:37, Jeff King wrote:
> > I think this is a useful thing to have, and I didn't see anything wrong
> > in the implementation. I did notice some oddities that existed before
> > your series:
> >
> >   1. Why do we have "test-tool sha256" at all? Nobody in the test suite
> >      calls it. It feels like the whole test-sha1/sha256/hash split is
> >      overly complicated. A single "test-tool hash" seems like it would
> >      be simpler, and it could take an "--algo" parameter (and an
> >      "--unsafe" one). I guess in the end we end up with the same options
> >      ,but the proliferation of top-level test-tool commands seems ugly
> >      to me (likewise "sha1_is_sha1dc").
>
> I think we do in `pack_trailer` in `t/lib-pack.sh`, but not in a
> greppable way:
>
>   # Compute and append pack trailer to "$1"
>   pack_trailer () {
>   	test-tool $(test_oid algo) -b <"$1" >trailer.tmp &&
>   	cat trailer.tmp >>"$1" &&
>   	rm -f trailer.tmp
>   }

Nice find. I think that it may be worth writing this as:

    case "$(test_oid algo)" in
    sha1)
        test-tool sha1 -b <"$1" >trailer.tmp
        ;;
    sha256)
        test-tool sha256 -b <"$1" >trailer.tmp
        ;;
    *)
        echo >&2 "unknown algorithm: $(test_oid algo)"
        exit 1
        ;;
    esac

To make it more greppable. Obviously the existing implementation is not
wrong, but I do find it remarkably hard to search for ;-).

> I think a single helper with `--algo` and `--unsafe` parameters would
> also be fine and would probably be a little more tidy, as you mention.

That would be nice too.

Thanks,
Taylor

  reply	other threads:[~2024-11-07 21:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-05 19:05 [PATCH v2 0/2] t/helper/test-tool: implement 'sha1-unsafe' helper Taylor Blau
2024-11-05 19:05 ` [PATCH v2 1/2] t/helper/test-sha1: prepare for an unsafe mode Taylor Blau
2024-11-06  1:38   ` Junio C Hamano
2024-11-07  0:48     ` brian m. carlson
2024-11-07  1:39       ` Jeff King
2024-11-07  1:49         ` brian m. carlson
2024-11-07  2:08           ` Jeff King
2024-11-07  3:08             ` Junio C Hamano
2024-11-07 21:30           ` Taylor Blau
2024-11-07 23:20             ` Taylor Blau
2024-11-08 17:26             ` Jeff King
2024-11-05 19:05 ` [PATCH v2 2/2] t/helper/test-tool: implement sha1-unsafe helper Taylor Blau
2024-11-07  1:47 ` [PATCH v2 0/2] t/helper/test-tool: implement 'sha1-unsafe' helper Jeff King
2024-11-07  2:05   ` brian m. carlson
2024-11-07 21:33     ` Taylor Blau [this message]
2024-11-08 17:23       ` Jeff King
2024-11-08 17:22     ` Jeff King
2024-11-07 21:36   ` Taylor Blau
2024-11-08 17:23     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zy0yRLt5dM554yq1@nand.local \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).