Merge branch 'pb/test-parse-options-expect'
[gitweb.git] / t / t4061-diff-indent.sh
index 0a65b585af9e346901096a891e1b6bc0abfc1da2..556450609b91873efc966d36f20b84f33425b4dc 100755 (executable)
@@ -14,6 +14,14 @@ compare_diff () {
        test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
 }
 
+# Compare blame output using the expectation for a diff as reference.
+# Only look for the lines coming from non-boundary commits.
+compare_blame () {
+       sed -n -e "1,4d" -e "s/^\+//p" <"$1" >.tmp-1
+       sed -ne "s/^[^^][^)]*) *//p" <"$2" >.tmp-2
+       test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+}
+
 test_expect_success 'prepare' '
        cat <<-\EOF >spaces.txt &&
        1
@@ -184,4 +192,25 @@ test_expect_success 'diff: nice functions with --indent-heuristic' '
        compare_diff functions-compacted-expect out-compacted
 '
 
+test_expect_success 'blame: ugly spaces' '
+       git blame old..new -- spaces.txt >out-blame &&
+       compare_blame spaces-expect out-blame
+'
+
+test_expect_success 'blame: nice spaces with --indent-heuristic' '
+       git blame --indent-heuristic old..new -- spaces.txt >out-blame-compacted &&
+       compare_blame spaces-compacted-expect out-blame-compacted
+'
+
+test_expect_success 'blame: nice spaces with diff.indentHeuristic' '
+       git -c diff.indentHeuristic=true blame old..new -- spaces.txt >out-blame-compacted2 &&
+       compare_blame spaces-compacted-expect out-blame-compacted2
+'
+
+test_expect_success 'blame: --no-indent-heuristic overrides config' '
+       git -c diff.indentHeuristic=true blame --no-indent-heuristic old..new -- spaces.txt >out-blame2 &&
+       git blame old..new -- spaces.txt >out-blame &&
+       compare_blame spaces-expect out-blame2
+'
+
 test_done