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

Re: [PATCH v4 5/8] refs: introduce enum-based transaction error types

From
Karthik Nayak <karthik.188@gmail.com>
Date
Mar 24, 2025, 14:50 UTC
Message-ID
<CAOLa=ZRM8EeeVXpZFpLU7Wg8k98_U+0hw1y63gQDjPEfR2P2cw@mail.gmail.com>
In-Reply-To
<Z9x578gHJQPCYU4v@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 36 quoted lines
> On Thu, Mar 20, 2025 at 12:44:00PM +0100, Karthik Nayak wrote:
>> diff --git a/refs.h b/refs.h
>> index 240e2d8537..dcd83e81e2 100644
>> --- a/refs.h
>> +++ b/refs.h
>> @@ -16,6 +16,29 @@ struct worktree;
>>  enum ref_storage_format ref_storage_format_by_name(const char *name);
>>  const char *ref_storage_format_to_name(enum ref_storage_format ref_storage_format);
>>
>> +/*
>> + * enum ref_transaction_error represents the following return codes:
>> + * REF_TRANSACTION_ERROR_GENERIC error_code: default error code.
>> + * REF_TRANSACTION_ERROR_NAME_CONFLICT error_code: ref name conflict like A vs A/B.
>> + * REF_TRANSACTION_ERROR_CREATE_EXISTS error_code: ref to be created already exists.
>> + * REF_TRANSACTION_ERROR_NONEXISTENT_REF error_code: ref expected but doesn't exist.
>> + * REF_TRANSACTION_ERROR_INCORRECT_OLD_VALUE error_code: provided old_oid or old_target of
>> + * reference doesn't match actual.
>> + * REF_TRANSACTION_ERROR_INVALID_NEW_VALUE error_code: provided new_oid or new_target is
>> + * invalid.
>> + * REF_TRANSACTION_ERROR_EXPECTED_SYMREF error_code: expected ref to be symref, but is a
>> + * regular ref.
>> + */
>> +enum ref_transaction_error {
>> +	REF_TRANSACTION_ERROR_GENERIC = -1,
>> +	REF_TRANSACTION_ERROR_NAME_CONFLICT = -2,
>> +	REF_TRANSACTION_ERROR_CREATE_EXISTS = -3,
>> +	REF_TRANSACTION_ERROR_NONEXISTENT_REF = -4,
>> +	REF_TRANSACTION_ERROR_INCORRECT_OLD_VALUE = -5,
>> +	REF_TRANSACTION_ERROR_INVALID_NEW_VALUE = -6,
>> +	REF_TRANSACTION_ERROR_EXPECTED_SYMREF = -7,
>> +};
>> +
>
> Tiny nit: I think it's generally preferable to document each specific
> right next to its definition.
>

Idk about this, I based it off on `enum bisect_error` which is similar, but I also see the same in `enum scld_error`.

I'm okay to change this though, perhaps makes sense to document the preferred style however.

> Patrick
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 11 of 19 in “refs: introduce support for batched reference updates”
  1. 0/8 refs: introduce support for batched reference updatesKarthik Nayak, Mar 20, 2025
  2. 1/8 refs/files: remove redundant check in split_symref_update()Karthik Nayak, Mar 20, 2025
  3. 2/8 refs: move duplicate refname update check to generic layerKarthik Nayak, Mar 20, 2025
  4. 3/8 refs/files: remove duplicate duplicates checkKarthik Nayak, Mar 20, 2025
  5. 4/8 refs/reftable: extract code from the transaction preparationKarthik Nayak, Mar 20, 2025
  6. 6/8 refs: implement batch reference update supportKarthik Nayak, Mar 20, 2025
  7. Patrick SteinhardtMar 20, 2025
  8. Karthik NayakMar 24, 2025
  9. 5/8 refs: introduce enum-based transaction error typesKarthik Nayak, Mar 20, 2025
  10. Patrick SteinhardtMar 20, 2025
  11. Karthik NayakMar 24, 2025
  12. Patrick SteinhardtMar 25, 2025
  13. 7/8 refs: support rejection in batch updates during F/D checksKarthik Nayak, Mar 20, 2025
  14. Patrick SteinhardtMar 24, 2025
  15. Karthik NayakMar 24, 2025
  16. Patrick SteinhardtMar 25, 2025
  17. 8/8 update-ref: add --batch-updates flag for stdin modeKarthik Nayak, Mar 20, 2025
  18. Patrick SteinhardtMar 24, 2025
  19. Karthik NayakMar 24, 2025

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.