summaryrefslogtreecommitdiff
path: root/t/t4061-diff-indent.sh
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2016-09-05 09:44:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-19 17:25:11 (GMT)
commit5b162879e93dab3b4bcd66afdbea3a96660abd7d (patch)
tree409c0b32b3ff0ae9be653d723900fc61c8eb909c /t/t4061-diff-indent.sh
parentce564eb1bd541a87152e3546fb7d7a2b460df7ed (diff)
downloadgit-5b162879e93dab3b4bcd66afdbea3a96660abd7d.zip
git-5b162879e93dab3b4bcd66afdbea3a96660abd7d.tar.gz
git-5b162879e93dab3b4bcd66afdbea3a96660abd7d.tar.bz2
blame: honor the diff heuristic options and config
Teach "git blame" and "git annotate" the --compaction-heuristic and --indent-heuristic options that are now supported by "git diff". Also teach them to honor the `diff.compactionHeuristic` and `diff.indentHeuristic` configuration options. It would be conceivable to introduce separate configuration options for "blame" and "annotate"; for example `blame.compactionHeuristic` and `blame.indentHeuristic`. But it would be confusing to users if blame output is inconsistent with diff output, so it makes more sense for them to respect the same configuration. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4061-diff-indent.sh')
-rwxr-xr-xt/t4061-diff-indent.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/t/t4061-diff-indent.sh b/t/t4061-diff-indent.sh
index 0a65b58..5564506 100755
--- a/t/t4061-diff-indent.sh
+++ b/t/t4061-diff-indent.sh
@@ -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