git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/4] deterministic commit timestamps in tests

From
EWEric Wong <e@80x24.org>
Date
Jul 14, 2020, 21:47 UTC
Message-ID
<20200714214728.GA21660@dcvr>
In-Reply-To
<20200714123334.GB2587001@coredump.intra.peff.net>
Jeff King <peff@peff.net> wrote:
Show 14 quoted lines
> On Tue, Jul 14, 2020 at 08:31:42AM -0400, Jeff King wrote:
> 
> > We _could_ fix this by sorting before removing duplicates, but
> > presumably it's a useful part of the test to make sure the trees appear
> > in the same order in both spots. Likewise, we could use something like:
> > 
> >   perl -ne 'print unless $seen{$_}++'
> > 
> > to remove duplicates without impacting the order. But that doesn't work
> > either, because there are actually multiple (non-duplicate) commits with
> > the same trees (we change a file mode and then change it back). So we'd
> > actually have to de-duplicate the combination of subject and tree. Which
> > then further throws off t9100.18, which compares the tree hashes
> > exactly; we'd have to strip the result back down.
Right, log order matters, so sorting isn't ideal.
Show 17 quoted lines
> Actually, that last one isn't _too_ bad. It looks something like this:
> 
> diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
> index b80952f0ac..4502c5f97d 100755
> --- a/t/t9100-git-svn-basic.sh
> +++ b/t/t9100-git-svn-basic.sh
> @@ -204,8 +204,10 @@ GIT_SVN_ID=alt
>  export GIT_SVN_ID
>  test_expect_success "$name" \
>      'git svn init "$svnrepo" && git svn fetch &&
> -     git rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
> -     git rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
> +     git log --format="tree %T %s" remotes/git-svn |
> +	perl -lne "print unless \$seen{\$_}++" |
> +	cut -d" " -f1-2 >a &&
> +     git log --format="tree %T" remotes/alt >b &&
>       test_cmp a b'

The future of non-strict one-liners with Perl7 on the horizon seems uncertain :< cut is unnecessary either way, but I suggest awk, here:

	awk "!seen[\$0]++ { print \$1, \$2 }'
Show 7 quoted lines
>  name='check imported tree checksums expected tree checksums'
> 
> It does lose a little bit of information, which is that in the original
> we confirmed that the duplicates were always next to each other. But I'm
> not sure that's important. We'd get confused if the same subject
> appeared twice, but all of the commits have distinct hard-coded
> subjects in the earlier tests.

Yeah, but I think it's fine. It's been a while since I wrote this

Previous: Jeff KingNext: Jeff King
Message 9 of 13 in “deterministic commit timestamps in tests”
  1. 0/4 deterministic commit timestamps in testsJeff King, Jul 9, 2020
  2. 1/4 t6000: use test_tick consistentlyJeff King, Jul 9, 2020
  3. 2/4 t9700: loosen ident timezone regexJeff King, Jul 9, 2020
  4. 3/4 t5539: make timestamp requirements more explicitJeff King, Jul 9, 2020
  5. 4/4 test-lib: set deterministic default author/committer dateJeff King, Jul 9, 2020
  6. Junio C HamanoJul 10, 2020
  7. Jeff KingJul 14, 2020
  8. Jeff KingJul 14, 2020
  9. Eric WongJul 14, 2020
  10. Jeff KingJul 15, 2020
  11. Junio C HamanoJul 15, 2020
  12. Junio C HamanoJul 15, 2020
  13. Jeff KingJul 16, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.