blob: 8c9823765e66aca886a1ec32a8ad523c1c28e1bc [file] [log] [blame]
Junio C Hamanob45563a2007-11-30 22:22:38 -08001#!/bin/sh
2
3test_description='typechange rename detection'
4
5. ./test-lib.sh
6
Johannes Sixt622f98e2013-06-07 22:53:32 +02007test_expect_success setup '
Junio C Hamanob45563a2007-11-30 22:22:38 -08008
9 rm -f foo bar &&
Junio C Hamanobfdbee92008-08-08 02:26:28 -070010 cat "$TEST_DIRECTORY"/../COPYING >foo &&
Johannes Sixt622f98e2013-06-07 22:53:32 +020011 test_ln_s_add linklink bar &&
12 git add foo &&
Junio C Hamanob45563a2007-11-30 22:22:38 -080013 git commit -a -m Initial &&
14 git tag one &&
15
Johannes Sixt622f98e2013-06-07 22:53:32 +020016 git rm -f foo bar &&
Junio C Hamanobfdbee92008-08-08 02:26:28 -070017 cat "$TEST_DIRECTORY"/../COPYING >bar &&
Johannes Sixt622f98e2013-06-07 22:53:32 +020018 test_ln_s_add linklink foo &&
19 git add bar &&
Junio C Hamanob45563a2007-11-30 22:22:38 -080020 git commit -a -m Second &&
21 git tag two &&
22
Johannes Sixt622f98e2013-06-07 22:53:32 +020023 git rm -f foo bar &&
Junio C Hamanobfdbee92008-08-08 02:26:28 -070024 cat "$TEST_DIRECTORY"/../COPYING >foo &&
Junio C Hamanob45563a2007-11-30 22:22:38 -080025 git add foo &&
26 git commit -a -m Third &&
27 git tag three &&
28
29 mv foo bar &&
Johannes Sixt622f98e2013-06-07 22:53:32 +020030 test_ln_s_add linklink foo &&
31 git add bar &&
Junio C Hamanob45563a2007-11-30 22:22:38 -080032 git commit -a -m Fourth &&
33 git tag four &&
34
35 # This is purely for sanity check
36
Johannes Sixt622f98e2013-06-07 22:53:32 +020037 git rm -f foo bar &&
Junio C Hamanobfdbee92008-08-08 02:26:28 -070038 cat "$TEST_DIRECTORY"/../COPYING >foo &&
39 cat "$TEST_DIRECTORY"/../Makefile >bar &&
Junio C Hamanob45563a2007-11-30 22:22:38 -080040 git add foo bar &&
41 git commit -a -m Fifth &&
42 git tag five &&
43
Johannes Sixt622f98e2013-06-07 22:53:32 +020044 git rm -f foo bar &&
Junio C Hamanobfdbee92008-08-08 02:26:28 -070045 cat "$TEST_DIRECTORY"/../Makefile >foo &&
46 cat "$TEST_DIRECTORY"/../COPYING >bar &&
Junio C Hamanob45563a2007-11-30 22:22:38 -080047 git add foo bar &&
48 git commit -a -m Sixth &&
49 git tag six
50
51'
52
Johannes Sixt622f98e2013-06-07 22:53:32 +020053test_expect_success 'cross renames to be detected for regular files' '
Junio C Hamanob45563a2007-11-30 22:22:38 -080054
55 git diff-tree five six -r --name-status -B -M | sort >actual &&
56 {
57 echo "R100 foo bar"
58 echo "R100 bar foo"
59 } | sort >expect &&
Jeff King82ebb0b2008-03-12 17:36:36 -040060 test_cmp expect actual
Junio C Hamanob45563a2007-11-30 22:22:38 -080061
62'
63
Johannes Sixt622f98e2013-06-07 22:53:32 +020064test_expect_success 'cross renames to be detected for typechange' '
Junio C Hamanob45563a2007-11-30 22:22:38 -080065
66 git diff-tree one two -r --name-status -B -M | sort >actual &&
67 {
68 echo "R100 foo bar"
69 echo "R100 bar foo"
70 } | sort >expect &&
Jeff King82ebb0b2008-03-12 17:36:36 -040071 test_cmp expect actual
Junio C Hamanob45563a2007-11-30 22:22:38 -080072
73'
74
Johannes Sixt622f98e2013-06-07 22:53:32 +020075test_expect_success 'moves and renames' '
Junio C Hamanob45563a2007-11-30 22:22:38 -080076
77 git diff-tree three four -r --name-status -B -M | sort >actual &&
78 {
Junio C Hamano6936b582014-10-23 10:02:02 -070079 # see -B -M (#6) in t4008
80 echo "C100 foo bar"
Junio C Hamanob45563a2007-11-30 22:22:38 -080081 echo "T100 foo"
82 } | sort >expect &&
Jeff King82ebb0b2008-03-12 17:36:36 -040083 test_cmp expect actual
Junio C Hamanob45563a2007-11-30 22:22:38 -080084
85'
86
87test_done