Re: [PATCH v6 8/8] update-ref: add test cases covering --stdin signature
From: Eric Sunshine <hidden>
Date: 2016-06-15 22:58:43
On Mon, Sep 9, 2013 at 8:57 PM, Brad King [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Extend t/t1400-update-ref.sh to cover cases using the --stdin option. Signed-off-by: Brad King <redacted> --- t/t1400-update-ref.sh | 639 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 639 insertions(+)diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index e415ee0..a510500 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh@@ -302,4 +302,643 @@ test_expect_success \ 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \ 'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")' +a=refs/heads/a +b=refs/heads/b +c=refs/heads/c +E='""' +pws='path with space' + +print_nul() { + while test $# -gt 0; do + printf -- "$1" && + printf -- "Q" | q_to_nul && + shift || return + done +}
I believe that current fashion in git test scripts is to add a space
before () in the function declaration. Likewise, the 'do' should be on
the line following 'while' and aligned with 'while' (and drop the
semicolon).
The '--' option to printf is not likely portable. POSIX [1] certainly
does not mention it.
You can get printf to emit a NUL more naturally via \0, so q_to_nul is
unnecessary.
Finally, printf reuses its 'format' argument as many times as needed
to output all arguments, so the while loop is unneeded.
Thus printf provides all the functionality you require, and
print_nul() function can be dropped. So:
printf '%s\0' foo bar baz
is equivalent to:
print_null foo bar baz
[1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html