Re: [PATCH 03/15] [GSOC] ref-filter: --format=%(raw) re-support --perl
On Thu, Jul 01 2021, ZheNing Hu via GitGitGadget wrote:
Show 9 quoted lines
> From: ZheNing Hu <adlternative@gmail.com>
>
> Because the perl language can handle binary data correctly,
> add the function perl_quote_buf_with_len(), which can specify
> the length of the data and prevent the data from being truncated
> at '\0' to help `--format="%(raw)"` re-support `--perl`.
>
> Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Show 22 quoted lines
> -test_expect_success '%(raw) with --perl must fail' '
> - test_must_fail git for-each-ref --format="%(raw)" --perl
> +test_expect_success '%(raw) with --perl' '
> + git for-each-ref --format="\$name= %(raw);
> +print \"\$name\"" refs/myblobs/blob1 --perl | perl > actual &&
> + cmp blob1 actual &&
> + git for-each-ref --format="\$name= %(raw);
> +print \"\$name\"" refs/myblobs/blob3 --perl | perl > actual &&
> + cmp blob3 actual &&
> + git for-each-ref --format="\$name= %(raw);
> +print \"\$name\"" refs/myblobs/blob8 --perl | perl > actual &&
> + cmp blob8 actual &&
> + git for-each-ref --format="\$name= %(raw);
> +print \"\$name\"" refs/myblobs/first --perl | perl > actual &&
> + cmp one actual &&
> + git cat-file tree refs/mytrees/first > expected &&
> + git for-each-ref --format="\$name= %(raw);
> +print \"\$name\"" refs/mytrees/first --perl | perl > actual &&
> + cmp expected actual
> '
>
> test_expect_success '%(raw) with --shell must fail' '
Nit: Formatting can be "| perl >actual", not "| perl > actual", like the
usual style...