t / t4035-diff-quiet.shon commit Sync with 2.10.1 (0cf3611)
   1#!/bin/sh
   2
   3test_description='Return value of diffs'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'setup' '
   8        echo 1 >a &&
   9        git add . &&
  10        git commit -m first &&
  11        echo 2 >b &&
  12        git add . &&
  13        git commit -a -m second &&
  14        mkdir -p test-outside/repo && (
  15                cd test-outside/repo &&
  16                git init &&
  17                echo "1 1" >a &&
  18                git add . &&
  19                git commit -m 1
  20        ) &&
  21        mkdir -p test-outside/non/git && (
  22                cd test-outside/non/git &&
  23                echo "1 1" >a &&
  24                echo "1 1" >matching-file &&
  25                echo "1 1 " >trailing-space &&
  26                echo "1   1" >extra-space &&
  27                echo "2" >never-match
  28        )
  29'
  30
  31test_expect_success 'git diff-tree HEAD^ HEAD' '
  32        test_expect_code 1 git diff-tree --quiet HEAD^ HEAD >cnt &&
  33        test_line_count = 0 cnt
  34'
  35test_expect_success 'git diff-tree HEAD^ HEAD -- a' '
  36        test_expect_code 0 git diff-tree --quiet HEAD^ HEAD -- a >cnt &&
  37        test_line_count = 0 cnt
  38'
  39test_expect_success 'git diff-tree HEAD^ HEAD -- b' '
  40        test_expect_code 1 git diff-tree --quiet HEAD^ HEAD -- b >cnt &&
  41        test_line_count = 0 cnt
  42'
  43# this diff outputs one line: sha1 of the given head
  44test_expect_success 'echo HEAD | git diff-tree --stdin' '
  45        echo $(git rev-parse HEAD) |
  46        test_expect_code 1 git diff-tree --quiet --stdin >cnt &&
  47        test_line_count = 1 cnt
  48'
  49test_expect_success 'git diff-tree HEAD HEAD' '
  50        test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt &&
  51        test_line_count = 0 cnt
  52'
  53test_expect_success 'git diff-files' '
  54        test_expect_code 0 git diff-files --quiet >cnt &&
  55        test_line_count = 0 cnt
  56'
  57test_expect_success 'git diff-index --cached HEAD' '
  58        test_expect_code 0 git diff-index --quiet --cached HEAD >cnt &&
  59        test_line_count = 0 cnt
  60'
  61test_expect_success 'git diff-index --cached HEAD^' '
  62        test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
  63        test_line_count = 0 cnt
  64'
  65test_expect_success 'git diff-index --cached HEAD^' '
  66        echo text >>b &&
  67        echo 3 >c &&
  68        git add . &&
  69        test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
  70        test_line_count = 0 cnt
  71'
  72test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' '
  73        git commit -m "text in b" &&
  74        test_expect_code 1 git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt &&
  75        test_line_count = 0 cnt
  76'
  77test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' '
  78        test_expect_code 0 git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt &&
  79        test_line_count = 0 cnt
  80'
  81test_expect_success 'git diff-files' '
  82        echo 3 >>c &&
  83        test_expect_code 1 git diff-files --quiet >cnt &&
  84        test_line_count = 0 cnt
  85'
  86
  87test_expect_success 'git diff-index --cached HEAD' '
  88        git update-index c &&
  89        test_expect_code 1 git diff-index --quiet --cached HEAD >cnt &&
  90        test_line_count = 0 cnt
  91'
  92
  93test_expect_success 'git diff, one file outside repo' '
  94        (
  95                cd test-outside/repo &&
  96                test_expect_code 0 git diff --quiet a ../non/git/matching-file &&
  97                test_expect_code 1 git diff --quiet a ../non/git/extra-space
  98        )
  99'
 100
 101test_expect_success 'git diff, both files outside repo' '
 102        (
 103                GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
 104                export GIT_CEILING_DIRECTORIES &&
 105                cd test-outside/non/git &&
 106                test_expect_code 0 git diff --quiet a matching-file &&
 107                test_expect_code 1 git diff --quiet a extra-space
 108        )
 109'
 110
 111test_expect_success 'git diff --ignore-space-at-eol, one file outside repo' '
 112        (
 113                cd test-outside/repo &&
 114                test_expect_code 0 git diff --quiet --ignore-space-at-eol a ../non/git/trailing-space &&
 115                test_expect_code 1 git diff --quiet --ignore-space-at-eol a ../non/git/extra-space
 116        )
 117'
 118
 119test_expect_success 'git diff --ignore-space-at-eol, both files outside repo' '
 120        (
 121                GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
 122                export GIT_CEILING_DIRECTORIES &&
 123                cd test-outside/non/git &&
 124                test_expect_code 0 git diff --quiet --ignore-space-at-eol a trailing-space &&
 125                test_expect_code 1 git diff --quiet --ignore-space-at-eol a extra-space
 126        )
 127'
 128
 129test_expect_success 'git diff --ignore-all-space, one file outside repo' '
 130        (
 131                cd test-outside/repo &&
 132                test_expect_code 0 git diff --quiet --ignore-all-space a ../non/git/trailing-space &&
 133                test_expect_code 0 git diff --quiet --ignore-all-space a ../non/git/extra-space &&
 134                test_expect_code 1 git diff --quiet --ignore-all-space a ../non/git/never-match
 135        )
 136'
 137
 138test_expect_success 'git diff --ignore-all-space, both files outside repo' '
 139        (
 140                GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
 141                export GIT_CEILING_DIRECTORIES &&
 142                cd test-outside/non/git &&
 143                test_expect_code 0 git diff --quiet --ignore-all-space a trailing-space &&
 144                test_expect_code 0 git diff --quiet --ignore-all-space a extra-space &&
 145                test_expect_code 1 git diff --quiet --ignore-all-space a never-match
 146        )
 147'
 148
 149test_expect_success 'git diff --quiet ignores stat-change only entries' '
 150        test-chmtime +10 a &&
 151        echo modified >>b &&
 152        test_expect_code 1 git diff --quiet
 153'
 154
 155test_done