aboutsummaryrefslogtreecommitdiffstats
path: root/t/lib-diff-alternative.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-02-27 10:08:56 -0800
committerJunio C Hamano <gitster@pobox.com>2023-02-27 10:08:56 -0800
commitece8dc97ae53d08247aa283b6f299e3e5b2669db (patch)
tree3af9afced2453f047c1e45f9d9e4639e89dec0d9 /t/lib-diff-alternative.sh
parentMerge branch 'pw/rebase-i-validate-labels-early' (diff)
parentdiff: teach diff to read algorithm from diff driver (diff)
downloadgit-ece8dc97ae53d08247aa283b6f299e3e5b2669db.tar.gz
git-ece8dc97ae53d08247aa283b6f299e3e5b2669db.zip
Merge branch 'jc/diff-algo-attribute'
The "diff" drivers specified by the "diff" attribute attached to paths can now specify which algorithm (e.g. histogram) to use. * jc/diff-algo-attribute: diff: teach diff to read algorithm from diff driver diff: consolidate diff algorithm option parsing
Diffstat (limited to 't/lib-diff-alternative.sh')
-rw-r--r--t/lib-diff-alternative.sh38
1 files changed, 37 insertions, 1 deletions
diff --git a/t/lib-diff-alternative.sh b/t/lib-diff-alternative.sh
index 8d1e408bb5..a8f5d3274a 100644
--- a/t/lib-diff-alternative.sh
+++ b/t/lib-diff-alternative.sh
@@ -105,10 +105,46 @@ index $file1..$file2 100644
}
EOF
+ cat >expect_diffstat <<EOF
+ file1 => file2 | 21 ++++++++++-----------
+ 1 file changed, 10 insertions(+), 11 deletions(-)
+EOF
+
STRATEGY=$1
+ test_expect_success "$STRATEGY diff from attributes" '
+ echo "file* diff=driver" >.gitattributes &&
+ git config diff.driver.algorithm "$STRATEGY" &&
+ test_must_fail git diff --no-index file1 file2 > output &&
+ cat expect &&
+ cat output &&
+ test_cmp expect output
+ '
+
+ test_expect_success "$STRATEGY diff from attributes has valid diffstat" '
+ echo "file* diff=driver" >.gitattributes &&
+ git config diff.driver.algorithm "$STRATEGY" &&
+ test_must_fail git diff --stat --no-index file1 file2 > output &&
+ test_cmp expect_diffstat output
+ '
+
test_expect_success "$STRATEGY diff" '
- test_must_fail git diff --no-index "--$STRATEGY" file1 file2 > output &&
+ test_must_fail git diff --no-index "--diff-algorithm=$STRATEGY" file1 file2 > output &&
+ test_cmp expect output
+ '
+
+ test_expect_success "$STRATEGY diff command line precedence before attributes" '
+ echo "file* diff=driver" >.gitattributes &&
+ git config diff.driver.algorithm myers &&
+ test_must_fail git diff --no-index "--diff-algorithm=$STRATEGY" file1 file2 > output &&
+ test_cmp expect output
+ '
+
+ test_expect_success "$STRATEGY diff attributes precedence before config" '
+ git config diff.algorithm default &&
+ echo "file* diff=driver" >.gitattributes &&
+ git config diff.driver.algorithm "$STRATEGY" &&
+ test_must_fail git diff --no-index file1 file2 > output &&
test_cmp expect output
'