{"thread":{"id":"29275","subject":"[PATCH] Work around sed portability issue in t8006-blame-textconv","startedAt":"2011-12-31T13:44:28Z","lastAt":"2012-01-10T04:46:26Z","messageCount":7,"participants":["Ben Walton","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"181814","messageId":"1325339068-6063-1-git-send-email-bwalton@artsci.utoronto.ca","threadId":"29275","inReplyTo":null,"subject":"[PATCH] Work around sed portability issue in t8006-blame-textconv","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2011-12-31T13:44:28Z","receivedAt":"2011-12-31T13:44:28Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"In test 'blame --textconv with local changes' of t8006-blame-textconv,\nusing /usr/xpg4/bin/sed on Solaris as set by SANE_TOOL_PATH, an\nadditional newline was added to the output from the 'helper' script\ndriven by git attributes.\n\nThis was noted by sed with a message such as:\nsed: Missing newline at end of file zero.bin.\n\nIn turn, this was triggering a fatal error from git blame:\nfatal: unable to read files to diff\n\nThe git blame --textconv stdout was empty as a result of the error\ncondition above.  This caused the test to fail because the output\nvalue differed from the expected result.\n\nUse perl -p -e instead of sed -e to work around this portability issue\nas it will not insert the newline.  This allows the git blame call to\ncomplete at which point the output comparison is successful.\n\nSigned-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n---\n t/t8006-blame-textconv.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t8006-blame-textconv.sh b/t/t8006-blame-textconv.sh\nindex 4ee42f1..c3c22f7 100755\n--- a/t/t8006-blame-textconv.sh\n+++ b/t/t8006-blame-textconv.sh\n@@ -10,7 +10,7 @@ find_blame() {\n cat >helper <<'EOF'\n #!/bin/sh\n grep -q '^bin: ' \"$1\" || { echo \"E: $1 is not \\\"binary\\\" file\" 1>&2; exit 1; }\n-sed 's/^bin: /converted: /' \"$1\"\n+perl -p -e 's/^bin: /converted: /' \"$1\"\n EOF\n chmod +x helper\n \n-- \n1.7.4.1\n"},{"id":"181873","messageId":"7vd3b0vc6h.fsf@alter.siamese.dyndns.org","threadId":"29275","inReplyTo":"1325339068-6063-1-git-send-email-bwalton@artsci.utoronto.ca","subject":"Re: [PATCH] Work around sed portability issue in t8006-blame-textconv","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-03T19:05:58Z","receivedAt":"2012-01-03T19:05:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Walton <bwalton@artsci.utoronto.ca> writes:\n\n> In test 'blame --textconv with local changes' of t8006-blame-textconv,\n> using /usr/xpg4/bin/sed on Solaris as set by SANE_TOOL_PATH, an\n> additional newline was added to the output from the 'helper' script\n> driven by git attributes.\n>\n> This was noted by sed with a message such as:\n> sed: Missing newline at end of file zero.bin.\n>\n> In turn, this was triggering a fatal error from git blame:\n> fatal: unable to read files to diff\n\nInteresting. A file with incomplete line technically is not a text file\nand sed is supposed to work on text files, so it is allowed to be picky.\n\n> Use perl -p -e instead of sed -e to work around this portability issue\n> as it will not insert the newline.\n\nI am not sure if additional newline is the problem, or the exit status\nfrom sed is, from your description. Your first paragraph says you will get\noutput from sed but with an extra newline, and then later you said blame\nnoticed an error in its attempt to read the contents. I am suspecting that\nit checked the exit status from the textconv subprocess and noticed the\nerror and that is the cause of the issue, but could you clarify?  IOW, I\nam suspecting that replacing \"as it will not insert the newline\" with \"as\nit does not error out on an incomplete line\" is necessary in this\nsentence.\n\nThanks.\n"},{"id":"182049","messageId":"7vehvcigsy.fsf@alter.siamese.dyndns.org","threadId":"29275","inReplyTo":"7vd3b0vc6h.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Work around sed portability issue in t8006-blame-textconv","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-06T22:53:33Z","receivedAt":"2012-01-06T22:53:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Ben Walton <bwalton@artsci.utoronto.ca> writes:\n>\n>> In test 'blame --textconv with local changes' of t8006-blame-textconv,\n>> using /usr/xpg4/bin/sed on Solaris as set by SANE_TOOL_PATH, an\n>> additional newline was added to the output from the 'helper' script\n>> driven by git attributes.\n>>\n>> This was noted by sed with a message such as:\n>> sed: Missing newline at end of file zero.bin.\n>>\n>> In turn, this was triggering a fatal error from git blame:\n>> fatal: unable to read files to diff\n>\n> Interesting. A file with incomplete line technically is not a text file\n> and sed is supposed to work on text files, so it is allowed to be picky.\n>\n>> Use perl -p -e instead of sed -e to work around this portability issue\n>> as it will not insert the newline.\n>\n> I am not sure if additional newline is the problem, or the exit status\n> from sed is, from your description. Your first paragraph says you will get\n> output from sed but with an extra newline, and then later you said blame\n> noticed an error in its attempt to read the contents. I am suspecting that\n> it checked the exit status from the textconv subprocess and noticed the\n> error and that is the cause of the issue, but could you clarify?  IOW, I\n> am suspecting that replacing \"as it will not insert the newline\" with \"as\n> it does not error out on an incomplete line\" is necessary in this\n> sentence.\n\nPing?\n"},{"id":"182146","messageId":"1326080292-sup-3735@pinkfloyd.chass.utoronto.ca","threadId":"29275","inReplyTo":"7vehvcigsy.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Work around sed portability issue in t8006-blame-textconv","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2012-01-09T03:40:44Z","receivedAt":"2012-01-09T03:40:44Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"Excerpts from Junio C Hamano's message of Fri Jan 06 17:53:33 -0500 2012:\n\n> Ping?\n\nSorry, I was out of email contact since last Sunday.  I'll look at\nthis tomorrow.  I think I tested the exit status from\n/usr/xpg4/bin/sed on this file by hand and found that it was exiting\ncleanly, but I'll verify and let you know.  If you're correct, I'll\nadjust the commit message accordingly.\n\nThanks\n-Ben\n--\nBen Walton\nSystems Programmer - CHASS\nUniversity of Toronto\nC:416.407.5610 | W:416.978.4302\n"},{"id":"182200","messageId":"1326163653-26565-1-git-send-email-bwalton@artsci.utoronto.ca","threadId":"29275","inReplyTo":"7vd3b0vc6h.fsf@alter.siamese.dyndns.org","subject":"[PATCH 0/1] Re-roll of the test fix for sed on solaris","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2012-01-10T02:47:32Z","receivedAt":"2012-01-10T02:47:32Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"Hi Junio,\n\nIt seems that you were correct in that it's the exit status from sed\nthat ultimately causes the breakage.  I've updated the commit message\nto reflect this.\n\nThanks\n-Ben\n"},{"id":"182201","messageId":"1326163653-26565-2-git-send-email-bwalton@artsci.utoronto.ca","threadId":"29275","inReplyTo":"1326163653-26565-1-git-send-email-bwalton@artsci.utoronto.ca","subject":"[PATCH] Use perl instead of sed for t8006-blame-textconv test","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2012-01-10T02:47:33Z","receivedAt":"2012-01-10T02:47:33Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"In test 'blame --textconv with local changes' of t8006-blame-textconv,\nusing /usr/xpg4/bin/sed (as set by SANE_TOOL_PATH), an additional\nnewline was added to the output from the 'helper' script.\n\nThis was noted by sed with a message such as:\nsed: Missing newline at end of file zero.bin.\n\nSed then exits with status 2 causing the helper script to also exit\nwith status 2.\n\nIn turn, this was triggering a fatal error from git blame:\nfatal: unable to read files to diff\n\nTo work around this difference in sed behaviour, use perl -p instead\nof sed -e as it exits cleanly and does not insert the additional\nnewline.\n\nSigned-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n---\n t/t8006-blame-textconv.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t8006-blame-textconv.sh b/t/t8006-blame-textconv.sh\nindex 4ee42f1..c3c22f7 100755\n--- a/t/t8006-blame-textconv.sh\n+++ b/t/t8006-blame-textconv.sh\n@@ -10,7 +10,7 @@ find_blame() {\n cat >helper <<'EOF'\n #!/bin/sh\n grep -q '^bin: ' \"$1\" || { echo \"E: $1 is not \\\"binary\\\" file\" 1>&2; exit 1; }\n-sed 's/^bin: /converted: /' \"$1\"\n+perl -p -e 's/^bin: /converted: /' \"$1\"\n EOF\n chmod +x helper\n \n-- \n1.7.8.2\n"},{"id":"182204","messageId":"7vpqesb1wd.fsf@alter.siamese.dyndns.org","threadId":"29275","inReplyTo":"1326163653-26565-1-git-send-email-bwalton@artsci.utoronto.ca","subject":"Re: [PATCH 0/1] Re-roll of the test fix for sed on solaris","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-10T04:46:26Z","receivedAt":"2012-01-10T04:46:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Walton <bwalton@artsci.utoronto.ca> writes:\n\n> It seems that you were correct in that it's the exit status from sed\n> that ultimately causes the breakage.  I've updated the commit message\n> to reflect this.\n\nThanks for being thorough. Very much appreciated.\n"}]}