Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2006 Eric Wong |
| 4 | # |
| 5 | |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 6 | test_description='git svn property tests' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 7 | . ./lib-git-svn.sh |
| 8 | |
| 9 | mkdir import |
| 10 | |
| 11 | a_crlf= |
| 12 | a_lf= |
| 13 | a_cr= |
| 14 | a_ne_crlf= |
| 15 | a_ne_lf= |
| 16 | a_ne_cr= |
| 17 | a_empty= |
| 18 | a_empty_lf= |
| 19 | a_empty_cr= |
| 20 | a_empty_crlf= |
| 21 | |
| 22 | cd import |
Eric Wong | 3c4c735 | 2006-05-29 19:03:45 -0700 | [diff] [blame] | 23 | cat >> kw.c <<\EOF |
Eric Wong | dc62e25 | 2006-06-28 03:07:14 -0700 | [diff] [blame] | 24 | /* Somebody prematurely put a keyword into this file */ |
| 25 | /* $Id$ */ |
Eric Wong | 3c4c735 | 2006-05-29 19:03:45 -0700 | [diff] [blame] | 26 | EOF |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 27 | |
| 28 | printf "Hello\r\nWorld\r\n" > crlf |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 29 | a_crlf=`git hash-object -w crlf` |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 30 | printf "Hello\rWorld\r" > cr |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 31 | a_cr=`git hash-object -w cr` |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 32 | printf "Hello\nWorld\n" > lf |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 33 | a_lf=`git hash-object -w lf` |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 34 | |
| 35 | printf "Hello\r\nWorld" > ne_crlf |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 36 | a_ne_crlf=`git hash-object -w ne_crlf` |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 37 | printf "Hello\nWorld" > ne_lf |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 38 | a_ne_lf=`git hash-object -w ne_lf` |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 39 | printf "Hello\rWorld" > ne_cr |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 40 | a_ne_cr=`git hash-object -w ne_cr` |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 41 | |
| 42 | touch empty |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 43 | a_empty=`git hash-object -w empty` |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 44 | printf "\n" > empty_lf |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 45 | a_empty_lf=`git hash-object -w empty_lf` |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 46 | printf "\r" > empty_cr |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 47 | a_empty_cr=`git hash-object -w empty_cr` |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 48 | printf "\r\n" > empty_crlf |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 49 | a_empty_crlf=`git hash-object -w empty_crlf` |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 50 | |
Nanako Shiraishi | f964732 | 2008-09-10 06:25:27 +0900 | [diff] [blame] | 51 | svn import --no-auto-props -m 'import for git svn' . "$svnrepo" >/dev/null |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 52 | cd .. |
| 53 | |
| 54 | rm -rf import |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 55 | test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc' |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 56 | test_expect_success 'setup some commits to svn' \ |
| 57 | 'cd test_wc && |
| 58 | echo Greetings >> kw.c && |
Michael Spang | 7b3fab8 | 2007-02-12 19:33:37 -0500 | [diff] [blame] | 59 | poke kw.c && |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 60 | svn commit -m "Not yet an Id" && |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 61 | echo Hello world >> kw.c && |
Michael Spang | 7b3fab8 | 2007-02-12 19:33:37 -0500 | [diff] [blame] | 62 | poke kw.c && |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 63 | svn commit -m "Modified file, but still not yet an Id" && |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 64 | svn propset svn:keywords Id kw.c && |
Michael Spang | 7b3fab8 | 2007-02-12 19:33:37 -0500 | [diff] [blame] | 65 | poke kw.c && |
| 66 | svn commit -m "Propset Id" && |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 67 | cd ..' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 68 | |
Nanako Shiraishi | f964732 | 2008-09-10 06:25:27 +0900 | [diff] [blame] | 69 | test_expect_success 'initialize git svn' 'git svn init "$svnrepo"' |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 70 | test_expect_success 'fetch revisions from svn' 'git svn fetch' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 71 | |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 72 | name='test svn:keywords ignoring' |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 73 | test_expect_success "$name" \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 74 | 'git checkout -b mybranch ${remotes_git_svn} && |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 75 | echo Hi again >> kw.c && |
Pavel Roskin | 3dff537 | 2007-02-03 23:49:16 -0500 | [diff] [blame] | 76 | git commit -a -m "test keywords ignoring" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 77 | git svn set-tree ${remotes_git_svn}..mybranch && |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 78 | git pull . ${remotes_git_svn}' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 79 | |
| 80 | expect='/* $Id$ */' |
| 81 | got="`sed -ne 2p kw.c`" |
| 82 | test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'" |
| 83 | |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 84 | test_expect_success "propset CR on crlf files" \ |
| 85 | 'cd test_wc && |
| 86 | svn propset svn:eol-style CR empty && |
| 87 | svn propset svn:eol-style CR crlf && |
| 88 | svn propset svn:eol-style CR ne_crlf && |
Michael Spang | 7b3fab8 | 2007-02-12 19:33:37 -0500 | [diff] [blame] | 89 | svn commit -m "propset CR on crlf files" && |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 90 | cd ..' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 91 | |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 92 | test_expect_success 'fetch and pull latest from svn and checkout a new wc' \ |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 93 | 'git svn fetch && |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 94 | git pull . ${remotes_git_svn} && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 95 | svn co "$svnrepo" new_wc' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 96 | |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 97 | for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf |
| 98 | do |
| 99 | test_expect_success "Comparing $i" "cmp $i new_wc/$i" |
| 100 | done |
| 101 | |
| 102 | |
| 103 | cd test_wc |
| 104 | printf '$Id$\rHello\rWorld\r' > cr |
| 105 | printf '$Id$\rHello\rWorld' > ne_cr |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 106 | a_cr=`printf '$Id$\r\nHello\r\nWorld\r\n' | git hash-object --stdin` |
| 107 | a_ne_cr=`printf '$Id$\r\nHello\r\nWorld' | git hash-object --stdin` |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 108 | test_expect_success 'Set CRLF on cr files' \ |
| 109 | 'svn propset svn:eol-style CRLF cr && |
| 110 | svn propset svn:eol-style CRLF ne_cr && |
| 111 | svn propset svn:keywords Id cr && |
| 112 | svn propset svn:keywords Id ne_cr && |
Eric Wong | 4385355 | 2006-12-31 21:49:47 -0800 | [diff] [blame] | 113 | svn commit -m "propset CRLF on cr files"' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 114 | cd .. |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 115 | test_expect_success 'fetch and pull latest from svn' \ |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 116 | 'git svn fetch && git pull . ${remotes_git_svn}' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 117 | |
Nanako Shiraishi | da06a80 | 2008-09-10 06:25:28 +0900 | [diff] [blame] | 118 | b_cr="`git hash-object cr`" |
| 119 | b_ne_cr="`git hash-object ne_cr`" |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 120 | |
| 121 | test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'" |
| 122 | test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'" |
| 123 | |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 124 | cat > show-ignore.expect <<\EOF |
| 125 | |
| 126 | # / |
| 127 | /no-such-file* |
| 128 | |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 129 | # /deeply/ |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 130 | /deeply/no-such-file* |
| 131 | |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 132 | # /deeply/nested/ |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 133 | /deeply/nested/no-such-file* |
| 134 | |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 135 | # /deeply/nested/directory/ |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 136 | /deeply/nested/directory/no-such-file* |
| 137 | EOF |
| 138 | |
| 139 | test_expect_success 'test show-ignore' " |
| 140 | cd test_wc && |
| 141 | mkdir -p deeply/nested/directory && |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 142 | touch deeply/nested/directory/.keep && |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 143 | svn add deeply && |
Sam Vilain | d99c74e | 2007-09-21 14:02:34 +1200 | [diff] [blame] | 144 | svn up && |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 145 | svn propset -R svn:ignore 'no-such-file*' . |
| 146 | svn commit -m 'propset svn:ignore' |
| 147 | cd .. && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 148 | git svn show-ignore > show-ignore.got && |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 149 | cmp show-ignore.expect show-ignore.got |
| 150 | " |
| 151 | |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 152 | cat >create-ignore.expect <<\EOF |
| 153 | /no-such-file* |
| 154 | EOF |
| 155 | |
| 156 | cat >create-ignore-index.expect <<\EOF |
| 157 | 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 .gitignore |
| 158 | 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/.gitignore |
| 159 | 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/.gitignore |
| 160 | 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/directory/.gitignore |
| 161 | EOF |
| 162 | |
| 163 | test_expect_success 'test create-ignore' " |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 164 | git svn fetch && git pull . ${remotes_git_svn} && |
| 165 | git svn create-ignore && |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 166 | cmp ./.gitignore create-ignore.expect && |
| 167 | cmp ./deeply/.gitignore create-ignore.expect && |
| 168 | cmp ./deeply/nested/.gitignore create-ignore.expect && |
| 169 | cmp ./deeply/nested/directory/.gitignore create-ignore.expect && |
| 170 | git ls-files -s | grep gitignore | cmp - create-ignore-index.expect |
| 171 | " |
| 172 | |
Benoit Sigoure | 1515345 | 2007-10-16 16:36:50 +0200 | [diff] [blame] | 173 | cat >prop.expect <<\EOF |
| 174 | no-such-file* |
| 175 | |
| 176 | EOF |
| 177 | cat >prop2.expect <<\EOF |
| 178 | 8 |
| 179 | EOF |
| 180 | |
| 181 | # This test can be improved: since all the svn:ignore contain the same |
| 182 | # pattern, it can pass even though the propget did not execute on the |
| 183 | # right directory. |
| 184 | test_expect_success 'test propget' " |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 185 | git svn propget svn:ignore . | cmp - prop.expect && |
Benoit Sigoure | 1515345 | 2007-10-16 16:36:50 +0200 | [diff] [blame] | 186 | cd deeply && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 187 | git svn propget svn:ignore . | cmp - ../prop.expect && |
| 188 | git svn propget svn:entry:committed-rev nested/directory/.keep \ |
Benoit Sigoure | 1515345 | 2007-10-16 16:36:50 +0200 | [diff] [blame] | 189 | | cmp - ../prop2.expect && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 190 | git svn propget svn:ignore .. | cmp - ../prop.expect && |
| 191 | git svn propget svn:ignore nested/ | cmp - ../prop.expect && |
| 192 | git svn propget svn:ignore ./nested | cmp - ../prop.expect && |
| 193 | git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect |
Benoit Sigoure | 1515345 | 2007-10-16 16:36:50 +0200 | [diff] [blame] | 194 | " |
| 195 | |
Benoit Sigoure | 51e057c | 2007-10-16 16:36:51 +0200 | [diff] [blame] | 196 | cat >prop.expect <<\EOF |
| 197 | Properties on '.': |
| 198 | svn:entry:committed-date |
| 199 | svn:entry:committed-rev |
| 200 | svn:entry:last-author |
| 201 | svn:entry:uuid |
| 202 | svn:ignore |
| 203 | EOF |
| 204 | cat >prop2.expect <<\EOF |
| 205 | Properties on 'nested/directory/.keep': |
| 206 | svn:entry:committed-date |
| 207 | svn:entry:committed-rev |
| 208 | svn:entry:last-author |
| 209 | svn:entry:uuid |
| 210 | EOF |
| 211 | |
| 212 | test_expect_success 'test proplist' " |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 213 | git svn proplist . | cmp - prop.expect && |
| 214 | git svn proplist nested/directory/.keep | cmp - prop2.expect |
Benoit Sigoure | 51e057c | 2007-10-16 16:36:51 +0200 | [diff] [blame] | 215 | " |
| 216 | |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 217 | test_done |