t / t4023-diff-rename-typechange.shon commit Sync with 1.6.2.2 (8130949)
   1#!/bin/sh
   2
   3test_description='typechange rename detection'
   4
   5. ./test-lib.sh
   6
   7if ! test_have_prereq SYMLINKS
   8then
   9        say 'Symbolic links not supported, skipping tests.'
  10        test_done
  11        exit
  12fi
  13
  14test_expect_success setup '
  15
  16        rm -f foo bar &&
  17        cat "$TEST_DIRECTORY"/../COPYING >foo &&
  18        ln -s linklink bar &&
  19        git add foo bar &&
  20        git commit -a -m Initial &&
  21        git tag one &&
  22
  23        rm -f foo bar &&
  24        cat "$TEST_DIRECTORY"/../COPYING >bar &&
  25        ln -s linklink foo &&
  26        git add foo bar &&
  27        git commit -a -m Second &&
  28        git tag two &&
  29
  30        rm -f foo bar &&
  31        cat "$TEST_DIRECTORY"/../COPYING >foo &&
  32        git add foo &&
  33        git commit -a -m Third &&
  34        git tag three &&
  35
  36        mv foo bar &&
  37        ln -s linklink foo &&
  38        git add foo bar &&
  39        git commit -a -m Fourth &&
  40        git tag four &&
  41
  42        # This is purely for sanity check
  43
  44        rm -f foo bar &&
  45        cat "$TEST_DIRECTORY"/../COPYING >foo &&
  46        cat "$TEST_DIRECTORY"/../Makefile >bar &&
  47        git add foo bar &&
  48        git commit -a -m Fifth &&
  49        git tag five &&
  50
  51        rm -f foo bar &&
  52        cat "$TEST_DIRECTORY"/../Makefile >foo &&
  53        cat "$TEST_DIRECTORY"/../COPYING >bar &&
  54        git add foo bar &&
  55        git commit -a -m Sixth &&
  56        git tag six
  57
  58'
  59
  60test_expect_success 'cross renames to be detected for regular files' '
  61
  62        git diff-tree five six -r --name-status -B -M | sort >actual &&
  63        {
  64                echo "R100      foo     bar"
  65                echo "R100      bar     foo"
  66        } | sort >expect &&
  67        test_cmp expect actual
  68
  69'
  70
  71test_expect_success 'cross renames to be detected for typechange' '
  72
  73        git diff-tree one two -r --name-status -B -M | sort >actual &&
  74        {
  75                echo "R100      foo     bar"
  76                echo "R100      bar     foo"
  77        } | sort >expect &&
  78        test_cmp expect actual
  79
  80'
  81
  82test_expect_success 'moves and renames' '
  83
  84        git diff-tree three four -r --name-status -B -M | sort >actual &&
  85        {
  86                echo "R100      foo     bar"
  87                echo "T100      foo"
  88        } | sort >expect &&
  89        test_cmp expect actual
  90
  91'
  92
  93test_done