Re: [PATCH v13 02/13] t: use update-ref and show-ref to reading/writing refs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 18, 2020, 23:34 UTC
- Message-ID
- <xmqq8sho24y7.fsf@gitster.c.googlers.com>
- In-Reply-To
- <dbf45fe8753c5782f1d1d87d2da47bf72b086506.1589226388.git.gitgitgadget@gmail.com>
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 37 quoted lines
> From: Han-Wen Nienhuys <hanwen@google.com> > > Reading and writing .git/refs/* assumes that refs are stored in the 'files' > ref backend. > > Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> > --- > t/t0002-gitfile.sh | 2 +- > t/t1400-update-ref.sh | 32 ++++++++++++++++---------------- > t/t1506-rev-parse-diagnosis.sh | 2 +- > t/t6050-replace.sh | 2 +- > t/t9020-remote-svn.sh | 4 ++-- > 5 files changed, 21 insertions(+), 21 deletions(-) > > diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh > index 0aa9908ea12..960ed150cb5 100755 > --- a/t/t0002-gitfile.sh > +++ b/t/t0002-gitfile.sh > @@ -62,7 +62,7 @@ test_expect_success 'check commit-tree' ' > ' > > test_expect_success 'check rev-list' ' > - echo $SHA >"$REAL/HEAD" && > + git update-ref "HEAD" "$SHA" && > test "$SHA" = "$(git rev-list HEAD)" > ' > > diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh > index e1197ac8189..27171f82612 100755 > --- a/t/t1400-update-ref.sh > +++ b/t/t1400-update-ref.sh > @@ -37,15 +37,15 @@ test_expect_success setup ' > > test_expect_success "create $m" ' > git update-ref $m $A && > - test $A = $(cat .git/$m) > + test $A = $(git show-ref -s --verify $m)
All of the above looks good. These were written long time ago, and we should have cleaned them up much earlier, but we didn't.
Show 11 quoted lines
> diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
> index 52edcbdcc32..dbf690b9c1b 100755
> --- a/t/t1506-rev-parse-diagnosis.sh
> +++ b/t/t1506-rev-parse-diagnosis.sh
> @@ -207,7 +207,7 @@ test_expect_success 'arg before dashdash must be a revision (ambiguous)' '
> {
> # we do not want to use rev-parse here, because
> # we are testing it
> - cat .git/refs/heads/foobar &&
> + git show-ref -s refs/heads/foobar &&
> printf "%s\n" --Likewise.
Show 12 quoted lines
> } >expect && > git rev-parse foobar -- >actual && > diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh > index e7e64e085dd..c80dc10b8f1 100755 > --- a/t/t6050-replace.sh > +++ b/t/t6050-replace.sh > @@ -135,7 +135,7 @@ test_expect_success 'tag replaced commit' ' > test_expect_success '"git fsck" works' ' > git fsck master >fsck_master.out && > test_i18ngrep "dangling commit $R" fsck_master.out && > - test_i18ngrep "dangling tag $(cat .git/refs/tags/mytag)" fsck_master.out && > + test_i18ngrep "dangling tag $(git show-ref -s refs/tags/mytag)" fsck_master.out &&
Likewise; this has no excuse of being old code ;-)
Show 16 quoted lines
> test -z "$(git fsck)" > ' > > diff --git a/t/t9020-remote-svn.sh b/t/t9020-remote-svn.sh > index 6fca08e5e35..9fcfa969a9b 100755 > --- a/t/t9020-remote-svn.sh > +++ b/t/t9020-remote-svn.sh > @@ -48,8 +48,8 @@ test_expect_success REMOTE_SVN 'simple fetch' ' > ' > > test_debug ' > - cat .git/refs/svn/svnsim/master > - cat .git/refs/remotes/svnsim/master > + git show-ref -s refs/svn/svnsim/master > + git show-ref -s refs/remotes/svnsim/master > '
Looks good.
Thanks.