{"thread":{"id":"11792","subject":"[PATCH 1/7] Use 'printf %s $x' notation in t5401","startedAt":"2008-01-30T06:21:56Z","lastAt":"2008-01-31T03:41:56Z","messageCount":5,"participants":["Shawn O. Pearce","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"66888","messageId":"20080130062156.GA15838@spearce.org","threadId":"11792","inReplyTo":null,"subject":"[PATCH 1/7] Use 'printf %s $x' notation in t5401","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-01-30T06:21:56Z","receivedAt":"2008-01-30T06:21:56Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"We only care about getting what should be an empty string and\nsending it to a file, without a trailing LF, so the empty string\ntranslates into a 0 byte file.  Earlier when I originally wrote\nthese lines Mac OS X allowed the format string of printf to be\nthe empty string, but more recent versions appear to have been\n'improved' with error messages if the format is not given.\n\nThis may cause problems if we ever wind up with changes to the hook\ntests.  A minor cleanup makes the test more safe on all systems,\nby conforming to accepted printf conventions.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n t/t5401-update-hooks.sh |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh\nindex 3eea306..9734fc5 100755\n--- a/t/t5401-update-hooks.sh\n+++ b/t/t5401-update-hooks.sh\n@@ -25,7 +25,7 @@ test_expect_success setup '\n \n cat >victim/.git/hooks/pre-receive <<'EOF'\n #!/bin/sh\n-printf \"$@\" >>$GIT_DIR/pre-receive.args\n+printf %s \"$@\" >>$GIT_DIR/pre-receive.args\n cat - >$GIT_DIR/pre-receive.stdin\n echo STDOUT pre-receive\n echo STDERR pre-receive >&2\n@@ -35,7 +35,7 @@ chmod u+x victim/.git/hooks/pre-receive\n cat >victim/.git/hooks/update <<'EOF'\n #!/bin/sh\n echo \"$@\" >>$GIT_DIR/update.args\n-read x; printf \"$x\" >$GIT_DIR/update.stdin\n+read x; printf %s \"$x\" >$GIT_DIR/update.stdin\n echo STDOUT update $1\n echo STDERR update $1 >&2\n test \"$1\" = refs/heads/master || exit\n@@ -44,7 +44,7 @@ chmod u+x victim/.git/hooks/update\n \n cat >victim/.git/hooks/post-receive <<'EOF'\n #!/bin/sh\n-printf \"$@\" >>$GIT_DIR/post-receive.args\n+printf %s \"$@\" >>$GIT_DIR/post-receive.args\n cat - >$GIT_DIR/post-receive.stdin\n echo STDOUT post-receive\n echo STDERR post-receive >&2\n@@ -54,7 +54,7 @@ chmod u+x victim/.git/hooks/post-receive\n cat >victim/.git/hooks/post-update <<'EOF'\n #!/bin/sh\n echo \"$@\" >>$GIT_DIR/post-update.args\n-read x; printf \"$x\" >$GIT_DIR/post-update.stdin\n+read x; printf %s \"$x\" >$GIT_DIR/post-update.stdin\n echo STDOUT post-update\n echo STDERR post-update >&2\n EOF\n-- \n1.5.4.rc5.1126.g6ba14\n"},{"id":"66896","messageId":"7vlk67izoa.fsf@gitster.siamese.dyndns.org","threadId":"11792","inReplyTo":"20080130062156.GA15838@spearce.org","subject":"Re: [PATCH 1/7] Use 'printf %s $x' notation in t5401","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-30T06:40:37Z","receivedAt":"2008-01-30T06:40:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> We only care about getting what should be an empty string and\n> sending it to a file, without a trailing LF, so the empty string\n> translates into a 0 byte file.  Earlier when I originally wrote\n> these lines Mac OS X allowed the format string of printf to be\n> the empty string, but more recent versions appear to have been\n> 'improved' with error messages if the format is not given.\n\nThat sounds like a bug to me.\n\n> diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh\n> index 3eea306..9734fc5 100755\n> --- a/t/t5401-update-hooks.sh\n> +++ b/t/t5401-update-hooks.sh\n> @@ -25,7 +25,7 @@ test_expect_success setup '\n>  \n>  cat >victim/.git/hooks/pre-receive <<'EOF'\n>  #!/bin/sh\n> -printf \"$@\" >>$GIT_DIR/pre-receive.args\n> +printf %s \"$@\" >>$GIT_DIR/pre-receive.args\n\nDo you really mean this? \"printf %s 1 2 3\" writes \"123\" without\nterminating LF.  You seem to check only for size but to be\nreusable you might want to use something like:\n\n\tprintf '%s\\n' \"$@\"\n\nLikewise for post-receive.args.\n"},{"id":"66897","messageId":"20080130064845.GR24004@spearce.org","threadId":"11792","inReplyTo":"7vlk67izoa.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/7] Use 'printf %s $x' notation in t5401","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-01-30T06:48:45Z","receivedAt":"2008-01-30T06:48:45Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> > diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh\n> > index 3eea306..9734fc5 100755\n> > --- a/t/t5401-update-hooks.sh\n> > +++ b/t/t5401-update-hooks.sh\n> > @@ -25,7 +25,7 @@ test_expect_success setup '\n> >  \n> >  cat >victim/.git/hooks/pre-receive <<'EOF'\n> >  #!/bin/sh\n> > -printf \"$@\" >>$GIT_DIR/pre-receive.args\n> > +printf %s \"$@\" >>$GIT_DIR/pre-receive.args\n> \n> Do you really mean this? \"printf %s 1 2 3\" writes \"123\" without\n> terminating LF.  You seem to check only for size but to be\n> reusable you might want to use something like:\n\nThe only thing we care about is was there args or not to the hook.\nI probably could do that test differently, like say:\n\n\techo $# >$GIT_DIR/pre-receive.args\n\nand then test that the file contains \"0\" instead of looking for it to\nbe empty.  Not sure why I didn't write it that way in the beginning.\n\n> \tprintf '%s\\n' \"$@\"\n\nEh.  Since all we care is that the argument count is 0 we probably\nshould be looking at $# and calling it a day.\n\n-- \nShawn.\n"},{"id":"66941","messageId":"7vbq72hjzo.fsf@gitster.siamese.dyndns.org","threadId":"11792","inReplyTo":"20080130064845.GR24004@spearce.org","subject":"Re: [PATCH 1/7] Use 'printf %s $x' notation in t5401","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-31T01:16:59Z","receivedAt":"2008-01-31T01:16:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Junio C Hamano <gitster@pobox.com> wrote:\n>> ...\n>> Do you really mean this? \"printf %s 1 2 3\" writes \"123\" without\n>> terminating LF.  You seem to check only for size but to be\n>> reusable you might want to use something like:\n> \n> The only thing we care about is was there args or not to the hook.\n> I probably could do that test differently, like say:\n>\n> \techo $# >$GIT_DIR/pre-receive.args\n>\n> and then test that the file contains \"0\" instead of looking for it to\n> be empty.  Not sure why I didn't write it that way in the beginning.\n>\n>> \tprintf '%s\\n' \"$@\"\n>\n> Eh.  Since all we care is that the argument count is 0 we probably\n> should be looking at $# and calling it a day.\n\nI'll apply as-is, but once you break the code that calls\npre-receive hook in such a way that it sends unexpected\narguments, you'd thank me for suggesting to print the arguments\nseparately while debugging the problem with the test script.\n"},{"id":"66955","messageId":"20080131034156.GV24004@spearce.org","threadId":"11792","inReplyTo":"7vbq72hjzo.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/7] Use 'printf %s $x' notation in t5401","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-01-31T03:41:56Z","receivedAt":"2008-01-31T03:41:56Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> >> \tprintf '%s\\n' \"$@\"\n> >\n> > Eh.  Since all we care is that the argument count is 0 we probably\n> > should be looking at $# and calling it a day.\n> \n> I'll apply as-is, but once you break the code that calls\n> pre-receive hook in such a way that it sends unexpected\n> arguments, you'd thank me for suggesting to print the arguments\n> separately while debugging the problem with the test script.\n\nWell, I don't really think it matters.  I doubt we'll break that\ncode that invokes the pre-receive or post-receive hooks.  And as\nthose hooks are defined to never take arguments if we did suddenly\nstart passing arguments we want the test to break.  When tests break\nsometimes its not obvious why they have broken.\n\nCase in point, the \"remote: \" prefixing caused by the sideband\ndemultiplexer really confused me for about 15 minutes.  I could\nnot figure out why the last test in this script was failing.\nUntil I pulled my head out of the sand and looked at the \"actual\"\nfile and saw those prefixes.  At which point it was very obvious.\n\n:)\n\nWe haven't touched that script in almost a year.  I poked at it only\nto fix a stupid error from my printf implementation, and because of\nthe new \"remote:\" prefix.  Which since it is a change in behavior may\ncause problems for anyone who is trying to screen-scrape the stderr\nof git-push.  Gawd I hope nobody's scripts are that convoluted.\n\n-- \nShawn.\n"}]}