Re: [PATCH 04/18] t1401-symbolic-ref: avoid direct filesystem access
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Apr 19, 2021, 20:38 UTC
- Message-ID
- <20210419203835.GW2947267@szeder.dev>
- In-Reply-To
- <53cf1069552b6cd6161ce6f69a31c44e59091096.1618829583.git.gitgitgadget@gmail.com>
On Mon, Apr 19, 2021 at 10:52:49AM +0000, Han-Wen Nienhuys via GitGitGadget wrote:
Show 32 quoted lines
> From: Han-Wen Nienhuys <hanwen@google.com>
>
> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
> ---
> t/t1401-symbolic-ref.sh | 23 +++++++++--------------
> 1 file changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh
> index a4ebb0b65fec..fd5980d3fb40 100755
> --- a/t/t1401-symbolic-ref.sh
> +++ b/t/t1401-symbolic-ref.sh
> @@ -7,18 +7,13 @@ test_description='basic symbolic-ref tests'
> # the git repo, meaning that further tests will operate on
> # the surrounding git repo instead of the trash directory.
> reset_to_sane() {
> - echo ref: refs/heads/foo >.git/HEAD
> + git --git-dir .git symbolic-ref HEAD refs/heads/foo
> }
>
> -test_expect_success 'symbolic-ref writes HEAD' '
> - git symbolic-ref HEAD refs/heads/foo &&
> - echo ref: refs/heads/foo >expect &&
> - test_cmp expect .git/HEAD
> -'
> -
> -test_expect_success 'symbolic-ref reads HEAD' '
> - echo refs/heads/foo >expect &&
> - git symbolic-ref HEAD >actual &&
> +test_expect_success 'symbolic-ref read/write roundtrip' '
> + git symbolic-ref HEAD refs/heads/read-write-roundtrip &&
> + echo refs/heads/read-write-roundtrip > expect &&
> + git symbolic-ref HEAD > actual &&Style nit: no space between redirection and filename, i.e. these should be '>expect' and '>actual'.
Show 11 quoted lines
> test_cmp expect actual > ' > > @@ -42,16 +37,16 @@ reset_to_sane > test_expect_success 'symbolic-ref can be deleted' ' > git symbolic-ref NOTHEAD refs/heads/foo && > git symbolic-ref -d NOTHEAD && > - test_path_is_file .git/refs/heads/foo && > - test_path_is_missing .git/NOTHEAD > + git rev-parse refs/heads/foo && > + ! git symbolic-ref NOTHEAD
Please use 'test_must_fail git ...', because otherwise a segfault could go unnoticed.
Show 16 quoted lines
> ' > reset_to_sane > > test_expect_success 'symbolic-ref can delete dangling symref' ' > git symbolic-ref NOTHEAD refs/heads/missing && > git symbolic-ref -d NOTHEAD && > - test_path_is_missing .git/refs/heads/missing && > - test_path_is_missing .git/NOTHEAD > + ! git rev-parse refs/heads/missing && > + ! git symbolic-ref NOTHEAD > ' > reset_to_sane > > -- > gitgitgadget >