From 43b82bd9c3a5ad597bbfc0c12a519d4053df01b8 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Wed, 11 Jan 2012 18:31:06 -0500 Subject: git-p4: only a single ... wildcard is supported Catch the case where a ... exists at the end, and also elsehwere. Reported-by: Gary Gibbons Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index c9471d562d..54204af8fb 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -101,12 +101,18 @@ test_expect_success 'unsupported view wildcard *' ' test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot ' -test_expect_success 'wildcard ... only supported at end of spec' ' +test_expect_success 'wildcard ... only supported at end of spec 1' ' client_view "//depot/.../file11 //client/.../file11" && test_when_finished cleanup_git && test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot ' +test_expect_success 'wildcard ... only supported at end of spec 2' ' + client_view "//depot/.../a/... //client/.../a/..." && + test_when_finished cleanup_git && + test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot +' + test_expect_success 'basic map' ' client_view "//depot/dir1/... //client/cli1/..." && files="cli1/file11 cli1/file12" && -- cgit v1.2.1 From 42d8c2799062bafc538d511a0262f76e23c99421 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Wed, 11 Jan 2012 18:31:10 -0500 Subject: git-p4: add tests demonstrating spec overlay ambiguities Introduce new tests that look more closely at overlay situations when there are conflicting files. Five of these are broken. Document the brokenness. This is a fundamental problem with how git-p4 only "borrows" a client spec. At some sync operation, a new change can contain a file which is already in the repo or explicitly deleted through another mapping. To sort this out would involve listing all the files in the client spec to find one with a higher priority. While this is not too hard for the initial import, subsequent sync operations would be very costly. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 387 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 387 insertions(+) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 54204af8fb..ae9145e307 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -246,6 +246,393 @@ test_expect_success 'quotes on rhs only' ' git_verify "cdir 1/file11" "cdir 1/file12" ' +# +# What happens when two files of the same name are overlayed together? +# The last-listed file should take preference. +# +# //depot +# - dir1 +# - file11 +# - file12 +# - filecollide +# - dir2 +# - file21 +# - file22 +# - filecollide +# +test_expect_success 'overlay collision setup' ' + client_view "//depot/... //client/..." && + ( + cd "$cli" && + p4 sync && + echo dir1/filecollide >dir1/filecollide && + p4 add dir1/filecollide && + p4 submit -d dir1/filecollide && + echo dir2/filecollide >dir2/filecollide && + p4 add dir2/filecollide && + p4 submit -d dir2/filecollide + ) +' + +test_expect_success 'overlay collision 1 to 2' ' + client_view "//depot/dir1/... //client/..." \ + "+//depot/dir2/... //client/..." && + files="file11 file12 file21 file22 filecollide" && + echo dir2/filecollide >actual && + client_verify $files && + test_cmp actual "$cli"/filecollide && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot && + git_verify $files && + test_cmp actual "$git"/filecollide +' + +test_expect_failure 'overlay collision 2 to 1' ' + client_view "//depot/dir2/... //client/..." \ + "+//depot/dir1/... //client/..." && + files="file11 file12 file21 file22 filecollide" && + echo dir1/filecollide >actual && + client_verify $files && + test_cmp actual "$cli"/filecollide && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot && + git_verify $files && + test_cmp actual "$git"/filecollide +' + +test_expect_success 'overlay collision delete 2' ' + client_view "//depot/... //client/..." && + ( + cd "$cli" && + p4 sync && + p4 delete dir2/filecollide && + p4 submit -d "remove dir2/filecollide" + ) +' + +# no filecollide, got deleted with dir2 +test_expect_failure 'overlay collision 1 to 2, but 2 deleted' ' + client_view "//depot/dir1/... //client/..." \ + "+//depot/dir2/... //client/..." && + files="file11 file12 file21 file22" && + client_verify $files && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot && + git_verify $files +' + +test_expect_success 'overlay collision update 1' ' + client_view "//depot/dir1/... //client/dir1/..." && + ( + cd "$cli" && + p4 sync && + p4 open dir1/filecollide && + echo dir1/filecollide update >dir1/filecollide && + p4 submit -d "update dir1/filecollide" + ) +' + +# still no filecollide, dir2 still wins with the deletion even though the +# change to dir1 is more recent +test_expect_failure 'overlay collision 1 to 2, but 2 deleted, then 1 updated' ' + client_view "//depot/dir1/... //client/..." \ + "+//depot/dir2/... //client/..." && + files="file11 file12 file21 file22" && + client_verify $files && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot && + git_verify $files +' + +test_expect_success 'overlay collision delete filecollides' ' + client_view "//depot/... //client/..." && + ( + cd "$cli" && + p4 sync && + p4 delete dir1/filecollide dir2/filecollide && + p4 submit -d "remove filecollides" + ) +' + +# +# Overlays as part of sync, rather than initial checkout: +# 1. add a file in dir1 +# 2. sync to include it +# 3. add same file in dir2 +# 4. sync, make sure content switches as dir2 has priority +# 5. add another file in dir1 +# 6. sync +# 7. add/delete same file in dir2 +# 8. sync, make sure it disappears, again dir2 wins +# 9. cleanup +# +# //depot +# - dir1 +# - file11 +# - file12 +# - colA +# - colB +# - dir2 +# - file21 +# - file22 +# - colA +# - colB +# +test_expect_success 'overlay sync: add colA in dir1' ' + client_view "//depot/dir1/... //client/dir1/..." && + ( + cd "$cli" && + p4 sync && + echo dir1/colA >dir1/colA && + p4 add dir1/colA && + p4 submit -d dir1/colA + ) +' + +test_expect_success 'overlay sync: initial git checkout' ' + client_view "//depot/dir1/... //client/..." \ + "+//depot/dir2/... //client/..." && + files="file11 file12 file21 file22 colA" && + echo dir1/colA >actual && + client_verify $files && + test_cmp actual "$cli"/colA && + "$GITP4" clone --use-client-spec --dest="$git" //depot && + git_verify $files && + test_cmp actual "$git"/colA +' + +test_expect_success 'overlay sync: add colA in dir2' ' + client_view "//depot/dir2/... //client/dir2/..." && + ( + cd "$cli" && + p4 sync && + echo dir2/colA >dir2/colA && + p4 add dir2/colA && + p4 submit -d dir2/colA + ) +' + +test_expect_success 'overlay sync: colA content switch' ' + client_view "//depot/dir1/... //client/..." \ + "+//depot/dir2/... //client/..." && + files="file11 file12 file21 file22 colA" && + echo dir2/colA >actual && + client_verify $files && + test_cmp actual "$cli"/colA && + ( + cd "$git" && + "$GITP4" sync --use-client-spec && + git merge --ff-only p4/master + ) && + git_verify $files && + test_cmp actual "$git"/colA +' + +test_expect_success 'overlay sync: add colB in dir1' ' + client_view "//depot/dir1/... //client/dir1/..." && + ( + cd "$cli" && + p4 sync && + echo dir1/colB >dir1/colB && + p4 add dir1/colB && + p4 submit -d dir1/colB + ) +' + +test_expect_success 'overlay sync: colB appears' ' + client_view "//depot/dir1/... //client/..." \ + "+//depot/dir2/... //client/..." && + files="file11 file12 file21 file22 colA colB" && + echo dir1/colB >actual && + client_verify $files && + test_cmp actual "$cli"/colB && + ( + cd "$git" && + "$GITP4" sync --use-client-spec && + git merge --ff-only p4/master + ) && + git_verify $files && + test_cmp actual "$git"/colB +' + +test_expect_success 'overlay sync: add/delete colB in dir2' ' + client_view "//depot/dir2/... //client/dir2/..." && + ( + cd "$cli" && + p4 sync && + echo dir2/colB >dir2/colB && + p4 add dir2/colB && + p4 submit -d dir2/colB && + p4 delete dir2/colB && + p4 submit -d "delete dir2/colB" + ) +' + +test_expect_success 'overlay sync: colB disappears' ' + client_view "//depot/dir1/... //client/..." \ + "+//depot/dir2/... //client/..." && + files="file11 file12 file21 file22 colA" && + client_verify $files && + test_when_finished cleanup_git && + ( + cd "$git" && + "$GITP4" sync --use-client-spec && + git merge --ff-only p4/master + ) && + git_verify $files +' + +test_expect_success 'overlay sync: cleanup' ' + client_view "//depot/... //client/..." && + ( + cd "$cli" && + p4 sync && + p4 delete dir1/colA dir2/colA dir1/colB && + p4 submit -d "remove overlay sync files" + ) +' + +# +# Overlay tests again, but swapped so dir1 has priority. +# 1. add a file in dir1 +# 2. sync to include it +# 3. add same file in dir2 +# 4. sync, make sure content does not switch +# 5. add another file in dir1 +# 6. sync +# 7. add/delete same file in dir2 +# 8. sync, make sure it is still there +# 9. cleanup +# +# //depot +# - dir1 +# - file11 +# - file12 +# - colA +# - colB +# - dir2 +# - file21 +# - file22 +# - colA +# - colB +# +test_expect_success 'overlay sync swap: add colA in dir1' ' + client_view "//depot/dir1/... //client/dir1/..." && + ( + cd "$cli" && + p4 sync && + echo dir1/colA >dir1/colA && + p4 add dir1/colA && + p4 submit -d dir1/colA + ) +' + +test_expect_success 'overlay sync swap: initial git checkout' ' + client_view "//depot/dir2/... //client/..." \ + "+//depot/dir1/... //client/..." && + files="file11 file12 file21 file22 colA" && + echo dir1/colA >actual && + client_verify $files && + test_cmp actual "$cli"/colA && + "$GITP4" clone --use-client-spec --dest="$git" //depot && + git_verify $files && + test_cmp actual "$git"/colA +' + +test_expect_success 'overlay sync swap: add colA in dir2' ' + client_view "//depot/dir2/... //client/dir2/..." && + ( + cd "$cli" && + p4 sync && + echo dir2/colA >dir2/colA && + p4 add dir2/colA && + p4 submit -d dir2/colA + ) +' + +test_expect_failure 'overlay sync swap: colA no content switch' ' + client_view "//depot/dir2/... //client/..." \ + "+//depot/dir1/... //client/..." && + files="file11 file12 file21 file22 colA" && + echo dir1/colA >actual && + client_verify $files && + test_cmp actual "$cli"/colA && + ( + cd "$git" && + "$GITP4" sync --use-client-spec && + git merge --ff-only p4/master + ) && + git_verify $files && + test_cmp actual "$git"/colA +' + +test_expect_success 'overlay sync swap: add colB in dir1' ' + client_view "//depot/dir1/... //client/dir1/..." && + ( + cd "$cli" && + p4 sync && + echo dir1/colB >dir1/colB && + p4 add dir1/colB && + p4 submit -d dir1/colB + ) +' + +test_expect_success 'overlay sync swap: colB appears' ' + client_view "//depot/dir2/... //client/..." \ + "+//depot/dir1/... //client/..." && + files="file11 file12 file21 file22 colA colB" && + echo dir1/colB >actual && + client_verify $files && + test_cmp actual "$cli"/colB && + ( + cd "$git" && + "$GITP4" sync --use-client-spec && + git merge --ff-only p4/master + ) && + git_verify $files && + test_cmp actual "$git"/colB +' + +test_expect_success 'overlay sync swap: add/delete colB in dir2' ' + client_view "//depot/dir2/... //client/dir2/..." && + ( + cd "$cli" && + p4 sync && + echo dir2/colB >dir2/colB && + p4 add dir2/colB && + p4 submit -d dir2/colB && + p4 delete dir2/colB && + p4 submit -d "delete dir2/colB" + ) +' + +test_expect_failure 'overlay sync swap: colB no change' ' + client_view "//depot/dir2/... //client/..." \ + "+//depot/dir1/... //client/..." && + files="file11 file12 file21 file22 colA colB" && + echo dir1/colB >actual && + client_verify $files && + test_cmp actual "$cli"/colB && + test_when_finished cleanup_git && + ( + cd "$git" && + "$GITP4" sync --use-client-spec && + git merge --ff-only p4/master + ) && + git_verify $files && + test_cmp actual "$cli"/colB +' + +test_expect_success 'overlay sync swap: cleanup' ' + client_view "//depot/... //client/..." && + ( + cd "$cli" && + p4 sync && + p4 delete dir1/colA dir2/colA dir1/colB && + p4 submit -d "remove overlay sync files" + ) +' + # # Rename directories to test quoting in depot-side mappings # //depot -- cgit v1.2.1 From a93d33ee7bf2f1cd41f94470e9e44e0fc9307046 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 25 Feb 2012 20:06:24 -0500 Subject: git-p4: set useClientSpec variable on initial clone If --use-client-spec was given, set the matching configuration variable. This is necessary to ensure that future submits work properly. The alternatives of requiring the user to set it, or providing a command-line option on every submit, are error prone. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index c9471d562d..25e01a469d 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -240,6 +240,23 @@ test_expect_success 'quotes on rhs only' ' git_verify "cdir 1/file11" "cdir 1/file12" ' +# +# Submit tests +# + +# clone sets variable +test_expect_success 'clone --use-client-spec sets useClientSpec' ' + client_view "//depot/... //client/..." && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot && + ( + cd "$git" && + git config --bool git-p4.useClientSpec >actual && + echo true >true && + test_cmp actual true + ) +' + # # Rename directories to test quoting in depot-side mappings # //depot -- cgit v1.2.1 From 543987bd475abae502939eb3db9c6879fde09c88 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 25 Feb 2012 20:06:25 -0500 Subject: git-p4: fix submit regression with clientSpec and subdir clone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the --use-client-spec is given to clone, and the clone path is a subset of the full tree as specified in the client, future submits will go to the wrong place. Factor out getClientSpec() so both clone/sync and submit can use it. Introduce getClientRoot() that is needed for the client spec case, and use it instead of p4Where(). Test the five possible submit behaviors (add, modify, rename, copy, delete). Reported-by: Laurent Charrière Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 142 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 131 insertions(+), 11 deletions(-) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 25e01a469d..96426414aa 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -71,20 +71,24 @@ git_verify() { # - dir2 # - file21 # - file22 +init_depot() { + for d in 1 2 ; do + mkdir -p dir$d && + for f in 1 2 ; do + echo dir$d/file$d$f >dir$d/file$d$f && + p4 add dir$d/file$d$f && + p4 submit -d "dir$d/file$d$f" + done + done && + find . -type f ! -name files >files && + check_files_exist dir1/file11 dir1/file12 \ + dir2/file21 dir2/file22 +} + test_expect_success 'init depot' ' ( cd "$cli" && - for d in 1 2 ; do - mkdir -p dir$d && - for f in 1 2 ; do - echo dir$d/file$d$f >dir$d/file$d$f && - p4 add dir$d/file$d$f && - p4 submit -d "dir$d/file$d$f" - done - done && - find . -type f ! -name files >files && - check_files_exist dir1/file11 dir1/file12 \ - dir2/file21 dir2/file22 + init_depot ) ' @@ -257,6 +261,122 @@ test_expect_success 'clone --use-client-spec sets useClientSpec' ' ) ' +# clone just a subdir of the client spec +test_expect_success 'subdir clone' ' + client_view "//depot/... //client/..." && + files="dir1/file11 dir1/file12 dir2/file21 dir2/file22" && + client_verify $files && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + git_verify dir1/file11 dir1/file12 +' + +# +# submit back, see what happens: five cases +# +test_expect_success 'subdir clone, submit modify' ' + client_view "//depot/... //client/..." && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + ( + cd "$git" && + git config git-p4.skipSubmitEdit true && + echo line >>dir1/file12 && + git add dir1/file12 && + git commit -m dir1/file12 && + "$GITP4" submit + ) && + ( + cd "$cli" && + test_path_is_file dir1/file12 && + test_line_count = 2 dir1/file12 + ) +' + +test_expect_success 'subdir clone, submit add' ' + client_view "//depot/... //client/..." && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + ( + cd "$git" && + git config git-p4.skipSubmitEdit true && + echo file13 >dir1/file13 && + git add dir1/file13 && + git commit -m dir1/file13 && + "$GITP4" submit + ) && + ( + cd "$cli" && + test_path_is_file dir1/file13 + ) +' + +test_expect_success 'subdir clone, submit delete' ' + client_view "//depot/... //client/..." && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + ( + cd "$git" && + git config git-p4.skipSubmitEdit true && + git rm dir1/file12 && + git commit -m "delete dir1/file12" && + "$GITP4" submit + ) && + ( + cd "$cli" && + test_path_is_missing dir1/file12 + ) +' + +test_expect_success 'subdir clone, submit copy' ' + client_view "//depot/... //client/..." && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + ( + cd "$git" && + git config git-p4.skipSubmitEdit true && + git config git-p4.detectCopies true && + cp dir1/file11 dir1/file11a && + git add dir1/file11a && + git commit -m "copy to dir1/file11a" && + "$GITP4" submit + ) && + ( + cd "$cli" && + test_path_is_file dir1/file11a + ) +' + +test_expect_success 'subdir clone, submit rename' ' + client_view "//depot/... //client/..." && + test_when_finished cleanup_git && + "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + ( + cd "$git" && + git config git-p4.skipSubmitEdit true && + git config git-p4.detectRenames true && + git mv dir1/file13 dir1/file13a && + git commit -m "rename dir1/file13 to dir1/file13a" && + "$GITP4" submit + ) && + ( + cd "$cli" && + test_path_is_missing dir1/file13 && + test_path_is_file dir1/file13a + ) +' + +test_expect_success 'reinit depot' ' + ( + cd "$cli" && + p4 sync -f && + rm files && + p4 delete */* && + p4 submit -d "delete all files" && + init_depot + ) +' + # # Rename directories to test quoting in depot-side mappings # //depot -- cgit v1.2.1 From 8d93a5ac68d12a01681a0c2a8d2f799da5cb9fa9 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sun, 26 Feb 2012 10:37:26 -0500 Subject: git-p4: remove bash-ism in t9809 Plain old $# works to count the number of arguments in either bash or dash, even if the arguments have spaces. Based-on-patch-by: Vitor Antunes Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 96426414aa..b0c6d4391d 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -31,7 +31,7 @@ client_view() { # check_files_exist() { ok=0 && - num=${#@} && + num=$# && for arg ; do test_path_is_file "$arg" && ok=$(($ok + 1)) -- cgit v1.2.1 From 6ab1d76c3cf96aac77a75565dfaa0cf64aa100a1 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sun, 8 Apr 2012 20:18:02 -0400 Subject: git p4: use "git p4" directly in tests Drop the $GITP4 variable that was used to specify the script in contrib/fast-import/. The command is called "git p4" now, not "git-p4". Note that configuration variables will remain in a section called "git-p4". Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 88 +++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 773a516ff0..796b02c7f3 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-p4 client view' +test_description='git p4 client view' . ./lib-git-p4.sh @@ -96,25 +96,25 @@ test_expect_success 'init depot' ' test_expect_success 'unsupported view wildcard %%n' ' client_view "//depot/%%%%1/sub/... //client/sub/%%%%1/..." && test_when_finished cleanup_git && - test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot + test_must_fail git p4 clone --use-client-spec --dest="$git" //depot ' test_expect_success 'unsupported view wildcard *' ' client_view "//depot/*/bar/... //client/*/bar/..." && test_when_finished cleanup_git && - test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot + test_must_fail git p4 clone --use-client-spec --dest="$git" //depot ' test_expect_success 'wildcard ... only supported at end of spec 1' ' client_view "//depot/.../file11 //client/.../file11" && test_when_finished cleanup_git && - test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot + test_must_fail git p4 clone --use-client-spec --dest="$git" //depot ' test_expect_success 'wildcard ... only supported at end of spec 2' ' client_view "//depot/.../a/... //client/.../a/..." && test_when_finished cleanup_git && - test_must_fail "$GITP4" clone --use-client-spec --dest="$git" //depot + test_must_fail git p4 clone --use-client-spec --dest="$git" //depot ' test_expect_success 'basic map' ' @@ -122,7 +122,7 @@ test_expect_success 'basic map' ' files="cli1/file11 cli1/file12" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -130,7 +130,7 @@ test_expect_success 'client view with no mappings' ' client_view && client_verify && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify ' @@ -139,7 +139,7 @@ test_expect_success 'single file map' ' files="file11" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -150,7 +150,7 @@ test_expect_success 'later mapping takes precedence (entire repo)' ' cli2/dir2/file21 cli2/dir2/file22" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -160,7 +160,7 @@ test_expect_success 'later mapping takes precedence (partial repo)' ' files="file21 file22" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -176,7 +176,7 @@ test_expect_success 'depot path matching rejected client path' ' files="cli12/file21 cli12/file22" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -187,7 +187,7 @@ test_expect_success 'exclusion wildcard, client rhs same (odd)' ' "-//depot/dir2/... //client/..." && client_verify && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify ' @@ -197,7 +197,7 @@ test_expect_success 'exclusion wildcard, client rhs different (normal)' ' files="dir1/file11 dir1/file12" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -207,7 +207,7 @@ test_expect_success 'exclusion single file' ' files="dir1/file11 dir1/file12 dir2/file21" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -217,7 +217,7 @@ test_expect_success 'overlay wildcard' ' files="cli/file11 cli/file12 cli/file21 cli/file22" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -227,7 +227,7 @@ test_expect_success 'overlay single file' ' files="cli/file11 cli/file12 cli/file21" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -238,7 +238,7 @@ test_expect_success 'exclusion with later inclusion' ' files="dir1/file11 dir1/file12 dir2incl/file21 dir2incl/file22" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -246,7 +246,7 @@ test_expect_success 'quotes on rhs only' ' client_view "//depot/dir1/... \"//client/cdir 1/...\"" && client_verify "cdir 1/file11" "cdir 1/file12" && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify "cdir 1/file11" "cdir 1/file12" ' @@ -258,7 +258,7 @@ test_expect_success 'quotes on rhs only' ' test_expect_success 'clone --use-client-spec sets useClientSpec' ' client_view "//depot/... //client/..." && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && ( cd "$git" && git config --bool git-p4.useClientSpec >actual && @@ -273,7 +273,7 @@ test_expect_success 'subdir clone' ' files="dir1/file11 dir1/file12 dir2/file21 dir2/file22" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + git p4 clone --use-client-spec --dest="$git" //depot/dir1 && git_verify dir1/file11 dir1/file12 ' @@ -283,14 +283,14 @@ test_expect_success 'subdir clone' ' test_expect_success 'subdir clone, submit modify' ' client_view "//depot/... //client/..." && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + git p4 clone --use-client-spec --dest="$git" //depot/dir1 && ( cd "$git" && git config git-p4.skipSubmitEdit true && echo line >>dir1/file12 && git add dir1/file12 && git commit -m dir1/file12 && - "$GITP4" submit + git p4 submit ) && ( cd "$cli" && @@ -302,14 +302,14 @@ test_expect_success 'subdir clone, submit modify' ' test_expect_success 'subdir clone, submit add' ' client_view "//depot/... //client/..." && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + git p4 clone --use-client-spec --dest="$git" //depot/dir1 && ( cd "$git" && git config git-p4.skipSubmitEdit true && echo file13 >dir1/file13 && git add dir1/file13 && git commit -m dir1/file13 && - "$GITP4" submit + git p4 submit ) && ( cd "$cli" && @@ -320,13 +320,13 @@ test_expect_success 'subdir clone, submit add' ' test_expect_success 'subdir clone, submit delete' ' client_view "//depot/... //client/..." && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + git p4 clone --use-client-spec --dest="$git" //depot/dir1 && ( cd "$git" && git config git-p4.skipSubmitEdit true && git rm dir1/file12 && git commit -m "delete dir1/file12" && - "$GITP4" submit + git p4 submit ) && ( cd "$cli" && @@ -337,7 +337,7 @@ test_expect_success 'subdir clone, submit delete' ' test_expect_success 'subdir clone, submit copy' ' client_view "//depot/... //client/..." && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + git p4 clone --use-client-spec --dest="$git" //depot/dir1 && ( cd "$git" && git config git-p4.skipSubmitEdit true && @@ -345,7 +345,7 @@ test_expect_success 'subdir clone, submit copy' ' cp dir1/file11 dir1/file11a && git add dir1/file11a && git commit -m "copy to dir1/file11a" && - "$GITP4" submit + git p4 submit ) && ( cd "$cli" && @@ -356,14 +356,14 @@ test_expect_success 'subdir clone, submit copy' ' test_expect_success 'subdir clone, submit rename' ' client_view "//depot/... //client/..." && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot/dir1 && + git p4 clone --use-client-spec --dest="$git" //depot/dir1 && ( cd "$git" && git config git-p4.skipSubmitEdit true && git config git-p4.detectRenames true && git mv dir1/file13 dir1/file13a && git commit -m "rename dir1/file13 to dir1/file13a" && - "$GITP4" submit + git p4 submit ) && ( cd "$cli" && @@ -419,7 +419,7 @@ test_expect_success 'overlay collision 1 to 2' ' client_verify $files && test_cmp actual "$cli"/filecollide && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files && test_cmp actual "$git"/filecollide ' @@ -432,7 +432,7 @@ test_expect_failure 'overlay collision 2 to 1' ' client_verify $files && test_cmp actual "$cli"/filecollide && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files && test_cmp actual "$git"/filecollide ' @@ -454,7 +454,7 @@ test_expect_failure 'overlay collision 1 to 2, but 2 deleted' ' files="file11 file12 file21 file22" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -477,7 +477,7 @@ test_expect_failure 'overlay collision 1 to 2, but 2 deleted, then 1 updated' ' files="file11 file12 file21 file22" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files ' @@ -533,7 +533,7 @@ test_expect_success 'overlay sync: initial git checkout' ' echo dir1/colA >actual && client_verify $files && test_cmp actual "$cli"/colA && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files && test_cmp actual "$git"/colA ' @@ -558,7 +558,7 @@ test_expect_success 'overlay sync: colA content switch' ' test_cmp actual "$cli"/colA && ( cd "$git" && - "$GITP4" sync --use-client-spec && + git p4 sync --use-client-spec && git merge --ff-only p4/master ) && git_verify $files && @@ -585,7 +585,7 @@ test_expect_success 'overlay sync: colB appears' ' test_cmp actual "$cli"/colB && ( cd "$git" && - "$GITP4" sync --use-client-spec && + git p4 sync --use-client-spec && git merge --ff-only p4/master ) && git_verify $files && @@ -613,7 +613,7 @@ test_expect_success 'overlay sync: colB disappears' ' test_when_finished cleanup_git && ( cd "$git" && - "$GITP4" sync --use-client-spec && + git p4 sync --use-client-spec && git merge --ff-only p4/master ) && git_verify $files @@ -671,7 +671,7 @@ test_expect_success 'overlay sync swap: initial git checkout' ' echo dir1/colA >actual && client_verify $files && test_cmp actual "$cli"/colA && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify $files && test_cmp actual "$git"/colA ' @@ -696,7 +696,7 @@ test_expect_failure 'overlay sync swap: colA no content switch' ' test_cmp actual "$cli"/colA && ( cd "$git" && - "$GITP4" sync --use-client-spec && + git p4 sync --use-client-spec && git merge --ff-only p4/master ) && git_verify $files && @@ -723,7 +723,7 @@ test_expect_success 'overlay sync swap: colB appears' ' test_cmp actual "$cli"/colB && ( cd "$git" && - "$GITP4" sync --use-client-spec && + git p4 sync --use-client-spec && git merge --ff-only p4/master ) && git_verify $files && @@ -753,7 +753,7 @@ test_expect_failure 'overlay sync swap: colB no change' ' test_when_finished cleanup_git && ( cd "$git" && - "$GITP4" sync --use-client-spec && + git p4 sync --use-client-spec && git merge --ff-only p4/master ) && git_verify $files && @@ -801,7 +801,7 @@ test_expect_success 'quotes on lhs only' ' files="cdir1/file11 cdir1/file12" && client_verify $files && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && client_verify $files ' @@ -809,7 +809,7 @@ test_expect_success 'quotes on both sides' ' client_view "\"//depot/dir 1/...\" \"//client/cdir 1/...\"" && client_verify "cdir 1/file11" "cdir 1/file12" && test_when_finished cleanup_git && - "$GITP4" clone --use-client-spec --dest="$git" //depot && + git p4 clone --use-client-spec --dest="$git" //depot && git_verify "cdir 1/file11" "cdir 1/file12" ' -- cgit v1.2.1 From b6ad6dcc3b0629d525abc9fe0882e1b0eb969e17 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sun, 29 Apr 2012 20:57:16 -0400 Subject: git p4: fix writable file after rename or copy The way rename works is with a "p4 integrate", optionally followed by a "p4 edit" if the change is not a 100% rename. Contents are generated by applying a patch, not doing a file system rename. Copy is similar. In this case, p4 does not fix the permissions back to read-only. Make sure this happens by calling "p4 sync -f". Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 796b02c7f3..43ed1feedf 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -349,7 +349,8 @@ test_expect_success 'subdir clone, submit copy' ' ) && ( cd "$cli" && - test_path_is_file dir1/file11a + test_path_is_file dir1/file11a && + test ! -w dir1/file11a ) ' @@ -368,14 +369,14 @@ test_expect_success 'subdir clone, submit rename' ' ( cd "$cli" && test_path_is_missing dir1/file13 && - test_path_is_file dir1/file13a + test_path_is_file dir1/file13a && + test ! -w dir1/file13a ) ' test_expect_success 'reinit depot' ' ( cd "$cli" && - p4 sync -f && rm files && p4 delete */* && p4 submit -d "delete all files" && -- cgit v1.2.1 From 9d7d446ae94d03ff3b7b32e7341198d9b2c5b222 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sun, 29 Apr 2012 20:57:17 -0400 Subject: git p4: submit files with wildcards There are four wildcard characters in p4. Files with these characters can be added to p4 repos using the "-f" option. They are stored in %xx notation, and when checked out, p4 converts them back to normal. When adding files with wildcards in git, the submit path must be careful to use the encoded names in some places, and it must use "-f" to add them. All other p4 commands that operate on the client directory expect encoded filenames as arguments. Support for wildcards in the clone/sync path was added in 084f630 (git-p4: decode p4 wildcard characters, 2011-02-19), but that change did not handle the submit path. There was a problem with wildcards in the sync path too. Commit 084f630 (git-p4: decode p4 wildcard characters, 2011-02-19) handled files with p4 wildcards that were added or modified in p4. Do this for deleted files, and also in branch detection checks, too. Reported-by: Luke Diamand Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 43ed1feedf..7d993ef80a 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -374,6 +374,39 @@ test_expect_success 'subdir clone, submit rename' ' ) ' +# see t9800 for the non-client-spec case, and the rest of the wildcard tests +test_expect_success 'wildcard files submit back to p4, client-spec case' ' + client_view "//depot/... //client/..." && + test_when_finished cleanup_git && + git p4 clone --use-client-spec --dest="$git" //depot/dir1 && + ( + cd "$git" && + echo git-wild-hash >dir1/git-wild#hash && + echo git-wild-star >dir1/git-wild\*star && + echo git-wild-at >dir1/git-wild@at && + echo git-wild-percent >dir1/git-wild%percent && + git add dir1/git-wild* && + git commit -m "add some wildcard filenames" && + git config git-p4.skipSubmitEditCheck true && + git p4 submit + ) && + ( + cd "$cli" && + test_path_is_file dir1/git-wild#hash && + test_path_is_file dir1/git-wild\*star && + test_path_is_file dir1/git-wild@at && + test_path_is_file dir1/git-wild%percent + ) && + ( + # delete these carefully, cannot just do "p4 delete" + # on files with wildcards; but git-p4 knows how + cd "$git" && + git rm dir1/git-wild* && + git commit -m "clean up the wildcards" && + git p4 submit + ) +' + test_expect_success 'reinit depot' ' ( cd "$cli" && -- cgit v1.2.1 From d2018293ca604544a79cd9390953ef0272a65078 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 11 Aug 2012 12:55:00 -0400 Subject: git p4 test: move client_view() function to library This code will be useful in --detect-branches --use-client-spec tests. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 7d993ef80a..281be29174 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -8,23 +8,6 @@ test_expect_success 'start p4d' ' start_p4d ' -# -# Construct a client with this list of View lines -# -client_view() { - ( - cat <<-EOF && - Client: client - Description: client - Root: $cli - View: - EOF - for arg ; do - printf "\t$arg\n" - done - ) | p4 client -i -} - # # Verify these files exist, exactly. Caller creates # a list of files in file "files". -- cgit v1.2.1 From 6112541b444b52d5ac83f491eabefbf571da4997 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 26 Jan 2013 22:11:08 -0500 Subject: git p4 test: avoid loop in client_view The printf command re-interprets the format string as long as there are arguments to consume. Use this to simplify a for loop in the client_view() library function. This requires a fix to one of the client_view callers. An errant \n in the string was converted into a harmless newline in the input to "p4 client -i", but now shows up as a literal \n as passed through by "%s". Remove the \n. Based-on-patch-by: Junio C Hamano Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 281be29174..0b58fb96f0 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -196,7 +196,7 @@ test_expect_success 'exclusion single file' ' test_expect_success 'overlay wildcard' ' client_view "//depot/dir1/... //client/cli/..." \ - "+//depot/dir2/... //client/cli/...\n" && + "+//depot/dir2/... //client/cli/..." && files="cli/file11 cli/file12 cli/file21 cli/file22" && client_verify $files && test_when_finished cleanup_git && -- cgit v1.2.1 From 9d01ae9f20435b90619c909e9cbb9ca29f7de494 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 26 Jan 2013 22:11:16 -0500 Subject: git p4 test: avoid wildcard * in windows This character is not valid in windows filenames, even though it can appear in p4 depot paths. Avoid using it in tests on windows, both mingw and cygwin. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 0b58fb96f0..a9119889ff 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -365,7 +365,10 @@ test_expect_success 'wildcard files submit back to p4, client-spec case' ' ( cd "$git" && echo git-wild-hash >dir1/git-wild#hash && - echo git-wild-star >dir1/git-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + echo git-wild-star >dir1/git-wild\*star + fi && echo git-wild-at >dir1/git-wild@at && echo git-wild-percent >dir1/git-wild%percent && git add dir1/git-wild* && @@ -376,7 +379,10 @@ test_expect_success 'wildcard files submit back to p4, client-spec case' ' ( cd "$cli" && test_path_is_file dir1/git-wild#hash && - test_path_is_file dir1/git-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + test_path_is_file dir1/git-wild\*star + fi && test_path_is_file dir1/git-wild@at && test_path_is_file dir1/git-wild%percent ) && -- cgit v1.2.1 From e9df0f9c7a7fbaed924273d0a9b502171ed23b7c Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 26 Jan 2013 22:11:17 -0500 Subject: git p4: cygwin p4 client does not mark read-only There are some old versions of p4, compiled for cygwin, that treat read-only files differently. Normally, a file that is not open is read-only, meaning that "test -w" on the file is false. This works on unix, and it works on windows using the NT version of p4. The cygwin version of p4, though, changes the permissions, but does not set the windows read-only attribute, so "test -w" returns false. Notice this oddity and make the tests work, even on cygiwn. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9809-git-p4-client-view.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t9809-git-p4-client-view.sh') diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index a9119889ff..77f63492d9 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -333,7 +333,7 @@ test_expect_success 'subdir clone, submit copy' ' ( cd "$cli" && test_path_is_file dir1/file11a && - test ! -w dir1/file11a + ! is_cli_file_writeable dir1/file11a ) ' @@ -353,7 +353,7 @@ test_expect_success 'subdir clone, submit rename' ' cd "$cli" && test_path_is_missing dir1/file13 && test_path_is_file dir1/file13a && - test ! -w dir1/file13a + ! is_cli_file_writeable dir1/file13a ) ' -- cgit v1.2.1