t / t4048-diff-combined-binary.shon commit refactor get_textconv to not require diff_filespec (3813e69)
   1#!/bin/sh
   2
   3test_description='combined and merge diff handle binary files and textconv'
   4. ./test-lib.sh
   5
   6test_expect_success 'setup binary merge conflict' '
   7        echo oneQ1 | q_to_nul >binary &&
   8        git add binary &&
   9        git commit -m one &&
  10        echo twoQ2 | q_to_nul >binary &&
  11        git commit -a -m two &&
  12        git checkout -b branch-binary HEAD^ &&
  13        echo threeQ3 | q_to_nul >binary &&
  14        git commit -a -m three &&
  15        test_must_fail git merge master &&
  16        echo resolvedQhooray | q_to_nul >binary &&
  17        git commit -a -m resolved
  18'
  19
  20cat >expect <<'EOF'
  21resolved
  22
  23diff --git a/binary b/binary
  24index 7ea6ded..9563691 100644
  25Binary files a/binary and b/binary differ
  26resolved
  27
  28diff --git a/binary b/binary
  29index 6197570..9563691 100644
  30Binary files a/binary and b/binary differ
  31EOF
  32test_expect_success 'diff -m indicates binary-ness' '
  33        git show --format=%s -m >actual &&
  34        test_cmp expect actual
  35'
  36
  37cat >expect <<'EOF'
  38resolved
  39
  40diff --combined binary
  41index 7ea6ded,6197570..9563691
  42Binary files differ
  43EOF
  44test_expect_success 'diff -c indicates binary-ness' '
  45        git show --format=%s -c >actual &&
  46        test_cmp expect actual
  47'
  48
  49cat >expect <<'EOF'
  50resolved
  51
  52diff --cc binary
  53index 7ea6ded,6197570..9563691
  54Binary files differ
  55EOF
  56test_expect_success 'diff --cc indicates binary-ness' '
  57        git show --format=%s --cc >actual &&
  58        test_cmp expect actual
  59'
  60
  61test_expect_success 'setup non-binary with binary attribute' '
  62        git checkout master &&
  63        test_commit one text &&
  64        test_commit two text &&
  65        git checkout -b branch-text HEAD^ &&
  66        test_commit three text &&
  67        test_must_fail git merge master &&
  68        test_commit resolved text &&
  69        echo text -diff >.gitattributes
  70'
  71
  72cat >expect <<'EOF'
  73resolved
  74
  75diff --git a/text b/text
  76index 2bdf67a..2ab19ae 100644
  77Binary files a/text and b/text differ
  78resolved
  79
  80diff --git a/text b/text
  81index f719efd..2ab19ae 100644
  82Binary files a/text and b/text differ
  83EOF
  84test_expect_success 'diff -m respects binary attribute' '
  85        git show --format=%s -m >actual &&
  86        test_cmp expect actual
  87'
  88
  89cat >expect <<'EOF'
  90resolved
  91
  92diff --combined text
  93index 2bdf67a,f719efd..2ab19ae
  94Binary files differ
  95EOF
  96test_expect_success 'diff -c respects binary attribute' '
  97        git show --format=%s -c >actual &&
  98        test_cmp expect actual
  99'
 100
 101cat >expect <<'EOF'
 102resolved
 103
 104diff --cc text
 105index 2bdf67a,f719efd..2ab19ae
 106Binary files differ
 107EOF
 108test_expect_success 'diff --cc respects binary attribute' '
 109        git show --format=%s --cc >actual &&
 110        test_cmp expect actual
 111'
 112
 113test_done