1#!/bin/sh
23
test_description='git-mv in subdirs'
4. ./test-lib.sh
56
test_expect_success \
7'prepare reference tree' \
8'mkdir path0 path1 &&
9cp ../../COPYING path0/COPYING &&
10git-add path0/COPYING &&
11git-commit -m add -a'
1213
test_expect_success \
14'moving the file out of subdirectory' \
15'cd path0 && git-mv COPYING ../path1/COPYING'
1617
# in path0 currently
18test_expect_success \
19'commiting the change' \
20'cd .. && git-commit -m move-out -a'
2122
test_expect_success \
23'checking the commit' \
24'git-diff-tree -r -M --name-status HEAD^ HEAD | \
25grep -E "^R100.+path0/COPYING.+path1/COPYING"'
2627
test_expect_success \
28'moving the file back into subdirectory' \
29'cd path0 && git-mv ../path1/COPYING COPYING'
3031
# in path0 currently
32test_expect_success \
33'commiting the change' \
34'cd .. && git-commit -m move-in -a'
3536
test_expect_success \
37'checking the commit' \
38'git-diff-tree -r -M --name-status HEAD^ HEAD | \
39grep -E "^R100.+path1/COPYING.+path0/COPYING"'
4041
test_expect_success \
42'adding another file' \
43'cp ../../README path0/README &&
44git-add path0/README &&
45git-commit -m add2 -a'
4647
test_expect_success \
48'moving whole subdirectory' \
49'git-mv path0 path2'
5051
test_expect_success \
52'commiting the change' \
53'git-commit -m dir-move -a'
5455
test_expect_success \
56'checking the commit' \
57'git-diff-tree -r -M --name-status HEAD^ HEAD | \
58grep -E "^R100.+path0/COPYING.+path2/COPYING" &&
59git-diff-tree -r -M --name-status HEAD^ HEAD | \
60grep -E "^R100.+path0/README.+path2/README"'
6162
test_expect_success \
63'moving whole subdirectory into subdirectory' \
64'git-mv path2 path1'
6566
test_expect_success \
67'commiting the change' \
68'git-commit -m dir-move -a'
6970
test_expect_success \
71'checking the commit' \
72'git-diff-tree -r -M --name-status HEAD^ HEAD | \
73grep -E "^R100.+path2/COPYING.+path1/path2/COPYING" &&
74git-diff-tree -r -M --name-status HEAD^ HEAD | \
75grep -E "^R100.+path2/README.+path1/path2/README"'
7677
test_expect_failure \
78'do not move directory over existing directory' \
79'mkdir path0 && mkdir path0/path2 && git-mv path2 path0'
8081
test_done