Signed-off-by: Brian Henderson <[email protected]>
---
contrib/diff-highlight/t/t9400-diff-highlight.sh | 54 ++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/contrib/diff-highlight/t/t9400-diff-highlight.sh
b/contrib/diff-highlight/t/t9400-diff-highlight.sh
index 6b8a461..3b3c831 100755
--- a/contrib/diff-highlight/t/t9400-diff-highlight.sh
+++ b/contrib/diff-highlight/t/t9400-diff-highlight.sh
@@ -85,10 +85,50 @@ dh_commit_test () {
test_cmp commit.exp commit.act
}
+# dh_test_setup_history takes a series (3) of changes and generates a
contrived graph
+# of commits and merges
+dh_test_setup_history () {
+ 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
+}
+
+
test_chomp_eof () {
"$PERL_PATH" -pe 'chomp if eof'
}
+left_trim () {
+ "$PERL_PATH" -pe 's/^\s+//'
+}
+
+trim_graph_el () {
+ # graphs start with * or |
+ # followed by a space or / or \
+ "$PERL_PATH" -pe 's@^((\*|\|)( |/|\\))+@@'
+}
+
test_expect_success 'diff-highlight highlights the beginning of a line' '
dh_test \
"aaa\nbbb\nccc\n" \
@@ -145,6 +185,20 @@ test_expect_failure 'diff-highlight highlights mismatched
hunk size' '
# TODO add multi-byte test
+test_expect_failure 'diff-highlight works with the --graph option' '
+ dh_test_setup_history \
+ "aaa\nbbb\nccc\n" \
+ "aaa\n0bb\nccc\n" \
+ "aaa\nb0b\nccc\n" &&
+
+ # topo-order so that the order of the commits is the same as with
--graph
+ # trim graph elements so we can do a diff
+ # trim leading space because our trim_graph_el is not perfect
+ git log -p --topo-order | "$DIFF_HIGHLIGHT" | left_trim >graph.exp &&
+ git log -p --graph | "$DIFF_HIGHLIGHT" | trim_graph_el | left_trim
>graph.act &&
+ test_cmp graph.exp graph.act
+'
+
test_done
# vim: set noet
--
2.9.0
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html