t / t8001-annotate.shon commit Fix test case for some sed (d5dddcc)
   1#!/bin/sh
   2
   3test_description='git-annotate'
   4. ./test-lib.sh
   5
   6test_expect_success \
   7    'prepare reference tree' \
   8    'echo "1A quick brown fox jumps over the" >file &&
   9     echo "lazy dog" >>file &&
  10     git add file
  11     GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
  12
  13test_expect_success \
  14    'check all lines blamed on A' \
  15    '[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'
  16
  17test_expect_success \
  18    'Setup new lines blamed on B' \
  19    'echo "2A quick brown fox jumps over the" >>file &&
  20     echo "lazy dog" >> file &&
  21     GIT_AUTHOR_NAME="B" git commit -a -m "Second."'
  22
  23test_expect_success \
  24    'Two lines blamed on A' \
  25    '[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'
  26
  27test_expect_success \
  28    'Two lines blamed on B' \
  29    '[ $(git annotate file | awk "{print \$3}" | grep -c "B") == 2 ]'
  30
  31test_expect_success \
  32    'merge-setup part 1' \
  33    'git checkout -b branch1 master &&
  34     echo "3A slow green fox jumps into the" >> file &&
  35     echo "well." >> file &&
  36     GIT_AUTHOR_NAME="B1" git commit -a -m "Branch1-1"'
  37
  38test_expect_success \
  39    'Two lines blamed on A' \
  40    '[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
  41
  42test_expect_success \
  43    'Two lines blamed on B' \
  44    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 2 ]'
  45
  46test_expect_success \
  47    'Two lines blamed on B1' \
  48    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'
  49
  50test_expect_success \
  51    'merge-setup part 2' \
  52    'git checkout -b branch2 master &&
  53     sed -e "s/2A quick brown/4A quick brown lazy dog/" < file > file.new &&
  54     mv file.new file &&
  55     GIT_AUTHOR_NAME="B2" git commit -a -m "Branch2-1"'
  56
  57test_expect_success \
  58    'Two lines blamed on A' \
  59    '[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
  60
  61test_expect_success \
  62    'One line blamed on B' \
  63    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 1 ]'
  64
  65test_expect_success \
  66    'One line blamed on B2' \
  67    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
  68
  69
  70test_expect_success \
  71    'merge-setup part 3' \
  72    'git pull . branch1'
  73
  74test_expect_success \
  75    'Two lines blamed on A' \
  76    '[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
  77
  78test_expect_success \
  79    'One line blamed on B' \
  80    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 1 ]'
  81
  82test_expect_success \
  83    'Two lines blamed on B1' \
  84    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'
  85
  86test_expect_success \
  87    'One line blamed on B2' \
  88    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
  89
  90test_done