git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 6/7] reftable: pick either 'oid' or 'target' for new updates

From
Karthik Nayak <karthik.188@gmail.com>
Date
Jun 5, 2024, 10:29 UTC
Message-ID
<20240605102958.716432-7-knayak@gitlab.com>
In-Reply-To
<https://lore.kernel.org/r/20240530120940.456817-1-knayak@gitlab.com>
From: Karthik Nayak <karthik.188@gmail.com>

When creating a reference transaction update, we can provide the old/new oid/target for the update. We have checks in place to ensure that for each old/new, either oid or target is set and not both.

In the reftable backend, when dealing with updates without the `REF_NO_DEREF` flag, we don't selectively propagate data as needed. Since there are no active users of the path, this is not caught. As we want to introduce the 'symref-update' command in the upcoming commit, which would use this flow, correct it.

Helped-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 refs/reftable-backend.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index bd89ce8d76..fee7a9904b 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -895,8 +895,9 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
 				 */
 				new_update = ref_transaction_add_update(
 					transaction, referent.buf, new_flags,
-					&u->new_oid, &u->old_oid, u->new_target,
-					u->old_target, u->msg);
+					u->new_target ? NULL : &u->new_oid,
+					u->old_target ? NULL : &u->old_oid,
+					u->new_target, u->old_target, u->msg);
 
 				new_update->parent_update = u;
 
-- 
2.43.GIT
Previous: Karthik NayakNext: Karthik Nayak
Message 21 of 22 in “update-ref: add symref support for --stdin”
  1. 0/7 update-ref: add symref support for --stdinKarthik Nayak, Jun 5, 2024
  2. Karthik NayakJun 6, 2024
  3. Karthik NayakJun 6, 2024
  4. 0/7 update-ref: add symref support for --stdinKarthik Nayak, Jun 7, 2024
  5. 1/7 refs: create and use `ref_update_expects_existing_old_ref()`Karthik Nayak, Jun 7, 2024
  6. 2/7 refs: specify error for regular refs with `old_target`Karthik Nayak, Jun 7, 2024
  7. Patrick SteinhardtJun 10, 2024
  8. Karthik NayakJun 10, 2024
  9. 3/7 update-ref: add support for 'symref-verify' commandKarthik Nayak, Jun 7, 2024
  10. 4/7 update-ref: add support for 'symref-delete' commandKarthik Nayak, Jun 7, 2024
  11. 5/7 update-ref: add support for 'symref-create' commandKarthik Nayak, Jun 7, 2024
  12. 6/7 reftable: pick either 'oid' or 'target' for new updatesKarthik Nayak, Jun 7, 2024
  13. 7/7 update-ref: add support for 'symref-update' commandKarthik Nayak, Jun 7, 2024
  14. 1/7 refs: create and use `ref_update_expects_existing_old_ref()`Karthik Nayak, Jun 5, 2024
  15. 2/7 refs: specify error for regular refs with `old_target`Karthik Nayak, Jun 5, 2024
  16. Patrick SteinhardtJun 6, 2024
  17. Karthik NayakJun 6, 2024
  18. 3/7 update-ref: add support for 'symref-verify' commandKarthik Nayak, Jun 5, 2024
  19. 4/7 update-ref: add support for 'symref-delete' commandKarthik Nayak, Jun 5, 2024
  20. 5/7 update-ref: add support for 'symref-create' commandKarthik Nayak, Jun 5, 2024
  21. 6/7 reftable: pick either 'oid' or 'target' for new updatesKarthik Nayak, Jun 5, 2024
  22. 7/7 update-ref: add support for 'symref-update' commandKarthik Nayak, Jun 5, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.