On Sat, May 17, 2014 at 08:41:30AM +0200, Christian Couder wrote:

> Signed-off-by: Christian Couder <chrisc...@tuxfamily.org>
> ---
>  t/t6050-replace.sh | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)

Yay, tests.

> +test_expect_success 'setup a fake editor' '
> +     cat >fakeeditor <<-\EOF &&
> +             #!/bin/sh
> +             sed -e "s/A U Thor/A fake Thor/" "$1" >"$1.new"
> +             mv "$1.new" "$1"
> +     EOF
> +     chmod +x fakeeditor
> +'

Please use write_script, like:

  test_expect_success 'setup a fake editor' '
        write_script fakeeditor <<-\EOF
                sed -e "s/A U Thor/A fake Thor/" "$1" >"$1.new"
                mv "$1.new" "$1"

which will use the $(SHELL_PATH) shebang. It doesn't matter for such a
simple script here (which even a broken #!/bin/sh could manage), but in
general, I think we're trying to set it consistently.

You could also &&-chain the commands in your fakeeditor script, though I
find it unlikely that sed will fail.

> +test_expect_success '--edit with and without already replaced object' '
> +     GIT_EDITOR=./fakeeditor test_must_fail git replace --edit "$PARA3" &&

Unfortunately it's not portable to do a one-shot environment variable on
a shell function like this; some shells leave the variable set after the
function returns. We've been using:

  test_must_fail env GIT_EDITOR=./fakeeditor git ...

The regular

  GIT_EDITOR=./fakeeditor git ...

ones are OK.

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to