diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2016-09-05 11:44:53 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-09-19 10:25:11 -0700 |
commit | 5b162879e93dab3b4bcd66afdbea3a96660abd7d (patch) | |
tree | 409c0b32b3ff0ae9be653d723900fc61c8eb909c /t | |
parent | parse-options: add parse_opt_unknown_cb() (diff) | |
download | tgif-5b162879e93dab3b4bcd66afdbea3a96660abd7d.tar.xz |
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')
-rwxr-xr-x | t/t4061-diff-indent.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/t/t4061-diff-indent.sh b/t/t4061-diff-indent.sh index 0a65b585af..556450609b 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 |