From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH v3 3/6] update-ref: add support for 'symref-delete' command
Date: Wed, 5 Jun 2024 10:02:08 +0200 [thread overview]
Message-ID: <ZmAbgGfNpZzU76pd@tanuki> (raw)
In-Reply-To: <20240530120940.456817-4-knayak@gitlab.com>
[-- Attachment #1: Type: text/plain, Size: 4052 bytes --]
On Thu, May 30, 2024 at 03:09:37PM +0300, Karthik Nayak wrote:
> diff --git a/refs.c b/refs.c
> index cdc4d25557..e29abebe1d 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -950,7 +950,7 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,
> transaction = ref_store_transaction_begin(refs, &err);
> if (!transaction ||
> ref_transaction_delete(transaction, refname, old_oid,
> - flags, msg, &err) ||
> + flags, NULL, msg, &err) ||
> ref_transaction_commit(transaction, &err)) {
> error("%s", err.buf);
> ref_transaction_free(transaction);
> @@ -1283,14 +1283,20 @@ int ref_transaction_create(struct ref_transaction *transaction,
> int ref_transaction_delete(struct ref_transaction *transaction,
> const char *refname,
> const struct object_id *old_oid,
> - unsigned int flags, const char *msg,
> + unsigned int flags,
> + const char *old_target,
The old target is somewhat weirdly placed here, as I'd have expected it
to live next to `old_oid`. That's only a minor nit, nothing that's worth
a reroll in my opinion.
> diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
> index 52801be07d..848d6fc42e 100755
> --- a/t/t1400-update-ref.sh
> +++ b/t/t1400-update-ref.sh
> @@ -1731,6 +1731,60 @@ do
> test_cmp expect actual
> '
>
> + test_expect_success "stdin $type symref-delete fails without --no-deref" '
> + git symbolic-ref refs/heads/symref $a &&
> + format_command $type "symref-delete refs/heads/symref" "$a" >stdin &&
> + test_must_fail git update-ref --stdin $type <stdin 2>err &&
> + grep "fatal: symref-delete: cannot operate with deref mode" err
> + '
> +
> + test_expect_success "stdin $type symref-delete fails with no ref" '
> + format_command $type "symref-delete " >stdin &&
> + test_must_fail git update-ref --stdin $type --no-deref <stdin 2>err &&
> + grep "fatal: symref-delete: missing <ref>" err
> + '
> +
> + test_expect_success "stdin $type symref-delete fails with too many arguments" '
> + format_command $type "symref-delete refs/heads/symref" "$a" "$a" >stdin &&
> + test_must_fail git update-ref --stdin $type --no-deref <stdin 2>err &&
> + if test "$type" = "-z"
> + then
> + grep "fatal: unknown command: $a" err
> + else
> + grep "fatal: symref-delete refs/heads/symref: extra input: $a" err
> + fi
> + '
> +
> + test_expect_success "stdin $type symref-delete fails with wrong old value" '
> + format_command $type "symref-delete refs/heads/symref" "$m" >stdin &&
> + test_must_fail git update-ref --stdin $type --no-deref <stdin 2>err &&
> + grep "fatal: verifying symref target: ${SQ}refs/heads/symref${SQ}: is at $a but expected refs/heads/main" err &&
> + git symbolic-ref refs/heads/symref >expect &&
> + echo $a >actual &&
> + test_cmp expect actual
> + '
> +
> + test_expect_success "stdin $type symref-delete works with right old value" '
> + format_command $type "symref-delete refs/heads/symref" "$a" >stdin &&
> + git update-ref --stdin $type --no-deref <stdin &&
> + test_must_fail git rev-parse --verify -q refs/heads/symref
> + '
> +
> + test_expect_success "stdin $type symref-delete works with empty old value" '
> + git symbolic-ref refs/heads/symref $a >stdin &&
> + format_command $type "symref-delete refs/heads/symref" "" >stdin &&
> + git update-ref --stdin $type --no-deref <stdin &&
> + test_must_fail git rev-parse --verify -q $b
> + '
> +
> + test_expect_success "stdin $type symref-delete succeeds for dangling reference" '
> + test_must_fail git symbolic-ref refs/heads/nonexistent &&
> + git symbolic-ref refs/heads/symref2 refs/heads/nonexistent &&
> + format_command $type "symref-delete refs/heads/symref2" "refs/heads/nonexistent" >stdin &&
> + git update-ref --stdin $type --no-deref <stdin &&
> + test_must_fail git symbolic-ref -d refs/heads/symref2
> + '
> +
Not sure whether I overlooked it, but one test I missed was when trying
to delete a non-symbolic-ref.
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-06-05 8:02 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-14 12:44 [PATCH 0/6] update-ref: add symref support for --stdin Karthik Nayak
2024-05-14 12:44 ` [PATCH 1/6] refs: create and use `ref_update_ref_must_exist()` Karthik Nayak
2024-05-16 11:09 ` Patrick Steinhardt
2024-05-17 13:08 ` Karthik Nayak
2024-05-14 12:44 ` [PATCH 2/6] update-ref: add support for 'symref-verify' command Karthik Nayak
2024-05-16 11:09 ` Patrick Steinhardt
2024-05-17 16:21 ` Karthik Nayak
2024-05-21 6:41 ` Patrick Steinhardt
2024-05-14 12:44 ` [PATCH 3/6] update-ref: add support for 'symref-delete' command Karthik Nayak
2024-05-16 11:09 ` Patrick Steinhardt
2024-05-14 12:44 ` [PATCH 4/6] update-ref: add support for 'symref-create' command Karthik Nayak
2024-05-16 11:09 ` Patrick Steinhardt
2024-05-19 14:01 ` Karthik Nayak
2024-05-14 12:44 ` [PATCH 5/6] reftable: pick either 'oid' or 'target' for new updates Karthik Nayak
2024-05-14 12:44 ` [PATCH 6/6] update-ref: add support for 'symref-update' command Karthik Nayak
2024-05-16 11:09 ` Patrick Steinhardt
2024-05-21 9:49 ` Karthik Nayak
2024-05-22 7:59 ` Karthik Nayak
2024-05-22 9:03 ` [PATCH v2 0/6] update-ref: add symref support for --stdin Karthik Nayak
2024-05-22 9:03 ` [PATCH v2 1/6] refs: create and use `ref_update_expects_existing_old_ref()` Karthik Nayak
2024-05-22 9:03 ` [PATCH v2 2/6] update-ref: add support for 'symref-verify' command Karthik Nayak
2024-05-22 9:03 ` [PATCH v2 3/6] update-ref: add support for 'symref-delete' command Karthik Nayak
2024-05-22 9:03 ` [PATCH v2 4/6] update-ref: add support for 'symref-create' command Karthik Nayak
2024-05-22 9:03 ` [PATCH v2 5/6] reftable: pick either 'oid' or 'target' for new updates Karthik Nayak
2024-05-22 9:03 ` [PATCH v2 6/6] update-ref: add support for 'symref-update' command Karthik Nayak
2024-05-25 23:00 ` Junio C Hamano
2024-05-29 8:29 ` Karthik Nayak
2024-05-23 15:02 ` [PATCH v2 0/6] update-ref: add symref support for --stdin Junio C Hamano
2024-05-23 15:52 ` Karthik Nayak
2024-05-23 16:29 ` Junio C Hamano
2024-05-23 17:50 ` Karthik Nayak
2024-05-23 17:59 ` Eric Sunshine
2024-05-23 18:08 ` Junio C Hamano
2024-05-23 18:50 ` Eric Sunshine
2024-05-23 19:06 ` Junio C Hamano
2024-05-23 21:46 ` Junio C Hamano
2024-05-23 16:03 ` Junio C Hamano
2024-05-30 12:09 ` [PATCH v3 " Karthik Nayak
2024-06-05 8:02 ` Patrick Steinhardt
2024-05-30 12:09 ` [PATCH v3 1/6] refs: create and use `ref_update_expects_existing_old_ref()` Karthik Nayak
2024-05-30 12:09 ` [PATCH v3 2/6] update-ref: add support for 'symref-verify' command Karthik Nayak
2024-05-30 12:09 ` [PATCH v3 3/6] update-ref: add support for 'symref-delete' command Karthik Nayak
2024-06-05 8:02 ` Patrick Steinhardt [this message]
2024-06-05 9:31 ` Karthik Nayak
2024-06-05 16:22 ` Junio C Hamano
2024-05-30 12:09 ` [PATCH v3 4/6] update-ref: add support for 'symref-create' command Karthik Nayak
2024-06-05 8:02 ` Patrick Steinhardt
2024-05-30 12:09 ` [PATCH v3 5/6] reftable: pick either 'oid' or 'target' for new updates Karthik Nayak
2024-05-30 12:09 ` [PATCH v3 6/6] update-ref: add support for 'symref-update' command Karthik Nayak
2024-06-05 8:02 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZmAbgGfNpZzU76pd@tanuki \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karthik.188@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).