t / t4005-diff-rename-2.shon commit Merge branch 'master' of https://github.com/vnwildman/git (26a567e)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano
   4#
   5
   6test_description='Same rename detection as t4003 but testing diff-raw.'
   7
   8. ./test-lib.sh
   9. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
  10
  11test_expect_success 'setup reference tree' '
  12        cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
  13        echo frotz >rezrov &&
  14        git update-index --add COPYING rezrov &&
  15        tree=$(git write-tree) &&
  16        echo $tree &&
  17        sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
  18        sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
  19        origoid=$(git hash-object COPYING) &&
  20        oid1=$(git hash-object COPYING.1) &&
  21        oid2=$(git hash-object COPYING.2)
  22'
  23
  24################################################################
  25# tree has COPYING and rezrov.  work tree has COPYING.1 and COPYING.2,
  26# both are slightly edited, and unchanged rezrov.  We say COPYING.1
  27# and COPYING.2 are based on COPYING, and do not say anything about
  28# rezrov.
  29
  30test_expect_success 'validate output from rename/copy detection (#1)' '
  31        rm -f COPYING &&
  32        git update-index --add --remove COPYING COPYING.? &&
  33
  34        cat <<-EOF >expected &&
  35        :100644 100644 $origoid $oid1 C1234     COPYING COPYING.1
  36        :100644 100644 $origoid $oid2 R1234     COPYING COPYING.2
  37        EOF
  38        git diff-index -C $tree >current &&
  39        compare_diff_raw expected current
  40'
  41
  42################################################################
  43# tree has COPYING and rezrov.  work tree has COPYING and COPYING.1,
  44# both are slightly edited, and unchanged rezrov.  We say COPYING.1
  45# is based on COPYING and COPYING is still there, and do not say anything
  46# about rezrov.
  47
  48test_expect_success 'validate output from rename/copy detection (#2)' '
  49        mv COPYING.2 COPYING &&
  50        git update-index --add --remove COPYING COPYING.1 COPYING.2 &&
  51
  52        cat <<-EOF >expected &&
  53        :100644 100644 $origoid $oid2 M COPYING
  54        :100644 100644 $origoid $oid1 C1234     COPYING COPYING.1
  55        EOF
  56        git diff-index -C $tree >current &&
  57        compare_diff_raw current expected
  58'
  59
  60################################################################
  61# tree has COPYING and rezrov.  work tree has the same COPYING and
  62# copy-edited COPYING.1, and unchanged rezrov.  We should not say
  63# anything about rezrov or COPYING, since the revised again diff-raw
  64# nows how to say Copy.
  65
  66test_expect_success 'validate output from rename/copy detection (#3)' '
  67        cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
  68        git update-index --add --remove COPYING COPYING.1 &&
  69
  70        cat <<-EOF >expected &&
  71        :100644 100644 $origoid $oid1 C1234     COPYING COPYING.1
  72        EOF
  73        git diff-index -C --find-copies-harder $tree >current &&
  74        compare_diff_raw current expected
  75'
  76
  77test_done