{"thread":{"id":"18035","subject":"[PATCH] t5540-http-push.sh: avoid non-portable grep -P","startedAt":"2009-02-26T19:49:05Z","lastAt":"2009-02-27T00:24:20Z","messageCount":17,"participants":["Jay Soffian","Junio C Hamano","Brandon Casey","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"106353","messageId":"1235677745-939-1-git-send-email-jaysoffian@gmail.com","threadId":"18035","inReplyTo":null,"subject":"[PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-26T19:49:05Z","receivedAt":"2009-02-26T19:49:05Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"OS X's GNU grep does not support -P/--perl-regexp; use egrep instead,\navoiding non-portable braces ({}) as well.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n t/t5540-http-push.sh |    8 +++++++-\n 1 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\nindex 11b3432..6a255a6 100755\n--- a/t/t5540-http-push.sh\n+++ b/t/t5540-http-push.sh\n@@ -94,9 +94,15 @@ test_expect_success 'MKCOL sends directory names with trailing slashes' '\n \n '\n \n+x1=\"[a-z0-9]\"\n+x2=\"$x1$x1\"\n+x5=\"$x1$x1$x1$x1$x1\"\n+x38=\"$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1\"\n+x40=\"$x38$x2\"\n+\n test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '\n \n-\tgrep -P \"\\\"(?:PUT|MOVE) .+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\\\" 20\\d\" \\\n+\tegrep \"\\\"(PUT|MOVE) .+objects/$x2/${x38}_$x40 HTTP/[0-9.]+\\\" 20[0-9]\" \\\n \t\t< \"$HTTPD_ROOT_PATH\"/access.log\n \n '\n-- \n1.6.2.rc1.309.g5f417\n"},{"id":"106357","messageId":"7vwsbdq6u4.fsf@gitster.siamese.dyndns.org","threadId":"18035","inReplyTo":"1235677745-939-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-26T20:30:27Z","receivedAt":"2009-02-26T20:30:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> OS X's GNU grep does not support -P/--perl-regexp; use egrep instead,\n> avoiding non-portable braces ({}) as well.\n>\n> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n> ---\n>  t/t5540-http-push.sh |    8 +++++++-\n>  1 files changed, 7 insertions(+), 1 deletions(-)\n>\n> diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\n> index 11b3432..6a255a6 100755\n> --- a/t/t5540-http-push.sh\n> +++ b/t/t5540-http-push.sh\n> @@ -94,9 +94,15 @@ test_expect_success 'MKCOL sends directory names with trailing slashes' '\n>  \n>  '\n>  \n> +x1=\"[a-z0-9]\"\n\nWhy [a-z0-9] not [0-9a-f]?\n\n> +x2=\"$x1$x1\"\n> +x5=\"$x1$x1$x1$x1$x1\"\n> +x38=\"$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1\"\n> +x40=\"$x38$x2\"\n> +\n>  test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '\n>  \n> -\tgrep -P \"\\\"(?:PUT|MOVE) .+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\\\" 20\\d\" \\\n> +\tegrep \"\\\"(PUT|MOVE) .+objects/$x2/${x38}_$x40 HTTP/[0-9.]+\\\" 20[0-9]\" \\\n>  \t\t< \"$HTTPD_ROOT_PATH\"/access.log\n\nI'd rather see the basic BRE grep used if you are shooting for\nportability.\n\nThere are some oddballs in the source (git-submodule.sh is a notable\noffender) but none of the core-ish scripts uses egrep nor \"grep -E\".\n"},{"id":"106359","messageId":"76718490902261243gaebdd8an2bd75bf625556f7b@mail.gmail.com","threadId":"18035","inReplyTo":"7vwsbdq6u4.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-26T20:43:52Z","receivedAt":"2009-02-26T20:43:52Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":">> +x1=\"[a-z0-9]\"\n>\n> Why [a-z0-9] not [0-9a-f]?\n\nNo reason. It's just what popped out of my head.\n\n> I'd rather see the basic BRE grep used if you are shooting for\n> portability.\n>\n> There are some oddballs in the source (git-submodule.sh is a notable\n> offender) but none of the core-ish scripts uses egrep nor \"grep -E\".\n\nSigh, I just wanted the test to pass. I did a check to see if any\nother tests were already using egrep, and when I found that they were,\nI thought that would be good enough.\n\nOriginally I had switched to perl. Would you prefer:\n\ndiff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\nindex 11b3432..a53fe0d 100755\n--- a/t/t5540-http-push.sh\n+++ b/t/t5540-http-push.sh\n@@ -96,8 +96,8 @@ test_expect_success 'MKCOL sends directory names\nwith trailing slashes' '\n\n test_expect_success 'PUT and MOVE sends object to URLs with SHA-1\nhash suffix' '\n\n-\tgrep -P \"\\\"(?:PUT|MOVE)\n.+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\\\" 20\\d\" \\\n-\t\t< \"$HTTPD_ROOT_PATH\"/access.log\n+\ttest $(perl -ne \"print if m{\\\"(?:PUT|MOVE)\n.+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\\\" 20\\d}\" \\\n+\t\t< \"$HTTPD_ROOT_PATH\"/access.log | wc -l) -gt 0\n\n '\n\n?\n\nj.\n"},{"id":"106361","messageId":"76718490902261246k1c5026f9m6ff18701a7a61fba@mail.gmail.com","threadId":"18035","inReplyTo":"76718490902261243gaebdd8an2bd75bf625556f7b@mail.gmail.com","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-26T20:46:54Z","receivedAt":"2009-02-26T20:46:54Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Feb 26, 2009 at 3:43 PM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> Originally I had switched to perl. Would you prefer:\n>\n> diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\n> index 11b3432..a53fe0d 100755\n> --- a/t/t5540-http-push.sh\n> +++ b/t/t5540-http-push.sh\n> @@ -96,8 +96,8 @@ test_expect_success 'MKCOL sends directory names\n> with trailing slashes' '\n>\n>  test_expect_success 'PUT and MOVE sends object to URLs with SHA-1\n> hash suffix' '\n>\n> -       grep -P \"\\\"(?:PUT|MOVE)\n> .+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\\\" 20\\d\" \\\n> -               < \"$HTTPD_ROOT_PATH\"/access.log\n> +       test $(perl -ne \"print if m{\\\"(?:PUT|MOVE)\n> .+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\\\" 20\\d}\" \\\n> +               < \"$HTTPD_ROOT_PATH\"/access.log | wc -l) -gt 0\n>\n>  '\n\ngmail mangled the lines. Sorry about that.\n\nBTW, I was not aiming for \"portable\" to the extent that git is\nportable, I was aiming for \"portable enough\" to the extent that the\ntest suite is portable. :-)\n\nLet me know if the perl above is okay, or if you'd prefer a basic RE\nand I'll send a new patch.\n\nj.\n"},{"id":"106363","messageId":"1235684470-6184-1-git-send-email-jaysoffian@gmail.com","threadId":"18035","inReplyTo":"7vwsbdq6u4.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v2] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-26T21:41:10Z","receivedAt":"2009-02-26T21:41:10Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"OS X's GNU grep does not support -P/--perl-regexp; use basic REs instead.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n t/t5540-http-push.sh |   11 ++++++++---\n 1 files changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\nindex 11b3432..a2e9384 100755\n--- a/t/t5540-http-push.sh\n+++ b/t/t5540-http-push.sh\n@@ -94,10 +94,15 @@ test_expect_success 'MKCOL sends directory names with trailing slashes' '\n \n '\n \n-test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '\n+x1=\"[0-9a-z]\"\n+x2=\"$x1$x1\"\n+x5=\"$x1$x1$x1$x1$x1\"\n+x38=\"$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1\"\n+x40=\"$x38$x2\"\n \n-\tgrep -P \"\\\"(?:PUT|MOVE) .+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\\\" 20\\d\" \\\n-\t\t< \"$HTTPD_ROOT_PATH\"/access.log\n+test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '\n+\tsed -e \"s/PUT/OP/\" -e \"s/MOVE/OP/\" < \"$HTTPD_ROOT_PATH\"/access.log \\\n+\t| grep \"\\\"OP .\\{1,\\}objects/$x2/${x38}_$x40 HTTP/[0-9.]\\{1,\\}\\\" 20[0-9]\"\n \n '\n \n-- \n1.6.2.rc1.309.g5f417\n"},{"id":"106364","messageId":"7vmyc8rhry.fsf@gitster.siamese.dyndns.org","threadId":"18035","inReplyTo":"76718490902261243gaebdd8an2bd75bf625556f7b@mail.gmail.com","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-26T21:48:49Z","receivedAt":"2009-02-26T21:48:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n>>> +x1=\"[a-z0-9]\"\n>>\n>> Why [a-z0-9] not [0-9a-f]?\n>\n> No reason. It's just what popped out of my head.\n>\n>> I'd rather see the basic BRE grep used if you are shooting for\n>> portability.\n>>\n>> There are some oddballs in the source (git-submodule.sh is a notable\n>> offender) but none of the core-ish scripts uses egrep nor \"grep -E\".\n>\n> Sigh, I just wanted the test to pass. I did a check to see if any\n> other tests were already using egrep, and when I found that they were,\n> I thought that would be good enough.\n>\n> Originally I had switched to perl. Would you prefer:\n\nNot really.  \n\nIf we are fixing it we should do it right.  The regexp you inherited seem\nsomewhat suboptimal, too.\n\n\"(?:PUT|MOVE) .+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\" 20\\d\"\n\n - It has a double-quote. can it be anywhere or only at the beginning (if\n   so \"^\" is missing at the beginning -- I didn't check)?\n\n - We then expect PUT or MOVE; Ok (that's \"\\(PUT\\|MOVE\\)\").\n\n - We then expect one space and one or more garbage before we see\n   \"objects/\"; do we really care if it is one-or-more garbage, or is it\n   zero-or-more garbage?  Don't we want to see slash before \"objects/\" (I\n   think we do)?\n\n - Then we expect objects/ and two hexdigits that should be spelled as\n   [0-9a-f]{2} or [0-9a-f][0-9a-f] (or $x2).\n\n - Then we expect / and thiry-eight hexdigits, underscore and then 40\n   hexdigits (I think your $x38 and $x40 are fine);\n\n - Then we expect exactly one SP followed by HTTP/ (Ok);\n\n - And version can be one-or-more of [0-9.]; do we really allow\n   HTTP/..999?, or we don't care?  I think we shouldn't care, and in that\n   case I think [.0-9]* is good enough here;\n\nSo perhaps define a variable:\n\ngood=\"\\\"\\(PUT\\|MOVE\\) .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9]\\\"\"\n\nand grep for it?\n"},{"id":"106367","messageId":"76718490902261419r314f6ea4r5eb02e9b5b0c40d0@mail.gmail.com","threadId":"18035","inReplyTo":"7vmyc8rhry.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-26T22:19:12Z","receivedAt":"2009-02-26T22:19:12Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Feb 26, 2009 at 4:48 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> So perhaps define a variable:\n>\n> good=\"\\\"\\(PUT\\|MOVE\\) .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9]\\\"\"\n>\n> and grep for it?\n\nHmpfh. According to my re_format man page:\n\nObsolete (``basic'') regular expressions differ in several respects.\n`|' is an ordinary character and there is no equivalent for its\nfunctionality.\n\nj.\n"},{"id":"106368","messageId":"7veixkrfif.fsf@gitster.siamese.dyndns.org","threadId":"18035","inReplyTo":"76718490902261419r314f6ea4r5eb02e9b5b0c40d0@mail.gmail.com","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-26T22:37:44Z","receivedAt":"2009-02-26T22:37:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> On Thu, Feb 26, 2009 at 4:48 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> So perhaps define a variable:\n>>\n>> good=\"\\\"\\(PUT\\|MOVE\\) .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9]\\\"\"\n>>\n>> and grep for it?\n>\n> Hmpfh. According to my re_format man page:\n>\n> Obsolete (``basic'') regular expressions differ in several respects.\n> `|' is an ordinary character and there is no equivalent for its\n> functionality.\n\nAhh, you are right; there is no '|'-alternation in BRE.\n\nWe of course could do something like:\n\n    good=\" .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9]\\\"\"\n    grep -e \"\\\"PUT $good\" -e \"\\\"MOVE $good\"\n\nBut that's too ugly.\n\nI don't mind Perl as we already depend on it; the looseness of the regexp\nstil bothers me somewhat, though...\n"},{"id":"106369","messageId":"76718490902261440p4c9981fbncbdd58ad12e38349@mail.gmail.com","threadId":"18035","inReplyTo":"7veixkrfif.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-26T22:40:25Z","receivedAt":"2009-02-26T22:40:25Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Feb 26, 2009 at 5:37 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> I don't mind Perl as we already depend on it; the looseness of the regexp\n> stil bothers me somewhat, though...\n\nI think you're letting the perfect be the enemy of the good. The point\nof the test is merely to check for the SHA-1 has suffix in PUT/MOVE\noperations. Any of my suggestions so far are better than what is there\nnow. Why so much fuss?\n\nI'll send one more iteration, and if that's not good enough, I give up.\n\nj.\n"},{"id":"106370","messageId":"1235688307-8464-1-git-send-email-jaysoffian@gmail.com","threadId":"18035","inReplyTo":"76718490902261440p4c9981fbncbdd58ad12e38349@mail.gmail.com","subject":"[PATCH v3] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-26T22:45:07Z","receivedAt":"2009-02-26T22:45:07Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"OS X's GNU grep does not support -P/--perl-regexp.\n\nWe use a basic RE instead, and simplify the pattern slightly by\nreplacing '+' with '*' so it can be more easily expressed using a basic\nRE. The important part of pattern, checking for a SHA-1 has suffix in\nthe successful PUT/MOVE operations, remains the same. Here are samples\nof what we want to match:\n\n127.0.0.1 - - [26/Feb/2009:22:38:13 +0000] \"PUT /test_repo.git/objects/3e/a4fbb9e18a401a6463c595d08118fcb9fb7426_fab55116904c665a95438bcc78521444a7db6096 HTTP/1.1\" 201 277\n127.0.0.1 - - [26/Feb/2009:22:38:13 +0000] \"MOVE /test_repo.git/objects/3e/a4fbb9e18a401a6463c595d08118fcb9fb7426_fab55116904c665a95438bcc78521444a7db6096 HTTP/1.1\" 201 277\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\nJunio,\n\nThis is the best I can do. If it's not good enough, and you'd rather\nhave the existing non-portable grep -P, so be it.\n\n t/t5540-http-push.sh |   11 ++++++++---\n 1 files changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\nindex 11b3432..470bca3 100755\n--- a/t/t5540-http-push.sh\n+++ b/t/t5540-http-push.sh\n@@ -94,10 +94,15 @@ test_expect_success 'MKCOL sends directory names with trailing slashes' '\n \n '\n \n-test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '\n+x1=\"[0-9a-z]\"\n+x2=\"$x1$x1\"\n+x5=\"$x1$x1$x1$x1$x1\"\n+x38=\"$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1\"\n+x40=\"$x38$x2\"\n \n-\tgrep -P \"\\\"(?:PUT|MOVE) .+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\\\" 20\\d\" \\\n-\t\t< \"$HTTPD_ROOT_PATH\"/access.log\n+test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '\n+\tsed -e \"s/PUT/OP/\" -e \"s/MOVE/OP/\" < \"$HTTPD_ROOT_PATH\"/access.log \\\n+\t| grep \"\\\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\\\" 20[0-9]\"\n \n '\n \n-- \n1.6.2.rc1.309.g5f417\n"},{"id":"106373","messageId":"7v4oygrd3w.fsf@gitster.siamese.dyndns.org","threadId":"18035","inReplyTo":"76718490902261440p4c9981fbncbdd58ad12e38349@mail.gmail.com","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-26T23:29:39Z","receivedAt":"2009-02-26T23:29:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> On Thu, Feb 26, 2009 at 5:37 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> I don't mind Perl as we already depend on it; the looseness of the regexp\n>> stil bothers me somewhat, though...\n>\n> I think you're letting the perfect be the enemy of the good. The point\n> of the test is merely to check for the SHA-1 has suffix in PUT/MOVE\n> operations. Any of my suggestions so far are better than what is there\n> now. Why so much fuss?\n>\n> I'll send one more iteration, and if that's not good enough, I give up.\n>\n> j.\n\nHeh, at least with /a-z/a-f/, I think it is usable.\n\nOr is there a reason I am missing that we want to allow g-z there?\n"},{"id":"106377","messageId":"76718490902261540m77925a38id628fc3bce2a8667@mail.gmail.com","threadId":"18035","inReplyTo":"7v4oygrd3w.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-26T23:40:09Z","receivedAt":"2009-02-26T23:40:09Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Feb 26, 2009 at 6:29 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Heh, at least with /a-z/a-f/, I think it is usable.\n>\n> Or is there a reason I am missing that we want to allow g-z there?\n\nOMG, I didn't even notice that until this message. When you asked:\n\n> Why [a-z0-9] not [0-9a-f]?\n\nI noticed only that you had flipped the relative positions of the\nalphas and the digits, no that you had also a-z to a-f. Please squash\nthis on top of the last patch I sent:\n\ndiff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\nindex 470bca3..bd45203 100755\n--- a/t/t5540-http-push.sh\n+++ b/t/t5540-http-push.sh\n@@ -94,7 +94,7 @@ test_expect_success 'MKCOL sends directory names\nwith trailing slashes' '\n\n '\n\n-x1=\"[0-9a-z]\"\n+x1=\"[0-9a-f]\"\n x2=\"$x1$x1\"\n x5=\"$x1$x1$x1$x1$x1\"\n x38=\"$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1\"\n\n\nSheesh.\n\nj.\n"},{"id":"106378","messageId":"1235691880-9806-1-git-send-email-jaysoffian@gmail.com","threadId":"18035","inReplyTo":"7v4oygrd3w.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v4] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-26T23:44:40Z","receivedAt":"2009-02-26T23:44:40Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"OS X's GNU grep does not support -P/--perl-regexp.\n\nWe use a basic RE instead, and simplify the pattern slightly by\nreplacing '+' with '*' so it can be more easily expressed using a basic\nRE. The important part of pattern, checking for a SHA-1 has suffix in\nthe successful PUT/MOVE operations, remains the same. Also, a-z instead\nof a-f was an obvious mistake in the original RE. Here are samples of\nwhat we want to match:\n\n127.0.0.1 - - [26/Feb/2009:22:38:13 +0000] \"PUT /test_repo.git/objects/3e/a4fbb9e18a401a6463c595d08118fcb9fb7426_fab55116904c665a95438bcc78521444a7db6096 HTTP/1.1\" 201 277\n127.0.0.1 - - [26/Feb/2009:22:38:13 +0000] \"MOVE /test_repo.git/objects/3e/a4fbb9e18a401a6463c595d08118fcb9fb7426_fab55116904c665a95438bcc78521444a7db6096 HTTP/1.1\" 201 277\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\nOn Thu, Feb 26, 2009 at 6:29 PM, Junio C Hamano <gitster@pobox.com> wrote:\n\n> Heh, at least with /a-z/a-f/, I think it is usable.\n>\n> Or is there a reason I am missing that we want to allow g-z there?\n\nI can't believe I didn't notice that. This is really really my last\nsend. I noticed gmail line wrapped my squash, so I'm resending properly.\nUpdated the commit note as well to mention the change from a-z to a-f is\non purpose.\n\nj.\n\n t/t5540-http-push.sh |   11 ++++++++---\n 1 files changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\nindex 11b3432..bd45203 100755\n--- a/t/t5540-http-push.sh\n+++ b/t/t5540-http-push.sh\n@@ -94,10 +94,15 @@ test_expect_success 'MKCOL sends directory names with trailing slashes' '\n \n '\n \n-test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '\n+x1=\"[0-9a-f]\"\n+x2=\"$x1$x1\"\n+x5=\"$x1$x1$x1$x1$x1\"\n+x38=\"$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1\"\n+x40=\"$x38$x2\"\n \n-\tgrep -P \"\\\"(?:PUT|MOVE) .+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\\\" 20\\d\" \\\n-\t\t< \"$HTTPD_ROOT_PATH\"/access.log\n+test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '\n+\tsed -e \"s/PUT/OP/\" -e \"s/MOVE/OP/\" < \"$HTTPD_ROOT_PATH\"/access.log \\\n+\t| grep \"\\\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\\\" 20[0-9]\"\n \n '\n \n-- \n1.6.2.rc1.309.g5f417\n"},{"id":"106379","messageId":"wRrDhWKagbvPUgIXKKh8JIhASl974j2rrgyuh-WEzRJFcXywywNupg@cipher.nrlssc.navy.mil","threadId":"18035","inReplyTo":"7v4oygrd3w.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2009-02-26T23:51:21Z","receivedAt":"2009-02-26T23:51:21Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Junio C Hamano wrote:\n> Jay Soffian <jaysoffian@gmail.com> writes:\n> \n>> On Thu, Feb 26, 2009 at 5:37 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>> I don't mind Perl as we already depend on it; the looseness of the regexp\n>>> stil bothers me somewhat, though...\n>> I think you're letting the perfect be the enemy of the good. The point\n>> of the test is merely to check for the SHA-1 has suffix in PUT/MOVE\n>> operations. Any of my suggestions so far are better than what is there\n>> now. Why so much fuss?\n>>\n>> I'll send one more iteration, and if that's not good enough, I give up.\n>>\n>> j.\n> \n> Heh, at least with /a-z/a-f/, I think it is usable.\n\nTwo minor style issues can also be fixed.\n\nI think the file name can be specified as an argument to sed rather than using\nthe shell's redirection mechanism.\n\n   sed -e 'script' input-file\n\nrather than\n\n   sed -e 'script' < input-file\n\nI think /that/, and moving the pipe character to the end of the sed line so that\nyou don't need to escape the newline will conform to git scripting style so it\nbecomes:\n\n   sed -e \"s/PUT/OP/\" -e \"s/MOVE/OP/\" \"$HTTPD_ROOT_PATH\"/access.log |\n     grep \"\\\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\\\" 20[0-9]\"\n\n-brandon\n"},{"id":"106380","messageId":"alpine.DEB.1.00.0902270056270.10279@pacific.mpi-cbg.de","threadId":"18035","inReplyTo":"wRrDhWKagbvPUgIXKKh8JIhASl974j2rrgyuh-WEzRJFcXywywNupg@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-26T23:58:52Z","receivedAt":"2009-02-26T23:58:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 26 Feb 2009, Brandon Casey wrote:\n\n>    sed -e 'script' input-file\n> \n> rather than\n> \n>    sed -e 'script' < input-file\n\nWhat should make the former more preferable to the latter?\n\nEspecially given that the latter way is preferable with other commands (at \nleast as far as our test suite is concerned), such as grep, because you do \nnot get the file name as part of the result?\n\nAnd especially given that sed means _stream_ editor, not file editor?\n\nCiao,\nDscho\n"},{"id":"106382","messageId":"4WGE1cq9SGp9DuzqT2ZuVN0RzLGmBe1mAX4n1O4-TNyRqiZqxDP62A@cipher.nrlssc.navy.mil","threadId":"18035","inReplyTo":"alpine.DEB.1.00.0902270056270.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2009-02-27T00:12:26Z","receivedAt":"2009-02-27T00:12:26Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Johannes Schindelin wrote:\n> Hi,\n> \n> On Thu, 26 Feb 2009, Brandon Casey wrote:\n> \n>>    sed -e 'script' input-file\n>>\n>> rather than\n>>\n>>    sed -e 'script' < input-file\n> \n> What should make the former more preferable to the latter?\n\nIt's less complex, but as you describe in the next paragraph, if the\nfile name is not desired in the result then the latter is preferable.\nI initially viewed the latter form as a useless use of cat, equivalent\nto:\n\n   cat input-file | sed -e 'script'\n\n> Especially given that the latter way is preferable with other commands (at \n> least as far as our test suite is concerned), such as grep, because you do \n> not get the file name as part of the result?\n> \n> And especially given that sed means _stream_ editor, not file editor?\n\nespecially? Your first argument is valid, but this last sentence means nothing.\n\n-brandon\n"},{"id":"106383","messageId":"7vr61kpw0b.fsf@gitster.siamese.dyndns.org","threadId":"18035","inReplyTo":"4WGE1cq9SGp9DuzqT2ZuVN0RzLGmBe1mAX4n1O4-TNyRqiZqxDP62A@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] t5540-http-push.sh: avoid non-portable grep -P","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-27T00:24:20Z","receivedAt":"2009-02-27T00:24:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Casey <casey@nrlssc.navy.mil> writes:\n\n> Johannes Schindelin wrote:\n>> Hi,\n>> \n>> On Thu, 26 Feb 2009, Brandon Casey wrote:\n>> \n>>>    sed -e 'script' input-file\n>>>\n>>> rather than\n>>>\n>>>    sed -e 'script' < input-file\n>> \n>> What should make the former more preferable to the latter?\n>\n> It's less complex, but as you describe in the next paragraph, if the\n> file name is not desired in the result then the latter is preferable.\n> I initially viewed the latter form as a useless use of cat, equivalent\n> to:\n>\n>    cat input-file | sed -e 'script'\n>\n>> Especially given that the latter way is preferable with other commands (at \n>> least as far as our test suite is concerned), such as grep, because you do \n>> not get the file name as part of the result?\n>> \n>> And especially given that sed means _stream_ editor, not file editor?\n>\n> especially? Your first argument is valid, but this last sentence means nothing.\n>\n\nOk, ok, I heard all of you.  I think \"sed -e 'script' file\" is better\nbecause it is one letter shorter than with \"<\" rediretion, nothing else.\n\nI merely was shooting for rejecting an obvious crap, not aiming for\nperfection.\n\nHere is the final one.  Let's stop wasting time and go on with our lives\n;-)\n\nThanks.\n\n-- >8 --\nFrom: Jay Soffian <jaysoffian@gmail.com>\nDate: Thu, 26 Feb 2009 18:44:40 -0500\nSubject: [PATCH] t5540-http-push.sh: avoid non-portable grep -P\n\nOS X's GNU grep does not support -P/--perl-regexp.\n\nWe use a basic RE instead, and simplify the pattern slightly by\nreplacing '+' with '*' so it can be more easily expressed using a basic\nRE.  The important part of pattern, checking for a SHA-1 has suffix in\nthe successful PUT/MOVE operations, remains the same.  Also, a-z instead\nof a-f was an obvious mistake in the original RE. Here are samples of\nwhat we want to match:\n\n127.0.0.1 - - [26/Feb/2009:22:38:13 +0000] \"PUT /test_repo.git/objects/3e/a4fbb9e18a401a6463c595d08118fcb9fb7426_fab55116904c665a95438bcc78521444a7db6096 HTTP/1.1\" 201 277\n127.0.0.1 - - [26/Feb/2009:22:38:13 +0000] \"MOVE /test_repo.git/objects/3e/a4fbb9e18a401a6463c595d08118fcb9fb7426_fab55116904c665a95438bcc78521444a7db6096 HTTP/1.1\" 201 277\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t5540-http-push.sh |   11 ++++++++---\n 1 files changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\nindex 11b3432..10e5fd0 100755\n--- a/t/t5540-http-push.sh\n+++ b/t/t5540-http-push.sh\n@@ -94,10 +94,15 @@ test_expect_success 'MKCOL sends directory names with trailing slashes' '\n \n '\n \n-test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '\n+x1=\"[0-9a-f]\"\n+x2=\"$x1$x1\"\n+x5=\"$x1$x1$x1$x1$x1\"\n+x38=\"$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1\"\n+x40=\"$x38$x2\"\n \n-\tgrep -P \"\\\"(?:PUT|MOVE) .+objects/[\\da-z]{2}/[\\da-z]{38}_[\\da-z\\-]{40} HTTP/[0-9.]+\\\" 20\\d\" \\\n-\t\t< \"$HTTPD_ROOT_PATH\"/access.log\n+test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '\n+\tsed -e \"s/PUT /OP /\" -e \"s/MOVE /OP /\" \"$HTTPD_ROOT_PATH\"/access.log |\n+\tgrep -e \"\\\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\\\" 20[0-9] \"\n \n '\n \n-- \n1.6.2.rc2.91.gf9a36\n"}]}