hooks/post-receive: replace printf with echo
commit97daf228d580098813ab2bf889abc7721e6d7013
authorKyle J. McKay <mackyle@gmail.com>
Tue, 6 Dec 2016 02:06:35 +0000 (5 18:06 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Tue, 6 Dec 2016 02:06:35 +0000 (5 18:06 -0800)
treeaa84aaa24d7546c3c6f7156373791ead0c6c79bf
parentbc4a4394cca96ea60938e555e2bdf79b79aa2f82
hooks/post-receive: replace printf with echo

The post-receive hook may run inside the chroot.  The printf command
may not be internal to the /bin/sh in use inside the chroot.  The
post-receive hook was using printf to safely output the ref update
lines.

This means:

  1) It's much slower

  2) It will break unless the external printf command is installed
     in the chroot

However, the format of a ref update line is <old> <new> <refname>
where both <old> and <new> are all hex digits and <refname> is any
acceptable Git ref name (which will always start with "refs/").

This means switching to "echo" instead will always be safe because a
hex digit (<old> always starts with a hex digit) can never be
interpreted as an option to echo and the character '\' is not valid
in Git ref names so there cannot possibly be any unintentionally
expanded escape sequences (by the versions of echo that do such
things) since all of the escape sequences in question start with '\'
and that character cannot be present in <old>, <new> or <refname>.

Therefore switch from using "printf '%s\n'" to "echo" so that shells
without an internal, built-in "printf" command are not forced to run
more slowly and will actually generate ref updates in the case where
the printf external command has not been installed in the chroot
(which Girocco is not yet guaranteeing).

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
hooks/post-receive