git-svn: fix log with single revision against a non-HEAD branch
[git/dscho.git] / t / t7001-mv.sh
blob8b43fb5a27af181e30a4fd125260174b7b49e3c0
1 #!/bin/sh
3 test_description='git mv in subdirs'
4 . ./test-lib.sh
6 test_expect_success \
7 'prepare reference tree' \
8 'mkdir path0 path1 &&
9 cp ../../COPYING path0/COPYING &&
10 git add path0/COPYING &&
11 git-commit -m add -a'
13 test_expect_success \
14 'moving the file out of subdirectory' \
15 'cd path0 && git mv COPYING ../path1/COPYING'
17 # in path0 currently
18 test_expect_success \
19 'commiting the change' \
20 'cd .. && git-commit -m move-out -a'
22 test_expect_success \
23 'checking the commit' \
24 'git diff-tree -r -M --name-status HEAD^ HEAD | \
25 grep -E "^R100.+path0/COPYING.+path1/COPYING"'
27 test_expect_success \
28 'moving the file back into subdirectory' \
29 'cd path0 && git mv ../path1/COPYING COPYING'
31 # in path0 currently
32 test_expect_success \
33 'commiting the change' \
34 'cd .. && git-commit -m move-in -a'
36 test_expect_success \
37 'checking the commit' \
38 'git diff-tree -r -M --name-status HEAD^ HEAD | \
39 grep -E "^R100.+path1/COPYING.+path0/COPYING"'
41 test_expect_success \
42 'adding another file' \
43 'cp ../../README path0/README &&
44 git add path0/README &&
45 git-commit -m add2 -a'
47 test_expect_success \
48 'moving whole subdirectory' \
49 'git mv path0 path2'
51 test_expect_success \
52 'commiting the change' \
53 'git-commit -m dir-move -a'
55 test_expect_success \
56 'checking the commit' \
57 'git diff-tree -r -M --name-status HEAD^ HEAD | \
58 grep -E "^R100.+path0/COPYING.+path2/COPYING" &&
59 git diff-tree -r -M --name-status HEAD^ HEAD | \
60 grep -E "^R100.+path0/README.+path2/README"'
62 test_expect_success \
63 'succeed when source is a prefix of destination' \
64 'git mv path2/COPYING path2/COPYING-renamed'
66 test_expect_success \
67 'moving whole subdirectory into subdirectory' \
68 'git mv path2 path1'
70 test_expect_success \
71 'commiting the change' \
72 'git-commit -m dir-move -a'
74 test_expect_success \
75 'checking the commit' \
76 'git diff-tree -r -M --name-status HEAD^ HEAD | \
77 grep -E "^R100.+path2/COPYING.+path1/path2/COPYING" &&
78 git diff-tree -r -M --name-status HEAD^ HEAD | \
79 grep -E "^R100.+path2/README.+path1/path2/README"'
81 test_expect_failure \
82 'do not move directory over existing directory' \
83 'mkdir path0 && mkdir path0/path2 && git mv path2 path0'
85 test_expect_success \
86 'move into "."' \
87 'git mv path1/path2/ .'
89 test_expect_success "Michael Cassar's test case" '
90 rm -fr .git papers partA &&
91 git init &&
92 mkdir -p papers/unsorted papers/all-papers partA &&
93 echo a > papers/unsorted/Thesis.pdf &&
94 echo b > partA/outline.txt &&
95 echo c > papers/unsorted/_another &&
96 git add papers partA &&
97 T1=`git write-tree` &&
99 git mv papers/unsorted/Thesis.pdf papers/all-papers/moo-blah.pdf &&
101 T=`git write-tree` &&
102 git ls-tree -r $T | grep partA/outline.txt || {
103 git ls-tree -r $T
104 (exit 1)
108 rm -fr papers partA path?
110 test_expect_success "Sergey Vlasov's test case" '
111 rm -fr .git &&
112 git init &&
113 mkdir ab &&
114 date >ab.c &&
115 date >ab/d &&
116 git add ab.c ab &&
117 git commit -m 'initial' &&
118 git mv ab a
121 test_done