Skip to content

Commit 09ccbd3

Browse files
Pete Wyckoffgitster
authored andcommitted
git-p4: remove bash-ism in t9800
This works in both bash and dash: $ bash -c 'VAR=1 env' | grep VAR VAR=1 $ dash -c 'VAR=1 env' | grep VAR VAR=1 But environment variables assigned this way are not necessarily propagated through a function in POSIX compliant shells: $ bash -c 'f() { "$@" }; VAR=1 f "env"' | grep VAR VAR=1 $ dash -c 'f() { "$@" }; VAR=1 f "env"' | grep VAR Fix constructs like this, in particular, setting variables through test_must_fail. Based-on-patch-by: Vitor Antunes <[email protected]> Signed-off-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8d93a5a commit 09ccbd3

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

t/t9800-git-p4-basic.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,10 @@ test_expect_success 'refuse to preserve users without perms' '
234234
git config git-p4.skipSubmitEditCheck true &&
235235
echo "username-noperms: a change by alice" >>file1 &&
236236
git commit --author "Alice <alice@localhost>" -m "perms: a change by alice" file1 &&
237-
P4EDITOR=touch P4USER=bob P4PASSWD=secret test_must_fail "$GITP4" commit --preserve-user &&
238-
test_must_fail git diff --exit-code HEAD..p4/master
237+
P4EDITOR=touch P4USER=bob P4PASSWD=secret &&
238+
export P4EDITOR P4USER P4PASSWD &&
239+
test_must_fail "$GITP4" commit --preserve-user &&
240+
! git diff --exit-code HEAD..p4/master
239241
)
240242
'
241243

@@ -250,13 +252,15 @@ test_expect_success 'preserve user where author is unknown to p4' '
250252
git commit --author "Bob <bob@localhost>" -m "preserve: a change by bob" file1 &&
251253
echo "username-unknown: a change by charlie" >>file1 &&
252254
git commit --author "Charlie <charlie@localhost>" -m "preserve: a change by charlie" file1 &&
253-
P4EDITOR=touch P4USER=alice P4PASSWD=secret test_must_fail "$GITP4" commit --preserve-user &&
254-
test_must_fail git diff --exit-code HEAD..p4/master &&
255+
P4EDITOR=touch P4USER=alice P4PASSWD=secret &&
256+
export P4EDITOR P4USER P4PASSWD &&
257+
test_must_fail "$GITP4" commit --preserve-user &&
258+
! git diff --exit-code HEAD..p4/master &&
255259
256260
echo "$0: repeat with allowMissingP4Users enabled" &&
257261
git config git-p4.allowMissingP4Users true &&
258262
git config git-p4.preserveUser true &&
259-
P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit &&
263+
"$GITP4" commit &&
260264
git diff --exit-code HEAD..p4/master &&
261265
p4_check_commit_author file1 alice
262266
)
@@ -275,20 +279,22 @@ test_expect_success 'not preserving user with mixed authorship' '
275279
p4_add_user derek Derek &&
276280
277281
make_change_by_user usernamefile3 Derek derek@localhost &&
278-
P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit |\
282+
P4EDITOR=cat P4USER=alice P4PASSWD=secret &&
283+
export P4EDITOR P4USER P4PASSWD &&
284+
"$GITP4" commit |\
279285
grep "git author derek@localhost does not match" &&
280286
281287
make_change_by_user usernamefile3 Charlie charlie@localhost &&
282-
P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit |\
288+
"$GITP4" commit |\
283289
grep "git author charlie@localhost does not match" &&
284290
285291
make_change_by_user usernamefile3 alice alice@localhost &&
286-
P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" |\
292+
"$GITP4" commit |\
287293
test_must_fail grep "git author.*does not match" &&
288294
289295
git config git-p4.skipUserNameCheck true &&
290296
make_change_by_user usernamefile3 Charlie charlie@localhost &&
291-
P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit |\
297+
"$GITP4" commit |\
292298
test_must_fail grep "git author.*does not match" &&
293299
294300
p4_check_commit_author usernamefile3 alice

0 commit comments

Comments
 (0)