]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9808-git-p4-chdir.sh
The sixth batch
[thirdparty/git.git] / t / t9808-git-p4-chdir.sh
CommitLineData
57526fde
PW
1#!/bin/sh
2
6ab1d76c 3test_description='git p4 relative chdir'
57526fde
PW
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 "change 1"
17 )
18'
19
20# P4 reads from P4CONFIG file to find its server params, if the
21# environment variable is set
22test_expect_success 'P4CONFIG and absolute dir clone' '
23 printf "P4PORT=$P4PORT\nP4CLIENT=$P4CLIENT\n" >p4config &&
08c5eb7a 24 test_when_finished "rm p4config" &&
57526fde
PW
25 test_when_finished cleanup_git &&
26 (
27 P4CONFIG=p4config && export P4CONFIG &&
1f5ad6b1 28 sane_unset P4PORT P4CLIENT &&
6ab1d76c 29 git p4 clone --verbose --dest="$git" //depot
57526fde
PW
30 )
31'
32
33# same thing, but with relative directory name, note missing $ on --dest
34test_expect_success 'P4CONFIG and relative dir clone' '
35 printf "P4PORT=$P4PORT\nP4CLIENT=$P4CLIENT\n" >p4config &&
08c5eb7a 36 test_when_finished "rm p4config" &&
57526fde
PW
37 test_when_finished cleanup_git &&
38 (
39 P4CONFIG=p4config && export P4CONFIG &&
1f5ad6b1 40 sane_unset P4PORT P4CLIENT &&
6ab1d76c 41 git p4 clone --verbose --dest="git" //depot
57526fde
PW
42 )
43'
44
9e7b8efb
PW
45# Common setup using .p4config to set P4CLIENT and P4PORT breaks
46# if clone destination is relative. Make sure that chdir() expands
47# the relative path in --dest to absolute.
48test_expect_success 'p4 client root would be relative due to clone --dest' '
49 test_when_finished cleanup_git &&
50 (
51 echo P4PORT=$P4PORT >git/.p4config &&
52 P4CONFIG=.p4config &&
53 export P4CONFIG &&
54 unset P4PORT &&
55 git p4 clone --dest="git" //depot
56 )
57'
58
89773db3
PW
59# When the p4 client Root is a symlink, make sure chdir() does not use
60# getcwd() to convert it to a physical path.
bbd84863 61test_expect_success SYMLINKS 'p4 client root symlink should stay symbolic' '
89773db3
PW
62 physical="$TRASH_DIRECTORY/physical" &&
63 symbolic="$TRASH_DIRECTORY/symbolic" &&
64 test_when_finished "rm -rf \"$physical\"" &&
65 test_when_finished "rm \"$symbolic\"" &&
66 mkdir -p "$physical" &&
67 ln -s "$physical" "$symbolic" &&
68 test_when_finished cleanup_git &&
69 (
70 P4CLIENT=client-sym &&
71 p4 client -i <<-EOF &&
72 Client: $P4CLIENT
73 Description: $P4CLIENT
74 Root: $symbolic
75 LineEnd: unix
76 View: //depot/... //$P4CLIENT/...
77 EOF
78 git p4 clone --dest="$git" //depot &&
79 cd "$git" &&
80 test_commit file2 &&
81 git config git-p4.skipSubmitEdit true &&
82 git p4 submit
83 )
84'
85
57526fde 86test_done