9c3b5963669dc0afde9a11737b9579fd1e2131e2
   1#!/bin/sh
   2
   3test_description='log --grep/--author/--regexp-ignore-case/-S/-G'
   4. ./test-lib.sh
   5
   6test_log () {
   7        expect=$1
   8        kind=$2
   9        needle=$3
  10        shift 3
  11        rest=$@
  12
  13        case $kind in
  14        --*)
  15                opt=$kind=$needle
  16                ;;
  17        *)
  18                opt=$kind$needle
  19                ;;
  20        esac
  21        case $expect in
  22        expect_nomatch)
  23                match=nomatch
  24                ;;
  25        *)
  26                match=match
  27                ;;
  28        esac
  29
  30        test_expect_success "log $kind${rest:+ $rest} ($match)" "
  31                git log $rest $opt --format=%H >actual &&
  32                test_cmp $expect actual
  33        "
  34}
  35
  36test_expect_success setup '
  37        >expect_nomatch &&
  38
  39        >file &&
  40        git add file &&
  41        test_tick &&
  42        git commit -m initial &&
  43        git rev-parse --verify HEAD >expect_initial &&
  44
  45        echo Picked >file &&
  46        git add file &&
  47        test_tick &&
  48        git commit --author="Another Person <another@example.com>" -m second &&
  49        git rev-parse --verify HEAD >expect_second
  50'
  51
  52test_expect_success 'log --grep' '
  53        git log --grep=initial --format=%H >actual &&
  54        test_cmp expect_initial actual
  55'
  56
  57test_expect_success 'log --grep --regexp-ignore-case' '
  58        git log --regexp-ignore-case --grep=InItial --format=%H >actual &&
  59        test_cmp expect_initial actual
  60'
  61
  62test_expect_success 'log --grep -i' '
  63        git log -i --grep=InItial --format=%H >actual &&
  64        test_cmp expect_initial actual
  65'
  66
  67test_expect_success 'log --author --regexp-ignore-case' '
  68        git log --regexp-ignore-case --author=person --format=%H >actual &&
  69        test_cmp expect_second actual
  70'
  71
  72test_expect_success 'log --author -i' '
  73        git log -i --author=person --format=%H >actual &&
  74        test_cmp expect_second actual
  75'
  76
  77test_log expect_nomatch -G picked
  78test_log expect_second  -G Picked
  79test_log expect_nomatch -G pickle --regexp-ignore-case
  80test_log expect_nomatch -G pickle -i
  81test_log expect_second  -G picked --regexp-ignore-case
  82test_log expect_second  -G picked -i
  83
  84test_expect_success 'log -G --textconv (missing textconv tool)' '
  85        echo "* diff=test" >.gitattributes &&
  86        test_must_fail git -c diff.test.textconv=missing log -Gfoo &&
  87        rm .gitattributes
  88'
  89
  90test_expect_success 'log -G --no-textconv (missing textconv tool)' '
  91        echo "* diff=test" >.gitattributes &&
  92        git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual &&
  93        test_cmp expect_nomatch actual &&
  94        rm .gitattributes
  95'
  96
  97test_log expect_nomatch -S picked
  98test_log expect_second  -S Picked
  99test_log expect_second  -S picked --regexp-ignore-case
 100test_log expect_second  -S picked -i
 101test_log expect_nomatch -S pickle --regexp-ignore-case
 102test_log expect_nomatch -S pickle -i
 103
 104test_expect_success 'log -S --textconv (missing textconv tool)' '
 105        echo "* diff=test" >.gitattributes &&
 106        test_must_fail git -c diff.test.textconv=missing log -Sfoo &&
 107        rm .gitattributes
 108'
 109
 110test_expect_success 'log -S --no-textconv (missing textconv tool)' '
 111        echo "* diff=test" >.gitattributes &&
 112        git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual &&
 113        test_cmp expect_nomatch actual &&
 114        rm .gitattributes
 115'
 116
 117test_done