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

[PATCH v2 2/3] diff-highlight: add failing test for handling --graph output.

From
Brian Henderson <henderson.bj@gmail.com>
Date
Aug 17, 2016, 15:31 UTC
Message-ID
<20160817153124.7770-3-henderson.bj@gmail.com>
In-Reply-To
<20160817153124.7770-1-henderson.bj@gmail.com>
Signed-off-by: Brian Henderson <henderson.bj@gmail.com>
---
 contrib/diff-highlight/t/t9400-diff-highlight.sh | 13 +++++++
 contrib/diff-highlight/t/test-diff-highlight.sh  | 43 ++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
diff --git a/contrib/diff-highlight/t/t9400-diff-highlight.sh b/contrib/diff-highlight/t/t9400-diff-highlight.sh
index 8eff178..39707c6 100755
--- a/contrib/diff-highlight/t/t9400-diff-highlight.sh
+++ b/contrib/diff-highlight/t/t9400-diff-highlight.sh
@@ -59,4 +59,17 @@ test_expect_success 'diff-highlight does not highlight mismatched hunk size' '
 
 # TODO add multi-byte test
 
+test_expect_success 'diff-highlight highlights the beginning of a line' '
+	dh_graph_test \
+		"aaa\nbbb\nccc\n" \
+		"aaa\n0bb\nccc\n" \
+		"aaa\nb0b\nccc\n" \
+"
+ aaa
+-${CW}b${CR}bb
++${CW}0${CR}bb
+ ccc
+"
+'
+
 test_done
diff --git a/contrib/diff-highlight/t/test-diff-highlight.sh b/contrib/diff-highlight/t/test-diff-highlight.sh
index 38323e8..67f742c 100644
--- a/contrib/diff-highlight/t/test-diff-highlight.sh
+++ b/contrib/diff-highlight/t/test-diff-highlight.sh
@@ -64,6 +64,49 @@ dh_commit_test() {
 	test_cmp commit.exp commit.act
 }
 
+dh_graph_test() {
+	a="$1" b="$2" c="$3"
+
+	{
+		printf "$a" >file
+		git add file
+		git commit -m"Add a file"
+
+		printf "$b" >file
+		git commit -am"Update a file"
+
+		git checkout -b branch
+		printf "$c" >file
+		git commit -am"Update a file on branch"
+
+		git checkout master
+		printf "$a" >file
+		git commit -am"Update a file again"
+
+		git checkout branch
+		printf "$b" >file
+		git commit -am"Update a file similar to master"
+
+		git merge master
+		git checkout master
+		git merge branch --no-ff
+	} >/dev/null 2>&1
+
+	git log -p --graph --no-merges >graph.raw
+
+	# git log --graph orders the commits different than git log so we hack it by
+	# using sed to remove the graph part. We know from other tests, that DIFF_HIGHLIGHT
+	# works without the graph, so there should be no diff when running it with
+	# and without.
+	<graph.raw sed -e 's"^\(*\|| \||/\)\+""' -e 's"^  ""' | "$DIFF_HIGHLIGHT" >graph.exp
+	<graph.raw "$DIFF_HIGHLIGHT" | sed -e 's"^\(*\|| \||/\)\+""' -e 's"^  ""' >graph.act &&
+
+	test -s graph.act &&
+	# ignore whitespace since we're using a hacky sed command to remove the graph
+	# parts.
+	git diff -b --no-index graph.exp graph.act
+}
+
 test_chomp_eof() {
 	perl -pe 'chomp if eof'
 }
-- 
2.9.0
Previous: Brian HendersonNext: Junio C Hamano
Message 11 of 24 in “diff-highlight: add support for git log --graph output.”
  1. 0/3 diff-highlight: add support for git log --graph output.Brian Henderson, Jul 30, 2016
  2. 3/3 diff-highlight: add support for --graph output.Brian Henderson, Jul 30, 2016
  3. Junio C HamanoAug 1, 2016
  4. diff-highlight: Add comment for our assumption about --graph output.Brian Henderson, Aug 4, 2016
  5. 2/3 diff-highlight: add failing test for handling --graph output.Brian Henderson, Jul 30, 2016
  6. 1/3 diff-highlight: add some tests.Brian Henderson, Jul 30, 2016
  7. Eric WongAug 10, 2016
  8. Brian HendersonAug 15, 2016
  9. Junio C HamanoAug 15, 2016
  10. 0/3 diff-highlight: add support for git log --graph output.Brian Henderson, Aug 17, 2016
  11. 2/3 diff-highlight: add failing test for handling --graph output.Brian Henderson, Aug 17, 2016
  12. Junio C HamanoAug 17, 2016
  13. 1/3 diff-highlight: add some tests.Brian Henderson, Aug 17, 2016
  14. Junio C HamanoAug 17, 2016
  15. Brian HendersonAug 19, 2016
  16. Jeff KingAug 19, 2016
  17. Brian HendersonAug 19, 2016
  18. 3/3 diff-highlight: add support for --graph output.Brian Henderson, Aug 17, 2016
  19. Jeff KingAug 19, 2016
  20. Eric WongAug 19, 2016
  21. Jeff KingAug 19, 2016
  22. Lars SchneiderAug 15, 2016
  23. Junio C HamanoAug 16, 2016
  24. Lars SchneiderAug 24, 2016

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.