{"thread":{"id":"29745","subject":"[PATCH 0/2] git-p4: remove test bash-isms","startedAt":"2012-02-26T15:37:25Z","lastAt":"2012-02-26T18:16:01Z","messageCount":5,"participants":["Pete Wyckoff","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"185458","messageId":"1330270647-8817-1-git-send-email-pw@padd.com","threadId":"29745","inReplyTo":null,"subject":"[PATCH 0/2] git-p4: remove test bash-isms","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-02-26T15:37:25Z","receivedAt":"2012-02-26T15:37:25Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"Two fixes to make the t98* tests run in dash.\n\nPete Wyckoff (2):\n  git-p4: remove bash-ism in t9809\n  git-p4: remove bash-ism in t9800\n\n t/t9800-git-p4-basic.sh       |   25 ++++++++++++++++---------\n t/t9809-git-p4-client-view.sh |    2 +-\n 2 files changed, 17 insertions(+), 10 deletions(-)\n\n-- \n1.7.9.2.288.g74b75\n"},{"id":"185459","messageId":"1330270647-8817-2-git-send-email-pw@padd.com","threadId":"29745","inReplyTo":"1330270647-8817-1-git-send-email-pw@padd.com","subject":"[PATCH 1/2] git-p4: remove bash-ism in t9809","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-02-26T15:37:26Z","receivedAt":"2012-02-26T15:37:26Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"Plain old $# works to count the number of arguments in\neither bash or dash, even if the arguments have spaces.\n\nBased-on-patch-by: Vitor Antunes <vitor.hda@gmail.com>\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9809-git-p4-client-view.sh |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh\nindex ae9145e..18d93e4 100755\n--- a/t/t9809-git-p4-client-view.sh\n+++ b/t/t9809-git-p4-client-view.sh\n@@ -31,7 +31,7 @@ client_view() {\n #\n check_files_exist() {\n \tok=0 &&\n-\tnum=${#@} &&\n+\tnum=$# &&\n \tfor arg ; do\n \t\ttest_path_is_file \"$arg\" &&\n \t\tok=$(($ok + 1))\n-- \n1.7.9.2.288.g74b75\n"},{"id":"185460","messageId":"1330270647-8817-3-git-send-email-pw@padd.com","threadId":"29745","inReplyTo":"1330270647-8817-1-git-send-email-pw@padd.com","subject":"[PATCH 2/2] git-p4: remove bash-ism in t9800","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-02-26T15:37:27Z","receivedAt":"2012-02-26T15:37:27Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"This works in both bash and dash:\n\n    arf$ bash -c 'VAR=1 env' | grep VAR\n    VAR=1\n    arf$ dash -c 'VAR=1 env' | grep VAR\n    VAR=1\n\nBut the variables are not propagated through a function\nin dash:\n\n    arf$ bash -c 'f() { \"$@\"\n    }; VAR=1 f \"env\"' | grep VAR\n    VAR=1\n    arf$ dash -c 'f() { \"$@\"\n    }; VAR=1 f \"env\"' | grep VAR\n\nFix constructs like this, in particular, setting variables\nthrough test_must_fail.\n\nBased-on-patch-by: Vitor Antunes <vitor.hda@gmail.com>\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4-basic.sh |   25 ++++++++++++++++---------\n 1 file changed, 16 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh\nindex 04ee20e..9f17cdb 100755\n--- a/t/t9800-git-p4-basic.sh\n+++ b/t/t9800-git-p4-basic.sh\n@@ -234,8 +234,11 @@ test_expect_success 'refuse to preserve users without perms' '\n \t\tgit config git-p4.skipSubmitEditCheck true &&\n \t\techo \"username-noperms: a change by alice\" >>file1 &&\n \t\tgit commit --author \"Alice <alice@localhost>\" -m \"perms: a change by alice\" file1 &&\n-\t\tP4EDITOR=touch P4USER=bob P4PASSWD=secret test_must_fail \"$GITP4\" commit --preserve-user &&\n-\t\ttest_must_fail git diff --exit-code HEAD..p4/master\n+\t\t# dashism: test_must_fail does not propagate variables\n+\t\tP4EDITOR=touch P4USER=bob P4PASSWD=secret &&\n+\t\texport P4EDITOR P4USER P4PASSWD &&\n+\t\ttest_must_fail \"$GITP4\" commit --preserve-user &&\n+\t\t! git diff --exit-code HEAD..p4/master\n \t)\n '\n \n@@ -250,13 +253,15 @@ test_expect_success 'preserve user where author is unknown to p4' '\n \t\tgit commit --author \"Bob <bob@localhost>\" -m \"preserve: a change by bob\" file1 &&\n \t\techo \"username-unknown: a change by charlie\" >>file1 &&\n \t\tgit commit --author \"Charlie <charlie@localhost>\" -m \"preserve: a change by charlie\" file1 &&\n-\t\tP4EDITOR=touch P4USER=alice P4PASSWD=secret test_must_fail \"$GITP4\" commit --preserve-user &&\n-\t\ttest_must_fail git diff --exit-code HEAD..p4/master &&\n+\t\tP4EDITOR=touch P4USER=alice P4PASSWD=secret &&\n+\t\texport P4EDITOR P4USER P4PASSWD &&\n+\t\ttest_must_fail \"$GITP4\" commit --preserve-user &&\n+\t\t! git diff --exit-code HEAD..p4/master &&\n \n \t\techo \"$0: repeat with allowMissingP4Users enabled\" &&\n \t\tgit config git-p4.allowMissingP4Users true &&\n \t\tgit config git-p4.preserveUser true &&\n-\t\tP4EDITOR=touch P4USER=alice P4PASSWD=secret \"$GITP4\" commit &&\n+\t\t\"$GITP4\" commit &&\n \t\tgit diff --exit-code HEAD..p4/master &&\n \t\tp4_check_commit_author file1 alice\n \t)\n@@ -275,20 +280,22 @@ test_expect_success 'not preserving user with mixed authorship' '\n \t\tp4_add_user derek Derek &&\n \n \t\tmake_change_by_user usernamefile3 Derek derek@localhost &&\n-\t\tP4EDITOR=cat P4USER=alice P4PASSWD=secret \"$GITP4\" commit |\\\n+\t\tP4EDITOR=cat P4USER=alice P4PASSWD=secret &&\n+\t\texport P4EDITOR P4USER P4PASSWD &&\n+\t\t\"$GITP4\" commit |\\\n \t\tgrep \"git author derek@localhost does not match\" &&\n \n \t\tmake_change_by_user usernamefile3 Charlie charlie@localhost &&\n-\t\tP4EDITOR=cat P4USER=alice P4PASSWD=secret \"$GITP4\" commit |\\\n+\t\t\"$GITP4\" commit |\\\n \t\tgrep \"git author charlie@localhost does not match\" &&\n \n \t\tmake_change_by_user usernamefile3 alice alice@localhost &&\n-\t\tP4EDITOR=cat P4USER=alice P4PASSWD=secret \"$GITP4\" |\\\n+\t\t\"$GITP4\" commit |\\\n \t\ttest_must_fail grep \"git author.*does not match\" &&\n \n \t\tgit config git-p4.skipUserNameCheck true &&\n \t\tmake_change_by_user usernamefile3 Charlie charlie@localhost &&\n-\t\tP4EDITOR=cat P4USER=alice P4PASSWD=secret \"$GITP4\" commit |\\\n+\t\t\"$GITP4\" commit |\\\n \t\ttest_must_fail grep \"git author.*does not match\" &&\n \n \t\tp4_check_commit_author usernamefile3 alice\n-- \n1.7.9.2.288.g74b75\n"},{"id":"185463","messageId":"4F4A7057.2020309@kdbg.org","threadId":"29745","inReplyTo":"1330270647-8817-3-git-send-email-pw@padd.com","subject":"Re: [PATCH 2/2] git-p4: remove bash-ism in t9800","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-02-26T17:48:07Z","receivedAt":"2012-02-26T17:48:07Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 26.02.2012 16:37, schrieb Pete Wyckoff:\n> -\t\tP4EDITOR=touch P4USER=bob P4PASSWD=secret test_must_fail \"$GITP4\" commit --preserve-user &&\n> -\t\ttest_must_fail git diff --exit-code HEAD..p4/master\n> +\t\t# dashism: test_must_fail does not propagate variables\n> +\t\tP4EDITOR=touch P4USER=bob P4PASSWD=secret &&\n> +\t\texport P4EDITOR P4USER P4PASSWD &&\n> +\t\ttest_must_fail \"$GITP4\" commit --preserve-user &&\n> +\t\t! git diff --exit-code HEAD..p4/master\n\nIt is a bashism that variables assigned in front of a shell function are\nexported. But it is not a dashism that they are not exported; that\n(surprising?) behavior is actually conforming to POSIX.\n\nWith the new code, be aware that the variables remain exported, which\nmight affect subsequent tests in general, though not this one, because\nthe assignments are in a sub-shell:\n\n>  \t)\n>  '\n\n-- Hannes\n"},{"id":"185465","messageId":"20120226181601.GA10130@padd.com","threadId":"29745","inReplyTo":"4F4A7057.2020309@kdbg.org","subject":"Re: [PATCH 2/2] git-p4: remove bash-ism in t9800","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-02-26T18:16:01Z","receivedAt":"2012-02-26T18:16:01Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"j6t@kdbg.org wrote on Sun, 26 Feb 2012 18:48 +0100:\n> Am 26.02.2012 16:37, schrieb Pete Wyckoff:\n> > -\t\tP4EDITOR=touch P4USER=bob P4PASSWD=secret test_must_fail \"$GITP4\" commit --preserve-user &&\n> > -\t\ttest_must_fail git diff --exit-code HEAD..p4/master\n> > +\t\t# dashism: test_must_fail does not propagate variables\n> > +\t\tP4EDITOR=touch P4USER=bob P4PASSWD=secret &&\n> > +\t\texport P4EDITOR P4USER P4PASSWD &&\n> > +\t\ttest_must_fail \"$GITP4\" commit --preserve-user &&\n> > +\t\t! git diff --exit-code HEAD..p4/master\n> \n> It is a bashism that variables assigned in front of a shell function are\n> exported. But it is not a dashism that they are not exported; that\n> (surprising?) behavior is actually conforming to POSIX.\n> \n> With the new code, be aware that the variables remain exported, which\n> might affect subsequent tests in general, though not this one, because\n> the assignments are in a sub-shell:\n> \n> >  \t)\n> >  '\n\nInteresting, thanks.  I thought about the subshell behavior and\nuse, on purpose, the fact that the variables stay exported in the\nsecond and third hunks.\n\n\t\t-- Pete\n"}]}