Skip to content

Commit 733f181

Browse files
spearcegitster
authored andcommitted
Use 'printf %s $x' notation in t5401
We only care about getting what should be an empty string and sending it to a file, without a trailing LF, so the empty string translates into a 0 byte file. Earlier when I originally wrote these lines Mac OS X allowed the format string of printf to be the empty string, but more recent versions appear to have been 'improved' with error messages if the format is not given. This may cause problems if we ever wind up with changes to the hook tests. A minor cleanup makes the test more safe on all systems, by conforming to accepted printf conventions. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent def16e7 commit 733f181

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

t/t5401-update-hooks.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test_expect_success setup '
2525

2626
cat >victim/.git/hooks/pre-receive <<'EOF'
2727
#!/bin/sh
28-
printf "$@" >>$GIT_DIR/pre-receive.args
28+
printf %s "$@" >>$GIT_DIR/pre-receive.args
2929
cat - >$GIT_DIR/pre-receive.stdin
3030
echo STDOUT pre-receive
3131
echo STDERR pre-receive >&2
@@ -35,7 +35,7 @@ chmod u+x victim/.git/hooks/pre-receive
3535
cat >victim/.git/hooks/update <<'EOF'
3636
#!/bin/sh
3737
echo "$@" >>$GIT_DIR/update.args
38-
read x; printf "$x" >$GIT_DIR/update.stdin
38+
read x; printf %s "$x" >$GIT_DIR/update.stdin
3939
echo STDOUT update $1
4040
echo STDERR update $1 >&2
4141
test "$1" = refs/heads/master || exit
@@ -44,7 +44,7 @@ chmod u+x victim/.git/hooks/update
4444

4545
cat >victim/.git/hooks/post-receive <<'EOF'
4646
#!/bin/sh
47-
printf "$@" >>$GIT_DIR/post-receive.args
47+
printf %s "$@" >>$GIT_DIR/post-receive.args
4848
cat - >$GIT_DIR/post-receive.stdin
4949
echo STDOUT post-receive
5050
echo STDERR post-receive >&2
@@ -54,7 +54,7 @@ chmod u+x victim/.git/hooks/post-receive
5454
cat >victim/.git/hooks/post-update <<'EOF'
5555
#!/bin/sh
5656
echo "$@" >>$GIT_DIR/post-update.args
57-
read x; printf "$x" >$GIT_DIR/post-update.stdin
57+
read x; printf %s "$x" >$GIT_DIR/post-update.stdin
5858
echo STDOUT post-update
5959
echo STDERR post-update >&2
6060
EOF

0 commit comments

Comments
 (0)