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 |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [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 |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [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 |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [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 |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [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 |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [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 |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [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 |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [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 |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [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 |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [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 |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [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 | |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 51 | svn_cmd 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' |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 56 | test_expect_success 'setup some commits to svn' ' |
| 57 | ( |
| 58 | cd test_wc && |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 59 | echo Greetings >> kw.c && |
Michael Spang | 7b3fab8 | 2007-02-12 19:33:37 -0500 | [diff] [blame] | 60 | poke kw.c && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 61 | svn_cmd commit -m "Not yet an Id" && |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 62 | echo Hello world >> kw.c && |
Michael Spang | 7b3fab8 | 2007-02-12 19:33:37 -0500 | [diff] [blame] | 63 | poke kw.c && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 64 | svn_cmd commit -m "Modified file, but still not yet an Id" && |
| 65 | svn_cmd propset svn:keywords Id kw.c && |
Michael Spang | 7b3fab8 | 2007-02-12 19:33:37 -0500 | [diff] [blame] | 66 | poke kw.c && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 67 | svn_cmd commit -m "Propset Id" |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 68 | ) |
| 69 | ' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 70 | |
Nanako Shiraishi | f964732 | 2008-09-10 06:25:27 +0900 | [diff] [blame] | 71 | test_expect_success 'initialize git svn' 'git svn init "$svnrepo"' |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 72 | test_expect_success 'fetch revisions from svn' 'git svn fetch' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 73 | |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 74 | name='test svn:keywords ignoring' |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 75 | test_expect_success "$name" \ |
Jeff King | e1c0c15 | 2016-05-13 16:47:14 -0400 | [diff] [blame] | 76 | 'git checkout -b mybranch remotes/git-svn && |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 77 | echo Hi again >> kw.c && |
Pavel Roskin | 3dff537 | 2007-02-03 23:49:16 -0500 | [diff] [blame] | 78 | git commit -a -m "test keywords ignoring" && |
Jeff King | e1c0c15 | 2016-05-13 16:47:14 -0400 | [diff] [blame] | 79 | git svn set-tree remotes/git-svn..mybranch && |
| 80 | git pull . remotes/git-svn' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 81 | |
| 82 | expect='/* $Id$ */' |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [diff] [blame] | 83 | got="$(sed -ne 2p kw.c)" |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 84 | test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'" |
| 85 | |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 86 | test_expect_success "propset CR on crlf files" ' |
| 87 | ( |
| 88 | cd test_wc && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 89 | svn_cmd propset svn:eol-style CR empty && |
| 90 | svn_cmd propset svn:eol-style CR crlf && |
| 91 | svn_cmd propset svn:eol-style CR ne_crlf && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 92 | svn_cmd commit -m "propset CR on crlf files" |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 93 | ) |
| 94 | ' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 95 | |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 96 | 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] | 97 | 'git svn fetch && |
Jeff King | e1c0c15 | 2016-05-13 16:47:14 -0400 | [diff] [blame] | 98 | git pull . remotes/git-svn && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 99 | svn_cmd co "$svnrepo" new_wc' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 100 | |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 101 | for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf |
| 102 | do |
| 103 | test_expect_success "Comparing $i" "cmp $i new_wc/$i" |
| 104 | done |
| 105 | |
| 106 | |
| 107 | cd test_wc |
| 108 | printf '$Id$\rHello\rWorld\r' > cr |
| 109 | printf '$Id$\rHello\rWorld' > ne_cr |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [diff] [blame] | 110 | a_cr=$(printf '$Id$\r\nHello\r\nWorld\r\n' | git hash-object --stdin) |
| 111 | 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] | 112 | test_expect_success 'Set CRLF on cr files' \ |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 113 | 'svn_cmd propset svn:eol-style CRLF cr && |
| 114 | svn_cmd propset svn:eol-style CRLF ne_cr && |
| 115 | svn_cmd propset svn:keywords Id cr && |
| 116 | svn_cmd propset svn:keywords Id ne_cr && |
| 117 | svn_cmd commit -m "propset CRLF on cr files"' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 118 | cd .. |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 119 | test_expect_success 'fetch and pull latest from svn' \ |
Jeff King | e1c0c15 | 2016-05-13 16:47:14 -0400 | [diff] [blame] | 120 | 'git svn fetch && git pull . remotes/git-svn' |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 121 | |
Elia Pinto | e10de5a | 2016-01-12 10:45:10 +0000 | [diff] [blame] | 122 | b_cr="$(git hash-object cr)" |
| 123 | b_ne_cr="$(git hash-object ne_cr)" |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 124 | |
| 125 | test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'" |
| 126 | test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'" |
| 127 | |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 128 | cat > show-ignore.expect <<\EOF |
| 129 | |
| 130 | # / |
| 131 | /no-such-file* |
| 132 | |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 133 | # /deeply/ |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 134 | /deeply/no-such-file* |
| 135 | |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 136 | # /deeply/nested/ |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 137 | /deeply/nested/no-such-file* |
| 138 | |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 139 | # /deeply/nested/directory/ |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 140 | /deeply/nested/directory/no-such-file* |
| 141 | EOF |
| 142 | |
| 143 | test_expect_success 'test show-ignore' " |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 144 | ( |
| 145 | cd test_wc && |
| 146 | mkdir -p deeply/nested/directory && |
| 147 | touch deeply/nested/directory/.keep && |
| 148 | svn_cmd add deeply && |
| 149 | svn_cmd up && |
| 150 | svn_cmd propset -R svn:ignore ' |
Michael Haggerty | a7d7254 | 2009-08-07 21:21:21 +0200 | [diff] [blame] | 151 | no-such-file* |
Eric Sunshine | cff4243 | 2018-07-01 20:24:04 -0400 | [diff] [blame] | 152 | ' . && |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 153 | svn_cmd commit -m 'propset svn:ignore' |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 154 | ) && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 155 | git svn show-ignore > show-ignore.got && |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 156 | cmp show-ignore.expect show-ignore.got |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 157 | " |
Eric Wong | ad2f908 | 2007-01-11 17:55:50 -0800 | [diff] [blame] | 158 | |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 159 | cat >create-ignore.expect <<\EOF |
| 160 | /no-such-file* |
| 161 | EOF |
| 162 | |
brian m. carlson | 3e04b6e | 2020-06-19 22:39:39 +0000 | [diff] [blame] | 163 | expectoid=$(git hash-object create-ignore.expect) |
| 164 | |
| 165 | cat >create-ignore-index.expect <<EOF |
| 166 | 100644 $expectoid 0 .gitignore |
| 167 | 100644 $expectoid 0 deeply/.gitignore |
| 168 | 100644 $expectoid 0 deeply/nested/.gitignore |
| 169 | 100644 $expectoid 0 deeply/nested/directory/.gitignore |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 170 | EOF |
| 171 | |
| 172 | test_expect_success 'test create-ignore' " |
Jeff King | e1c0c15 | 2016-05-13 16:47:14 -0400 | [diff] [blame] | 173 | git svn fetch && git pull . remotes/git-svn && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 174 | git svn create-ignore && |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 175 | cmp ./.gitignore create-ignore.expect && |
| 176 | cmp ./deeply/.gitignore create-ignore.expect && |
| 177 | cmp ./deeply/nested/.gitignore create-ignore.expect && |
| 178 | cmp ./deeply/nested/directory/.gitignore create-ignore.expect && |
Matthew DeVore | b00b6ac | 2018-10-05 14:54:06 -0700 | [diff] [blame] | 179 | git ls-files -s >ls_files_result && |
| 180 | grep gitignore ls_files_result | cmp - create-ignore-index.expect |
Benoit Sigoure | d05ddec | 2007-10-16 16:36:49 +0200 | [diff] [blame] | 181 | " |
| 182 | |
Benoit Sigoure | 1515345 | 2007-10-16 16:36:50 +0200 | [diff] [blame] | 183 | cat >prop.expect <<\EOF |
Michael Haggerty | a7d7254 | 2009-08-07 21:21:21 +0200 | [diff] [blame] | 184 | |
Benoit Sigoure | 1515345 | 2007-10-16 16:36:50 +0200 | [diff] [blame] | 185 | no-such-file* |
| 186 | |
| 187 | EOF |
| 188 | cat >prop2.expect <<\EOF |
| 189 | 8 |
| 190 | EOF |
| 191 | |
| 192 | # This test can be improved: since all the svn:ignore contain the same |
| 193 | # pattern, it can pass even though the propget did not execute on the |
| 194 | # right directory. |
Matthew DeVore | b00b6ac | 2018-10-05 14:54:06 -0700 | [diff] [blame] | 195 | test_expect_success 'test propget' ' |
| 196 | test_propget () { |
| 197 | git svn propget $1 $2 >actual && |
| 198 | cmp $3 actual |
| 199 | } && |
| 200 | test_propget svn:ignore . prop.expect && |
Benoit Sigoure | 1515345 | 2007-10-16 16:36:50 +0200 | [diff] [blame] | 201 | cd deeply && |
Matthew DeVore | b00b6ac | 2018-10-05 14:54:06 -0700 | [diff] [blame] | 202 | test_propget svn:ignore . ../prop.expect && |
| 203 | test_propget svn:entry:committed-rev nested/directory/.keep \ |
| 204 | ../prop2.expect && |
| 205 | test_propget svn:ignore .. ../prop.expect && |
| 206 | test_propget svn:ignore nested/ ../prop.expect && |
| 207 | test_propget svn:ignore ./nested ../prop.expect && |
| 208 | test_propget svn:ignore .././deeply/nested ../prop.expect |
| 209 | ' |
Benoit Sigoure | 1515345 | 2007-10-16 16:36:50 +0200 | [diff] [blame] | 210 | |
Benoit Sigoure | 51e057c | 2007-10-16 16:36:51 +0200 | [diff] [blame] | 211 | cat >prop.expect <<\EOF |
| 212 | Properties on '.': |
| 213 | svn:entry:committed-date |
| 214 | svn:entry:committed-rev |
| 215 | svn:entry:last-author |
| 216 | svn:entry:uuid |
| 217 | svn:ignore |
| 218 | EOF |
| 219 | cat >prop2.expect <<\EOF |
| 220 | Properties on 'nested/directory/.keep': |
| 221 | svn:entry:committed-date |
| 222 | svn:entry:committed-rev |
| 223 | svn:entry:last-author |
| 224 | svn:entry:uuid |
| 225 | EOF |
| 226 | |
| 227 | test_expect_success 'test proplist' " |
Matthew DeVore | b00b6ac | 2018-10-05 14:54:06 -0700 | [diff] [blame] | 228 | git svn proplist . >actual && |
| 229 | cmp prop.expect actual && |
| 230 | |
| 231 | git svn proplist nested/directory/.keep >actual && |
| 232 | cmp prop2.expect actual |
Benoit Sigoure | 51e057c | 2007-10-16 16:36:51 +0200 | [diff] [blame] | 233 | " |
| 234 | |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 235 | test_done |