From: Philip Oakley <philipoakley@iee.email>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/4] blame: test the -b option, use blank oid for boundary commits.
Date: Wed, 27 May 2020 11:52:19 +0100 [thread overview]
Message-ID: <aabb67b8-b342-aab9-6213-f7c2d5758719@iee.email> (raw)
In-Reply-To: <20200527073020.GB4006199@coredump.intra.peff.net>
On 27/05/2020 08:30, Jeff King wrote:
> On Mon, May 25, 2020 at 10:57:51PM +0100, Philip Oakley wrote:
>
>> The sed script removes the last hex digit from boundary commit oids
>> '^hexx msg' -> '^hex msg' until all leading hex's are gone, finally
>> removing the boundary commit marker.
> Thanks for documenting this, as the sed was rather hard to read:
It was hard to write as well;-) lots of dead ends in the sed language.
>
>> +test_expect_success 'test -b option, blank oid for boundary commits' '
>> + git blame -b branch1.. -- file >actual &&
>> + git blame branch1.. -- file >full &&
>> + sed -e "/^\^/{
>> + :loop;
>> + s/^\(\^[0-9a-f]*\)[0-9a-f] \(.*\)/\1 \2/g;
>> + tloop;
>> + s/^\^/ /;
>> + }" full >expected &&
> I wonder if we can make it simpler.
>
> In perl I'd probably just replace the whole string with the equivalent
> number of spaces, like:
>
> perl -pe 's/^\^\S+/" " x length($&)/e'
I'm not a perl person, so I thought sed might be an easy target but ...
it wasn't.
>
> but I suppose some would consider that pretty magical, too.
I'd need to look it up!
> It might be
> simpler still to just avoid testing leading whitespace:
>
> sed 's/^\^[0-9a-f]* *//' <full >expected &&
> sed 's/^ *//' <actual >actual.stripped &&
> test_cmp expected actual.stripped
>
> but perhaps the indentation is a useful part of what we're testing.
The code does take care to exactly match indentation, so I felt that the
indentation should be tested.
Philip
next prev parent reply other threads:[~2020-05-27 10:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-25 21:57 [PATCH 0/4] Selectively show only blamed limes Philip Oakley
2020-05-25 21:57 ` [PATCH 1/4] doc: blame: show the boundary commit '^' caret mark Philip Oakley
2020-05-25 21:57 ` [PATCH 2/4] blame: add option to show only blamed commits `--blame-only` Philip Oakley
2020-05-25 21:57 ` [PATCH 3/4] blame: do not show boundary commits, only those blamed Philip Oakley
2020-05-25 21:57 ` [PATCH 4/4] blame: test the -b option, use blank oid for boundary commits Philip Oakley
2020-05-27 7:30 ` Jeff King
2020-05-27 10:52 ` Philip Oakley [this message]
2020-05-27 7:23 ` [PATCH 0/4] Selectively show only blamed limes Jeff King
2020-05-27 10:24 ` Philip Oakley
2020-05-28 16:45 ` Jeff King
2020-05-28 18:30 ` Junio C Hamano
2020-05-30 16:18 ` Philip Oakley
2020-05-31 16:02 ` Junio C Hamano
2020-05-31 16:28 ` Junio C Hamano
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=aabb67b8-b342-aab9-6213-f7c2d5758719@iee.email \
--to=philipoakley@iee.email \
--cc=git@vger.kernel.org \
--cc=peff@peff.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).