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

[PATCH 4/7] diff-highlight: test interleaved parallel lines of history

From
Jeff King <peff@peff.net>
Date
Mar 21, 2018, 05:49 UTC
Message-ID
<20180321054926.GD14016@sigill.intra.peff.net>
In-Reply-To
<20180321054718.GA13936@sigill.intra.peff.net>

The graph test in t9400 covers the case of two simultaneous branches, but all of the commits during this time are on the right-hand branch. So we test a graph structure like:

  | |
  | * commit ...
  | |

but we never see the reverse, a commit on the left-hand branch:

  | |
  * | commit ...
  | |

Since this is an easy thing to get wrong when touching the graph-matching code, let's cover it by adding one more commit with its timestamp interleaved with the other branch.

Note that we need to pass --date-order to convince Git to show it this way (since --topo-order tries to keep lines of history separate).

Signed-off-by: Jeff King <peff@peff.net>
---
 .../diff-highlight/t/t9400-diff-highlight.sh  | 22 +++++++++++++------
 1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/contrib/diff-highlight/t/t9400-diff-highlight.sh b/contrib/diff-highlight/t/t9400-diff-highlight.sh
index 3f02d31467..33bcdbc90f 100755
--- a/contrib/diff-highlight/t/t9400-diff-highlight.sh
+++ b/contrib/diff-highlight/t/t9400-diff-highlight.sh
@@ -52,15 +52,17 @@ test_strip_patch_header () {
 # dh_test_setup_history generates a contrived graph such that we have at least
 # 1 nesting (E) and 2 nestings (F).
 #
-#	  A master
+#	  A---B master
 #	 /
 #	D---E---F branch
 #
 #	git log --all --graph
 #	* commit
-#	|    A
+#	|    B
 #	| * commit
 #	| |    F
+#	* | commit
+#	| |    A
 #	| * commit
 #	|/
 #	|    E
@@ -78,14 +80,20 @@ dh_test_setup_history () {
 	test_tick &&
 	git commit -a -m "E" &&
 
+	git checkout master &&
+	echo file2 >file &&
+	test_tick &&
+	git commit -a -m "A" &&
+
+	git checkout branch &&
 	echo file3 >file &&
 	test_tick &&
 	git commit -a -m "F" &&
 
 	git checkout master &&
-	echo file2 >file &&
+	echo file3 >file &&
 	test_tick &&
-	git commit -a -m "A"
+	git commit -a -m "B"
 }
 
 left_trim () {
@@ -246,12 +254,12 @@ test_expect_failure 'diff-highlight treats combining code points as a unit' '
 test_expect_success 'diff-highlight works with the --graph option' '
 	dh_test_setup_history &&
 
-	# topo-order so that the order of the commits is the same as with --graph
+	# date-order so that the commits are interleaved for both
 	# trim graph elements so we can do a diff
 	# trim leading space because our trim_graph is not perfect
-	git log --branches -p --topo-order |
+	git log --branches -p --date-order |
 		"$DIFF_HIGHLIGHT" | left_trim >graph.exp &&
-	git log --branches -p --graph |
+	git log --branches -p --date-order --graph |
 		"$DIFF_HIGHLIGHT" | trim_graph | left_trim >graph.act &&
 	test_cmp graph.exp graph.act
 '
-- 
2.17.0.rc0.402.ged0b3fd1ee
Previous: Jeff KingNext: Jeff King
Message 9 of 15 in “[BUG] log --graph corrupts patch”
  1. Phillip WoodMar 19, 2018
  2. Jeff KingMar 20, 2018
  3. Phillip WoodMar 20, 2018
  4. Jeff KingMar 20, 2018
  5. Jeff KingMar 21, 2018
  6. 1/7 diff-highlight: correct test graph diagramJeff King, Mar 21, 2018
  7. 2/7 diff-highlight: use test_tick in graph testJeff King, Mar 21, 2018
  8. 3/7 diff-highlight: prefer "echo" to "cat" in testsJeff King, Mar 21, 2018
  9. 4/7 diff-highlight: test interleaved parallel lines of historyJeff King, Mar 21, 2018
  10. 5/7 diff-highlight: test graphs with --colorJeff King, Mar 21, 2018
  11. 6/7 diff-highlight: use flush() helper consistentlyJeff King, Mar 21, 2018
  12. 7/7 diff-highlight: detect --graph by indentJeff King, Mar 21, 2018
  13. Phillip WoodMar 22, 2018
  14. Jeff KingMar 22, 2018
  15. Junio C HamanoMar 21, 2018

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.