Re: [PATCH v5 5/7] refs: use transaction in `refs_create_symref()`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- May 2, 2024, 07:47 UTC
- Message-ID
- <ZjNFEHA9QgQlMl5F@tanuki>
- In-Reply-To
- <20240501202229.2695774-6-knayak@gitlab.com>
On Wed, May 01, 2024 at 10:22:27PM +0200, Karthik Nayak wrote:
Show 9 quoted lines
> From: Karthik Nayak <karthik.188@gmail.com> > > The `refs_create_symref()` function updates a symref to a given new > target. To do this, it uses a ref-backend specific function > `create_symref()`. > > In this previous commit, we introduce symref support in transactions. > This means we can now use transactions to perform symref updates and not > have to resort to `create_symref()`. Doing this allows us to remove and
Nit: "not have to" -> "don't have to"
[snip]
Show 13 quoted lines
> diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh
> index 178791e086..9e8d22bcbd 100755
> --- a/t/t0610-reftable-basics.sh
> +++ b/t/t0610-reftable-basics.sh
> @@ -286,7 +286,7 @@ test_expect_success 'ref transaction: creating symbolic ref fails with F/D confl
> git init repo &&
> test_commit -C repo A &&
> cat >expect <<-EOF &&
> - error: unable to write symref for refs/heads: file/directory conflict
> + error: ${SQ}refs/heads/main${SQ} exists; cannot create ${SQ}refs/heads${SQ}
> EOF
> test_must_fail git -C repo symbolic-ref refs/heads refs/heads/foo 2>err &&
> test_cmp expect errNice. Not only do we have less code to worry about, but the error message is better, too.
Show 27 quoted lines
> diff --git a/t/t1416-ref-transaction-hooks.sh b/t/t1416-ref-transaction-hooks.sh > index 2092488090..4433ac2177 100755 > --- a/t/t1416-ref-transaction-hooks.sh > +++ b/t/t1416-ref-transaction-hooks.sh > @@ -134,4 +134,27 @@ test_expect_success 'interleaving hook calls succeed' ' > test_cmp expect target-repo.git/actual > ' > > +test_expect_success 'hook captures git-symbolic-ref updates' ' > + test_when_finished "rm actual" && > + > + test_hook reference-transaction <<-\EOF && > + echo "$*" >>actual > + while read -r line > + do > + printf "%s\n" "$line" > + done >>actual > + EOF > + > + git symbolic-ref refs/heads/symref refs/heads/main && > + > + cat >expect <<-EOF && > + prepared > + $ZERO_OID ref:refs/heads/main refs/heads/symref > + committed > + $ZERO_OID ref:refs/heads/main refs/heads/symref > + EOF
Nit: the contents of the heredoc should be indented one level less.
Patrick