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

Re: [PATCH 4/4] blame: test the -b option, use blank oid for boundary commits.

From
Jeff King <peff@peff.net>
Date
May 27, 2020, 07:30 UTC
Message-ID
<20200527073020.GB4006199@coredump.intra.peff.net>
In-Reply-To
<20200525215751.1735-5-philipoakley@iee.email>
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:
Show 9 quoted lines
> +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'

but I suppose some would consider that pretty magical, too. 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.
-Peff
Previous: Philip OakleyNext: Philip Oakley
Message 6 of 14 in “Selectively show only blamed limes”
  1. 0/4 Selectively show only blamed limesPhilip Oakley, May 25, 2020
  2. 1/4 doc: blame: show the boundary commit '^' caret markPhilip Oakley, May 25, 2020
  3. 2/4 blame: add option to show only blamed commits `--blame-only`Philip Oakley, May 25, 2020
  4. 3/4 blame: do not show boundary commits, only those blamedPhilip Oakley, May 25, 2020
  5. 4/4 blame: test the -b option, use blank oid for boundary commits.Philip Oakley, May 25, 2020
  6. Jeff KingMay 27, 2020
  7. Philip OakleyMay 27, 2020
  8. Jeff KingMay 27, 2020
  9. Philip OakleyMay 27, 2020
  10. Jeff KingMay 28, 2020
  11. Junio C HamanoMay 28, 2020
  12. Philip OakleyMay 30, 2020
  13. Junio C HamanoMay 31, 2020
  14. Junio C HamanoMay 31, 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.