git p4 test: avoid loop in client_view
authorPete Wyckoff <pw@padd.com>
Sun, 27 Jan 2013 03:11:08 +0000 (22:11 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sun, 27 Jan 2013 06:00:38 +0000 (22:00 -0800)
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 <gitster@pobox.com>
Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-git-p4.sh
t/t9809-git-p4-client-view.sh

index 890ee60708f59e743daf93171f40adb0abc4a76d..b1dbded3e801bd6c1869598a7b70f8af3fde4ccb 100644 (file)
@@ -121,8 +121,6 @@ client_view() {
                Root: $cli
                View:
                EOF
-               for arg ; do
-                       printf "\t$arg\n"
-               done
+               printf "\t%s\n" "$@"
        ) | p4 client -i
 }
index 281be29174b8b4fea854d72c663eaa2d46b00259..0b58fb96f097dee7cd4d139269698e8dde4a81c3 100755 (executable)
@@ -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 &&