Skip to content

Commit 6112541

Browse files
Pete Wyckoffgitster
authored andcommitted
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 <gitster@pobox.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent daa38f4 commit 6112541

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

t/lib-git-p4.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ client_view() {
121121
Root: $cli
122122
View:
123123
EOF
124-
for arg ; do
125-
printf "\t$arg\n"
126-
done
124+
printf "\t%s\n" "$@"
127125
) | p4 client -i
128126
}

t/t9809-git-p4-client-view.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ test_expect_success 'exclusion single file' '
196196

197197
test_expect_success 'overlay wildcard' '
198198
client_view "//depot/dir1/... //client/cli/..." \
199-
"+//depot/dir2/... //client/cli/...\n" &&
199+
"+//depot/dir2/... //client/cli/..." &&
200200
files="cli/file11 cli/file12 cli/file21 cli/file22" &&
201201
client_verify $files &&
202202
test_when_finished cleanup_git &&

0 commit comments

Comments
 (0)