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

[PATCH 2/3] t8003: factor setup out of coalesce test

From
Jeff King <peff@peff.net>
Date
Aug 13, 2020, 05:23 UTC
Message-ID
<20200813052341.GB2514880@coredump.intra.peff.net>
In-Reply-To
<20200813052054.GA1962792@coredump.intra.peff.net>

In preparation for adding more tests of blame's coalesce code, let's split the setup out from the first test, and give each of the commits a more meaningful name:

  - $orig for the original source that added the lines
  - $split for the version where they are split apart
  - $final for the final version that re-joins them

That's not strictly necessary, but makes the follow-on tests less brittle than relying on HEAD^, etc, to name the commits.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t8003-blame-corner-cases.sh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/t/t8003-blame-corner-cases.sh b/t/t8003-blame-corner-cases.sh
index 1e89494ef6..7f39a84289 100755
--- a/t/t8003-blame-corner-cases.sh
+++ b/t/t8003-blame-corner-cases.sh
@@ -273,14 +273,14 @@ test_expect_success 'blame file with CRLF core.autocrlf=true' '
 	grep "A U Thor" actual
 '
 
-test_expect_success 'blame coalesce' '
+test_expect_success 'setup coalesce tests' '
 	cat >giraffe <<-\EOF &&
 	ABC
 	DEF
 	EOF
 	git add giraffe &&
 	git commit -m "original file" &&
-	oid=$(git rev-parse HEAD) &&
+	orig=$(git rev-parse HEAD) &&
 
 	cat >giraffe <<-\EOF &&
 	ABC
@@ -289,20 +289,24 @@ test_expect_success 'blame coalesce' '
 	EOF
 	git add giraffe &&
 	git commit -m "interior SPLIT line" &&
+	split=$(git rev-parse HEAD) &&
 
 	cat >giraffe <<-\EOF &&
 	ABC
 	DEF
 	EOF
 	git add giraffe &&
 	git commit -m "same contents as original" &&
+	final=$(git rev-parse HEAD)
+'
 
+test_expect_success 'blame coalesce' '
 	cat >expect <<-EOF &&
-	$oid 1 1 2
-	$oid 2 2
+	$orig 1 1 2
+	$orig 2 2
 	EOF
-	git blame --porcelain giraffe >actual.raw &&
-	grep "^$oid" actual.raw >actual &&
+	git blame --porcelain $final giraffe >actual.raw &&
+	grep "^$orig" actual.raw >actual &&
 	test_cmp expect actual
 '
 
-- 
2.28.0.570.ge2c3ee08e4
Previous: Jeff KingNext: Jeff King
Message 12 of 16 in “`git blame` Line Number Off-by-one”
  1. Nuthan MunaiahAug 7, 2020
  2. Jeff KingAug 7, 2020
  3. Jeff KingAug 7, 2020
  4. Jeff KingAug 7, 2020
  5. Junio C HamanoAug 7, 2020
  6. Jeff KingAug 7, 2020
  7. Jeff KingAug 7, 2020
  8. 0/3 blame: fix bug in coalescing non-adjacent "-L" chunksJeff King, Aug 13, 2020
  9. 1/3 t8003: check output of coalesced blameJeff King, Aug 13, 2020
  10. Junio C HamanoAug 13, 2020
  11. Jeff KingAug 13, 2020
  12. 2/3 t8003: factor setup out of coalesce testJeff King, Aug 13, 2020
  13. 3/3 blame: only coalesce lines that are adjacent in resultJeff King, Aug 13, 2020
  14. Junio C HamanoAug 13, 2020
  15. Junio C HamanoAug 13, 2020
  16. Barret RhodenAug 13, 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.