t / t4015-diff-whitespace.shon commit fix importing of subversion tars (46f6178)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Johannes E. Schindelin
   4#
   5
   6test_description='Test special whitespace in diff engine.
   7
   8'
   9. ./test-lib.sh
  10. ../diff-lib.sh
  11
  12# Ray Lehtiniemi's example
  13
  14cat << EOF > x
  15do {
  16   nothing;
  17} while (0);
  18EOF
  19
  20git-update-index --add x
  21
  22cat << EOF > x
  23do
  24{
  25   nothing;
  26}
  27while (0);
  28EOF
  29
  30cat << EOF > expect
  31diff --git a/x b/x
  32index adf3937..6edc172 100644
  33--- a/x
  34+++ b/x
  35@@ -1,3 +1,5 @@
  36-do {
  37+do
  38+{
  39    nothing;
  40-} while (0);
  41+}
  42+while (0);
  43EOF
  44
  45git-diff > out
  46test_expect_success "Ray's example without options" 'git diff expect out'
  47
  48git-diff -w > out
  49test_expect_success "Ray's example with -w" 'git diff expect out'
  50
  51git-diff -b > out
  52test_expect_success "Ray's example with -b" 'git diff expect out'
  53
  54tr 'Q' '\015' << EOF > x
  55whitespace at beginning
  56whitespace change
  57whitespace in the middle
  58whitespace at end
  59unchanged line
  60CR at endQ
  61EOF
  62
  63git-update-index x
  64
  65cat << EOF > x
  66        whitespace at beginning
  67whitespace       change
  68white space in the middle
  69whitespace at end  
  70unchanged line
  71CR at end
  72EOF
  73
  74tr 'Q' '\015' << EOF > expect
  75diff --git a/x b/x
  76index d99af23..8b32fb5 100644
  77--- a/x
  78+++ b/x
  79@@ -1,6 +1,6 @@
  80-whitespace at beginning
  81-whitespace change
  82-whitespace in the middle
  83-whitespace at end
  84+       whitespace at beginning
  85+whitespace      change
  86+white space in the middle
  87+whitespace at end  
  88 unchanged line
  89-CR at endQ
  90+CR at end
  91EOF
  92git-diff > out
  93test_expect_success 'another test, without options' 'git diff expect out'
  94
  95cat << EOF > expect
  96diff --git a/x b/x
  97index d99af23..8b32fb5 100644
  98EOF
  99git-diff -w > out
 100test_expect_success 'another test, with -w' 'git diff expect out'
 101
 102tr 'Q' '\015' << EOF > expect
 103diff --git a/x b/x
 104index d99af23..8b32fb5 100644
 105--- a/x
 106+++ b/x
 107@@ -1,6 +1,6 @@
 108-whitespace at beginning
 109+       whitespace at beginning
 110 whitespace change
 111-whitespace in the middle
 112+white space in the middle
 113 whitespace at end
 114 unchanged line
 115 CR at endQ
 116EOF
 117git-diff -b > out
 118test_expect_success 'another test, with -b' 'git diff expect out'
 119
 120test_done