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

Re: [PATCH v2 05/24] refs: update ref transactions to use struct object_id

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 9, 2017, 23:13 UTC
Message-ID
<20171009231304.GI19555@aiede.mtv.corp.google.com>
In-Reply-To
<20171009011132.675341-6-sandals@crustytoothpaste.net>
brian m. carlson wrote:
Show 23 quoted lines
> Update the ref transaction code to use struct object_id.  Remove one
> NULL pointer check which was previously inserted around a dereference;
> since we now pass a pointer to struct object_id directly through, the
> code we're calling handles this for us.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
>  branch.c               |  2 +-
>  builtin/clone.c        |  2 +-
>  builtin/commit.c       |  4 ++--
>  builtin/fetch.c        |  4 ++--
>  builtin/receive-pack.c |  4 ++--
>  builtin/replace.c      |  2 +-
>  builtin/tag.c          |  2 +-
>  builtin/update-ref.c   |  8 ++++----
>  fast-import.c          |  4 ++--
>  refs.c                 | 44 +++++++++++++++++++++-----------------------
>  refs.h                 | 24 ++++++++++++------------
>  refs/files-backend.c   | 12 ++++++------
>  refs/refs-internal.h   |  4 ++--
>  sequencer.c            |  2 +-
>  walker.c               |  2 +-
>  15 files changed, 59 insertions(+), 61 deletions(-)
Makes sense.
[...]
> +++ b/refs.c
[...]
Show 10 quoted lines
>  int ref_transaction_create(struct ref_transaction *transaction,
>  			   const char *refname,
> -			   const unsigned char *new_sha1,
> +			   const struct object_id *new_oid,
>  			   unsigned int flags, const char *msg,
>  			   struct strbuf *err)
>  {
> -	if (!new_sha1 || is_null_sha1(new_sha1))
> +	if (!new_oid || is_null_oid(new_oid))
>  		die("BUG: create called without valid new_sha1");
The error message still refers to new_sha1.
[...]
Show 10 quoted lines
>  int ref_transaction_delete(struct ref_transaction *transaction,
>  			   const char *refname,
> -			   const unsigned char *old_sha1,
> +			   const struct object_id *old_oid,
>  			   unsigned int flags, const char *msg,
>  			   struct strbuf *err)
>  {
> -	if (old_sha1 && is_null_sha1(old_sha1))
> +	if (old_oid && is_null_oid(old_oid))
>  		die("BUG: delete called with old_sha1 set to zeros");
Likewise.
[...]
Show 10 quoted lines
>  int ref_transaction_verify(struct ref_transaction *transaction,
>  			   const char *refname,
> -			   const unsigned char *old_sha1,
> +			   const struct object_id *old_oid,
>  			   unsigned int flags,
>  			   struct strbuf *err)
>  {
> -	if (!old_sha1)
> +	if (!old_oid)
>  		die("BUG: verify called with old_sha1 set to NULL");
Likewise.
[...]
> +++ b/refs.h
> @@ -519,15 +519,15 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err);
[...]
Show 11 quoted lines
>  /*
> - * Add a reference creation to transaction. new_sha1 is the value that
> + * Add a reference creation to transaction. new_oid is the value that
>   * the reference should have after the update; it must not be
> - * null_sha1. It is verified that the reference does not exist
> + * null_oid. It is verified that the reference does not exist
>   * already.
>   *
>   * See the above comment "Reference transaction updates" for more
> @@ -535,35 +535,35 @@ int ref_transaction_update(struct ref_transaction *transaction,
>   */

(Possible diff generation bug: there's exactly one line represented in that @@ field. I would have expected the diff generator to combine the hunks.)

I think this is fine to go in without the error messages being fixed. A grep for 'sha1' will find them later so that they can be addressed in a separate patch.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Previous: brian m. carlsonNext: Michael Haggerty
Message 43 of 53 in “object_id part 10”
  1. 00/24 object_id part 10brian m. carlson, Oct 9, 2017
  2. 01/24 walker: convert to struct object_idbrian m. carlson, Oct 9, 2017
  3. Jonathan NiederOct 9, 2017
  4. 03/24 refs: convert delete_ref and refs_delete_ref to struct object_idbrian m. carlson, Oct 9, 2017
  5. Jonathan NiederOct 9, 2017
  6. 02/24 refs/files-backend: convert struct ref_to_prune to object_idbrian m. carlson, Oct 9, 2017
  7. Jonathan NiederOct 9, 2017
  8. 04/24 refs: convert update_ref and refs_update_ref to use struct object_idbrian m. carlson, Oct 9, 2017
  9. Jonathan NiederOct 9, 2017
  10. Michael HaggertyOct 11, 2017
  11. brian m. carlsonOct 12, 2017
  12. 10/24 builtin/reflog: convert remaining unsigned char uses to object_idbrian m. carlson, Oct 9, 2017
  13. Jonathan NiederOct 10, 2017
  14. 09/24 refs: convert dwim_ref and expand_ref to struct object_idbrian m. carlson, Oct 9, 2017
  15. Jonathan NiederOct 10, 2017
  16. 12/24 pack-bitmap: convert traverse_bitmap_commit_list to object_idbrian m. carlson, Oct 9, 2017
  17. Jonathan NiederOct 10, 2017
  18. 18/24 Convert remaining callers of resolve_gitlink_ref to object_idbrian m. carlson, Oct 9, 2017
  19. 21/24 refs: convert resolve_ref_unsafe to struct object_idbrian m. carlson, Oct 9, 2017
  20. Michael HaggertyOct 11, 2017
  21. 24/24 refs/files-backend: convert static functions to object_idbrian m. carlson, Oct 9, 2017
  22. Michael HaggertyOct 11, 2017
  23. 22/24 refs: convert peel_object to struct object_idbrian m. carlson, Oct 9, 2017
  24. 23/24 refs: convert read_raw_ref backends to struct object_idbrian m. carlson, Oct 9, 2017
  25. Michael HaggertyOct 11, 2017
  26. 19/24 refs: convert resolve_gitlink_ref to struct object_idbrian m. carlson, Oct 9, 2017
  27. 20/24 worktree: convert struct worktree to object_idbrian m. carlson, Oct 9, 2017
  28. 15/24 refs: convert read_ref_at to struct object_idbrian m. carlson, Oct 9, 2017
  29. 14/24 refs: convert peel_ref to struct object_idbrian m. carlson, Oct 9, 2017
  30. Michael HaggertyOct 11, 2017
  31. 17/24 sha1_file: convert index_path and index_fd to struct object_idbrian m. carlson, Oct 9, 2017
  32. 13/24 builtin/pack-objects: convert to struct object_idbrian m. carlson, Oct 9, 2017
  33. Jonathan NiederOct 10, 2017
  34. 16/24 refs: convert reflog_expire parameter to struct object_idbrian m. carlson, Oct 9, 2017
  35. 08/24 refs: convert read_ref and read_ref_full to object_idbrian m. carlson, Oct 9, 2017
  36. Jonathan NiederOct 10, 2017
  37. 11/24 refs: convert dwim_log to struct object_idbrian m. carlson, Oct 9, 2017
  38. Jonathan NiederOct 10, 2017
  39. 07/24 refs: convert resolve_refdup and refs_resolve_refdup to struct object_idbrian m. carlson, Oct 9, 2017
  40. Jonathan NiederOct 9, 2017
  41. Junio C HamanoOct 10, 2017
  42. 05/24 refs: update ref transactions to use struct object_idbrian m. carlson, Oct 9, 2017
  43. Jonathan NiederOct 9, 2017
  44. Michael HaggertyOct 11, 2017
  45. 06/24 Convert check_connected to use struct object_idbrian m. carlson, Oct 9, 2017
  46. Jonathan NiederOct 9, 2017
  47. Stefan BellerOct 9, 2017
  48. Junio C HamanoOct 9, 2017
  49. Michael HaggertyOct 11, 2017
  50. Junio C HamanoOct 11, 2017
  51. brian m. carlsonOct 12, 2017
  52. Junio C HamanoOct 12, 2017
  53. brian m. carlsonOct 12, 2017

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.