t / t9803-git-p4-shell-metachars.shon commit Merge branch 'jc/detached-head-doc' (cd797c7)
   1#!/bin/sh
   2
   3test_description='git p4 transparency to shell metachars in filenames'
   4
   5. ./lib-git-p4.sh
   6
   7test_expect_success 'start p4d' '
   8        start_p4d
   9'
  10
  11test_expect_success 'init depot' '
  12        (
  13                cd "$cli" &&
  14                echo file1 >file1 &&
  15                p4 add file1 &&
  16                p4 submit -d "file1"
  17        )
  18'
  19
  20test_expect_success 'shell metachars in filenames' '
  21        git p4 clone --dest="$git" //depot &&
  22        test_when_finished cleanup_git &&
  23        (
  24                cd "$git" &&
  25                git config git-p4.skipSubmitEditCheck true &&
  26                echo f1 >foo\$bar &&
  27                git add foo\$bar &&
  28                echo f2 >"file with spaces" &&
  29                git add "file with spaces" &&
  30                git commit -m "add files" &&
  31                P4EDITOR=touch git p4 submit
  32        ) &&
  33        (
  34                cd "$cli" &&
  35                p4 sync ... &&
  36                test -e "file with spaces" &&
  37                test -e "foo\$bar"
  38        )
  39'
  40
  41test_expect_success 'deleting with shell metachars' '
  42        git p4 clone --dest="$git" //depot &&
  43        test_when_finished cleanup_git &&
  44        (
  45                cd "$git" &&
  46                git config git-p4.skipSubmitEditCheck true &&
  47                git rm foo\$bar &&
  48                git rm file\ with\ spaces &&
  49                git commit -m "remove files" &&
  50                P4EDITOR=touch git p4 submit
  51        ) &&
  52        (
  53                cd "$cli" &&
  54                p4 sync ... &&
  55                test ! -e "file with spaces" &&
  56                test ! -e foo\$bar
  57        )
  58'
  59
  60# Create a branch with a shell metachar in its name
  61#
  62# 1. //depot/main
  63# 2. //depot/branch$3
  64
  65test_expect_success 'branch with shell char' '
  66        test_when_finished cleanup_git &&
  67        test_create_repo "$git" &&
  68        (
  69                cd "$cli" &&
  70
  71                mkdir -p main &&
  72
  73                echo f1 >main/f1 &&
  74                p4 add main/f1 &&
  75                p4 submit -d "main/f1" &&
  76
  77                p4 integrate //depot/main/... //depot/branch\$3/... &&
  78                p4 submit -d "integrate main to branch\$3" &&
  79
  80                echo f1 >branch\$3/shell_char_branch_file &&
  81                p4 add branch\$3/shell_char_branch_file &&
  82                p4 submit -d "branch\$3/shell_char_branch_file" &&
  83
  84                p4 branch -i <<-EOF &&
  85                Branch: branch\$3
  86                View: //depot/main/... //depot/branch\$3/...
  87                EOF
  88
  89                p4 edit main/f1 &&
  90                echo "a change" >> main/f1 &&
  91                p4 submit -d "a change" main/f1 &&
  92
  93                p4 integrate -b branch\$3 &&
  94                p4 resolve -am branch\$3/... &&
  95                p4 submit -d "integrate main to branch\$3" &&
  96
  97                cd "$git" &&
  98
  99                git config git-p4.branchList main:branch\$3 &&
 100                git p4 clone --dest=. --detect-branches //depot@all &&
 101                git log --all --graph --decorate --stat &&
 102                git reset --hard p4/depot/branch\$3 &&
 103                test -f shell_char_branch_file &&
 104                test -f f1
 105        )
 106'
 107
 108test_expect_success 'kill p4d' '
 109        kill_p4d
 110'
 111
 112test_done