t / t8004-blame-with-conflicts.shon commit Merge branch 'gp/avoid-explicit-mention-of-dot-git-refs' (9adf272)
   1#!/bin/sh
   2
   3# Based on a test case submitted by Björn Steinbrink.
   4
   5test_description='git blame on conflicted files'
   6. ./test-lib.sh
   7
   8test_expect_success 'setup first case' '
   9        # Create the old file
  10        echo "Old line" > file1 &&
  11        git add file1 &&
  12        git commit --author "Old Line <ol@localhost>" -m file1.a &&
  13
  14        # Branch
  15        git checkout -b foo &&
  16
  17        # Do an ugly move and change
  18        git rm file1 &&
  19        echo "New line ..."  > file2 &&
  20        echo "... and more" >> file2 &&
  21        git add file2 &&
  22        git commit --author "U Gly <ug@localhost>" -m ugly &&
  23
  24        # Back to master and change something
  25        git checkout master &&
  26        echo "
  27
  28bla" >> file1 &&
  29        git commit --author "Old Line <ol@localhost>" -a -m file1.b &&
  30
  31        # Back to foo and merge master
  32        git checkout foo &&
  33        if git merge master; then
  34                echo needed conflict here
  35                exit 1
  36        else
  37                echo merge failed - resolving automatically
  38        fi &&
  39        echo "New line ...
  40... and more
  41
  42bla
  43Even more" > file2 &&
  44        git rm file1 &&
  45        git commit --author "M Result <mr@localhost>" -a -m merged &&
  46
  47        # Back to master and change file1 again
  48        git checkout master &&
  49        sed s/bla/foo/ <file1 >X &&
  50        rm file1 &&
  51        mv X file1 &&
  52        git commit --author "No Bla <nb@localhost>" -a -m replace &&
  53
  54        # Try to merge into foo again
  55        git checkout foo &&
  56        if git merge master; then
  57                echo needed conflict here
  58                exit 1
  59        else
  60                echo merge failed - test is setup
  61        fi
  62'
  63
  64test_expect_success \
  65        'blame runs on unconflicted file while other file has conflicts' '
  66        git blame file2
  67'
  68
  69test_expect_success 'blame does not crash with conflicted file in stages 1,3' '
  70        git blame file1
  71'
  72
  73test_done