{"thread":{"id":"28238","subject":"[PATCH] t5540-http-test: shorten grep pattern","startedAt":"2011-08-28T04:42:00Z","lastAt":"2011-08-29T06:42:21Z","messageCount":3,"participants":["Brian Gernhardt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"174401","messageId":"1314506520-17430-1-git-send-email-brian@gernhardtsoftware.com","threadId":"28238","inReplyTo":null,"subject":"[PATCH] t5540-http-test: shorten grep pattern","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2011-08-28T04:42:00Z","receivedAt":"2011-08-28T04:42:00Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"On OS X, the grep pattern\n\n    \"\\\"OP .*/objects/$x2/X38_X40 HTTP/[.0-9]*\\\" 20[0-9] \"\n\nis far too long ($x38 and $x40 represent 38 and 40 copies of\n[0-9a-f]).  In order to still be able to match this, use the sed\ninvocation to replace what we're looking for a token.\n\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n t/t5540-http-push.sh |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\nindex a266ca5..5bf287d 100755\n--- a/t/t5540-http-push.sh\n+++ b/t/t5540-http-push.sh\n@@ -132,8 +132,9 @@ 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-\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+\tsed -e \"s/PUT /OP /\" -e \"s/MOVE /OP /\" -e \"s/$x40/X40/\" -e \"s/$x38/X38/\"\\\n+\t\t\"$HTTPD_ROOT_PATH\"/access.log |\n+\tgrep -e \"\\\"OP .*/objects/$x2/X38_X40 HTTP/[.0-9]*\\\" 20[0-9] \"\n \n '\n \n-- \n1.7.6.671.g4d09b\n"},{"id":"174440","messageId":"7vhb5094pm.fsf@alter.siamese.dyndns.org","threadId":"28238","inReplyTo":"1314506520-17430-1-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH] t5540-http-test: shorten grep pattern","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-29T05:17:25Z","receivedAt":"2011-08-29T05:17:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brian Gernhardt <brian@gernhardtsoftware.com> writes:\n\n> On OS X, the grep pattern\n>\n>     \"\\\"OP .*/objects/$x2/X38_X40 HTTP/[.0-9]*\\\" 20[0-9] \"\n>\n> is far too long ($x38 and $x40 represent 38 and 40 copies of\n> [0-9a-f]).  In order to still be able to match this, use the sed\n> invocation to replace what we're looking for a token.\n>\n> Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n> ---\n>  t/t5540-http-push.sh |    5 +++--\n>  1 files changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\n> index a266ca5..5bf287d 100755\n> --- a/t/t5540-http-push.sh\n> +++ b/t/t5540-http-push.sh\n> @@ -132,8 +132,9 @@ 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> -\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> +\tsed -e \"s/PUT /OP /\" -e \"s/MOVE /OP /\" -e \"s/$x40/X40/\" -e \"s/$x38/X38/\"\\\n> +\t\t\"$HTTPD_ROOT_PATH\"/access.log |\n> +\tgrep -e \"\\\"OP .*/objects/$x2/X38_X40 HTTP/[.0-9]*\\\" 20[0-9] \"\n>  \n>  '\n\nHmm...\n\nIs it sensible to replace $x40 with X40 and $x38 with X38 on any line\nanywhere for the purpose of this test? As the downstream test is only\ninterested in a line with HTTP request line that asks for a specific path\nunder objects/??/?{38}_?{40}, wouldn't it make more sense to replace\noccurrences of only such line?\n\n\tsed -n \\\n            -e \"s/PUT /OP \" \\\n\t    -e \"s/MOVE /OP /\" \\\n\t    -e \"s|/objects/$x2/$x38_$x40|WANTED_PATH_REQUEST|p\" \\\n\t    \"$HTTPD_ROOT_PATH/access.log\" |\n\tgrep -e \"\\\"OP .*WANTED_PATH_REQUEST HTTP/[.0-9]*\\\" 20[0-9] \"\n"},{"id":"174449","messageId":"FA05560D-EE6C-43F4-BD67-EF9E77FA969A@gernhardtsoftware.com","threadId":"28238","inReplyTo":"7vhb5094pm.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] t5540-http-test: shorten grep pattern","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2011-08-29T06:42:21Z","receivedAt":"2011-08-29T06:42:21Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"On OS X, the grep pattern\n\n    \"\\\"OP .*/objects/$x2/X38_X40 HTTP/[.0-9]*\\\" 20[0-9] \"\n\nis too long ($x38 and $x40 represent 38 and 40 copies of [0-9a-f]) for\ngrep to handle.  In order to still be able to match this, use the sed\ninvocation to replace what we're looking for with a token.\n\nImproved-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n t/t5540-http-push.sh |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\nOn Aug 29, 2011, at 1:17 AM, Junio C Hamano wrote:\n\n> Is it sensible to replace $x40 with X40 and $x38 with X38 on any line\n> anywhere for the purpose of this test? As the downstream test is only\n> interested in a line with HTTP request line that asks for a specific path\n> under objects/??/?{38}_?{40}, wouldn't it make more sense to replace\n> occurrences of only such line?\n\nYes, of course.  The reason it ended up the way it did was that I first\ntried replacing $x40 with SHA-1, but that was still too long.  Your way\nmakes more sense in the end, although the $x38_$x40 bit needs to be\n${x38}_$x40 so the shell looks for the right variable.\n\ndiff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\nindex a266ca5..64767d8 100755\n--- a/t/t5540-http-push.sh\n+++ b/t/t5540-http-push.sh\n@@ -132,8 +132,12 @@ 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-\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+\tsed \\\n+\t\t-e \"s/PUT /OP /\" \\\n+\t\t-e \"s/MOVE /OP /\" \\\n+\t    -e \"s|/objects/$x2/${x38}_$x40|WANTED_PATH_REQUEST|\" \\\n+\t\t\"$HTTPD_ROOT_PATH\"/access.log |\n+\tgrep -e \"\\\"OP .*WANTED_PATH_REQUEST HTTP/[.0-9]*\\\" 20[0-9] \"\n \n '\n \n-- \n1.7.7.rc0.308.g517a2\n"}]}