t / t9812-git-p4-wildcards.shon commit Merge branch 'rs/merge-tree-simplify' (7669461)
   1#!/bin/sh
   2
   3test_description='git p4 wildcards'
   4
   5. ./lib-git-p4.sh
   6
   7test_expect_success 'start p4d' '
   8        start_p4d
   9'
  10
  11test_expect_success 'add p4 files with wildcards in the names' '
  12        (
  13                cd "$cli" &&
  14                printf "file2\nhas\nsome\nrandom\ntext\n" >file2 &&
  15                p4 add file2 &&
  16                echo file-wild-hash >file-wild#hash &&
  17                if test_have_prereq !MINGW,!CYGWIN
  18                then
  19                        echo file-wild-star >file-wild\*star
  20                fi &&
  21                echo file-wild-at >file-wild@at &&
  22                echo file-wild-percent >file-wild%percent &&
  23                p4 add -f file-wild* &&
  24                p4 submit -d "file wildcards"
  25        )
  26'
  27
  28test_expect_success 'wildcard files git p4 clone' '
  29        git p4 clone --dest="$git" //depot &&
  30        test_when_finished cleanup_git &&
  31        (
  32                cd "$git" &&
  33                test -f file-wild#hash &&
  34                if test_have_prereq !MINGW,!CYGWIN
  35                then
  36                        test -f file-wild\*star
  37                fi &&
  38                test -f file-wild@at &&
  39                test -f file-wild%percent
  40        )
  41'
  42
  43test_expect_success 'wildcard files submit back to p4, add' '
  44        test_when_finished cleanup_git &&
  45        git p4 clone --dest="$git" //depot &&
  46        (
  47                cd "$git" &&
  48                echo git-wild-hash >git-wild#hash &&
  49                if test_have_prereq !MINGW,!CYGWIN
  50                then
  51                        echo git-wild-star >git-wild\*star
  52                fi &&
  53                echo git-wild-at >git-wild@at &&
  54                echo git-wild-percent >git-wild%percent &&
  55                git add git-wild* &&
  56                git commit -m "add some wildcard filenames" &&
  57                git config git-p4.skipSubmitEdit true &&
  58                git p4 submit
  59        ) &&
  60        (
  61                cd "$cli" &&
  62                test_path_is_file git-wild#hash &&
  63                if test_have_prereq !MINGW,!CYGWIN
  64                then
  65                        test_path_is_file git-wild\*star
  66                fi &&
  67                test_path_is_file git-wild@at &&
  68                test_path_is_file git-wild%percent
  69        )
  70'
  71
  72test_expect_success 'wildcard files submit back to p4, modify' '
  73        test_when_finished cleanup_git &&
  74        git p4 clone --dest="$git" //depot &&
  75        (
  76                cd "$git" &&
  77                echo new-line >>git-wild#hash &&
  78                if test_have_prereq !MINGW,!CYGWIN
  79                then
  80                        echo new-line >>git-wild\*star
  81                fi &&
  82                echo new-line >>git-wild@at &&
  83                echo new-line >>git-wild%percent &&
  84                git add git-wild* &&
  85                git commit -m "modify the wildcard files" &&
  86                git config git-p4.skipSubmitEdit true &&
  87                git p4 submit
  88        ) &&
  89        (
  90                cd "$cli" &&
  91                test_line_count = 2 git-wild#hash &&
  92                if test_have_prereq !MINGW,!CYGWIN
  93                then
  94                        test_line_count = 2 git-wild\*star
  95                fi &&
  96                test_line_count = 2 git-wild@at &&
  97                test_line_count = 2 git-wild%percent
  98        )
  99'
 100
 101test_expect_success 'wildcard files submit back to p4, copy' '
 102        test_when_finished cleanup_git &&
 103        git p4 clone --dest="$git" //depot &&
 104        (
 105                cd "$git" &&
 106                cp file2 git-wild-cp#hash &&
 107                git add git-wild-cp#hash &&
 108                cp git-wild#hash file-wild-3 &&
 109                git add file-wild-3 &&
 110                git commit -m "wildcard copies" &&
 111                git config git-p4.detectCopies true &&
 112                git config git-p4.detectCopiesHarder true &&
 113                git config git-p4.skipSubmitEdit true &&
 114                git p4 submit
 115        ) &&
 116        (
 117                cd "$cli" &&
 118                test_path_is_file git-wild-cp#hash &&
 119                test_path_is_file file-wild-3
 120        )
 121'
 122
 123test_expect_success 'wildcard files submit back to p4, rename' '
 124        test_when_finished cleanup_git &&
 125        git p4 clone --dest="$git" //depot &&
 126        (
 127                cd "$git" &&
 128                git mv git-wild@at file-wild-4 &&
 129                git mv file-wild-3 git-wild-cp%percent &&
 130                git commit -m "wildcard renames" &&
 131                git config git-p4.detectRenames true &&
 132                git config git-p4.skipSubmitEdit true &&
 133                git p4 submit
 134        ) &&
 135        (
 136                cd "$cli" &&
 137                test_path_is_missing git-wild@at &&
 138                test_path_is_file git-wild-cp%percent
 139        )
 140'
 141
 142test_expect_success 'wildcard files submit back to p4, delete' '
 143        test_when_finished cleanup_git &&
 144        git p4 clone --dest="$git" //depot &&
 145        (
 146                cd "$git" &&
 147                git rm git-wild* &&
 148                git commit -m "delete the wildcard files" &&
 149                git config git-p4.skipSubmitEdit true &&
 150                git p4 submit
 151        ) &&
 152        (
 153                cd "$cli" &&
 154                test_path_is_missing git-wild#hash &&
 155                if test_have_prereq !MINGW,!CYGWIN
 156                then
 157                        test_path_is_missing git-wild\*star
 158                fi &&
 159                test_path_is_missing git-wild@at &&
 160                test_path_is_missing git-wild%percent
 161        )
 162'
 163
 164test_expect_success 'p4 deleted a wildcard file' '
 165        (
 166                cd "$cli" &&
 167                echo "wild delete test" >wild@delete &&
 168                p4 add -f wild@delete &&
 169                p4 submit -d "add wild@delete"
 170        ) &&
 171        test_when_finished cleanup_git &&
 172        git p4 clone --dest="$git" //depot &&
 173        (
 174                cd "$git" &&
 175                test_path_is_file wild@delete
 176        ) &&
 177        (
 178                cd "$cli" &&
 179                # must use its encoded name
 180                p4 delete wild%40delete &&
 181                p4 submit -d "delete wild@delete"
 182        ) &&
 183        (
 184                cd "$git" &&
 185                git p4 sync &&
 186                git merge --ff-only p4/master &&
 187                test_path_is_missing wild@delete
 188        )
 189'
 190
 191test_expect_success 'wildcard files requiring keyword scrub' '
 192        (
 193                cd "$cli" &&
 194                cat <<-\EOF >scrub@wild &&
 195                $Id$
 196                line2
 197                EOF
 198                p4 add -t text+k -f scrub@wild &&
 199                p4 submit -d "scrub at wild"
 200        ) &&
 201        test_when_finished cleanup_git &&
 202        git p4 clone --dest="$git" //depot &&
 203        (
 204                cd "$git" &&
 205                git config git-p4.skipSubmitEdit true &&
 206                git config git-p4.attemptRCSCleanup true &&
 207                sed "s/^line2/line2 edit/" <scrub@wild >scrub@wild.tmp &&
 208                mv -f scrub@wild.tmp scrub@wild &&
 209                git commit -m "scrub at wild line2 edit" scrub@wild &&
 210                git p4 submit
 211        )
 212'
 213
 214test_expect_success 'kill p4d' '
 215        kill_p4d
 216'
 217
 218test_done