t / t4202-log.shon commit Merge branch 'jc/maint-checkout-keep-remove' into maint (2ba3d5d)
   1#!/bin/sh
   2
   3test_description='git log'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8
   9        echo one >one &&
  10        git add one &&
  11        test_tick &&
  12        git commit -m initial &&
  13
  14        echo ichi >one &&
  15        git add one &&
  16        test_tick &&
  17        git commit -m second &&
  18
  19        mkdir a &&
  20        echo ni >a/two &&
  21        git add a/two &&
  22        test_tick &&
  23        git commit -m third &&
  24
  25        echo san >a/three &&
  26        git add a/three &&
  27        test_tick &&
  28        git commit -m fourth &&
  29
  30        git rm a/three &&
  31        test_tick &&
  32        git commit -m fifth
  33
  34'
  35
  36test_expect_success 'diff-filter=A' '
  37
  38        actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) &&
  39        expect=$(echo fourth ; echo third ; echo initial) &&
  40        test "$actual" = "$expect" || {
  41                echo Oops
  42                echo "Actual: $actual"
  43                false
  44        }
  45
  46'
  47
  48test_expect_success 'diff-filter=M' '
  49
  50        actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
  51        expect=$(echo second) &&
  52        test "$actual" = "$expect" || {
  53                echo Oops
  54                echo "Actual: $actual"
  55                false
  56        }
  57
  58'
  59
  60test_expect_success 'diff-filter=D' '
  61
  62        actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
  63        expect=$(echo fifth) &&
  64        test "$actual" = "$expect" || {
  65                echo Oops
  66                echo "Actual: $actual"
  67                false
  68        }
  69
  70'
  71
  72test_expect_success 'setup case sensitivity tests' '
  73        echo case >one &&
  74        test_tick &&
  75        git commit -a -m Second
  76'
  77
  78test_expect_success 'log --grep' '
  79        echo second >expect &&
  80        git log -1 --pretty="tformat:%s" --grep=sec >actual &&
  81        test_cmp expect actual
  82'
  83
  84test_expect_success 'log -i --grep' '
  85        echo Second >expect &&
  86        git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
  87        test_cmp expect actual
  88'
  89
  90test_expect_success 'log --grep -i' '
  91        echo Second >expect &&
  92        git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
  93        test_cmp expect actual
  94'
  95
  96test_done
  97