Re: [PATCH v2 1/7] t1414: document some reflog-walk oddities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 07, 2017 at 05:06:10AM -0400, Jeff King wrote:

> +test_expect_failure 'walking multiple reflogs shows all' '
> +	# We expect to see all entries for all reflogs, but interleaved by
> +	# date, with order no the command line breaking ties. We
> +	# can use "sort" on the separate lists to generate this,
> +	# but note two tricks:
> +	#
> +	#   1. We use "{" as the delimiter, which lets us skip to the reflog
> +	#      date specifier as our second field, and then our "-n" numeric
> +	#      sort ignores the bits after the timestamp.
> +	#
> +	#   2. POSIX leaves undefined whether this is a stable sort or not. So
> +	#      we use "-k 1" to ensure that we see HEAD before master before
> +	#      side when breaking ties.
> +	{
> +		do_walk --date=unix HEAD &&
> +		do_walk --date=unix side &&
> +		do_walk --date=unix master
> +	} >expect.raw &&
> +	sort -t "{" -k 2nr -k 1 <expect.raw >expect &&

I won't lie; the contortions needed for this "sort" made me a little
sick to my stomach.

It would be much easier if we could do something like:

  git log -g --format="%gt %gd"

and just get the reflog timestamp separately. But we never added %gt, so
we'd have to munge it with sed or perl.

One thing that perl would buy is that we could rely on a stable sort,
and ask for an order besides alphabetical. I.e., we could ask for:

  do_walk side master HEAD

and confirm that "side" comes before "HEAD", even though it doesn't
byte-wise sort.

I didn't think writing a perl snippet was worth the trouble for that
minor benefit, though probably it would be shorter than the comment I
needed to explain the "sort" invocation. ;)

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux