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

Re: [PATCH 3/7] reftable/system: stop depending on "hash.h"

From
Justin Tobler <jltobler@gmail.com>
Date
Nov 8, 2024, 01:10 UTC
Message-ID
<hhlsmyyqt2y6ue3abnlwjmrmsslewwjcoiu44aadp6nqkscict@m55ip4ibqgoq>
In-Reply-To
<b595668a5cdae0dff4a7271a3547c5821aa6e912.1729677003.git.ps@pks.im>
On 24/10/23 11:56AM, Patrick Steinhardt wrote:
Show 27 quoted lines
> diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
> index 3c6107c7ce5..7d86d920970 100644
> --- a/refs/reftable-backend.c
> +++ b/refs/reftable-backend.c
> @@ -15,6 +15,7 @@
>  #include "../object.h"
>  #include "../path.h"
>  #include "../refs.h"
> +#include "../reftable/reftable-basics.h"
>  #include "../reftable/reftable-stack.h"
>  #include "../reftable/reftable-record.h"
>  #include "../reftable/reftable-error.h"
> @@ -289,7 +290,16 @@ static struct ref_store *reftable_be_init(struct repository *repo,
>  	refs->store_flags = store_flags;
>  	refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
>  
> -	refs->write_options.hash_id = repo->hash_algo->format_id;
> +	switch (repo->hash_algo->format_id) {
> +	case GIT_SHA1_FORMAT_ID:
> +		refs->write_options.hash_id = REFTABLE_HASH_SHA1;
> +		break;
> +	case GIT_SHA256_FORMAT_ID:
> +		refs->write_options.hash_id = REFTABLE_HASH_SHA256;
> +		break;
> +	default:
> +		BUG("unknown hash algorithm %d", repo->hash_algo->format_id);
> +	}

Here we define the mapping between the Git's format ID and the reftable hash external to the reftable library. This facilitates swapping uses of `GIT_*_FORMAT_ID` to `REFTABLE_HASH_*` as done in the rest of the patch which looks good.

>  	refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
>  	refs->write_options.disable_auto_compact =
>  		!git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);
[snip]
Show 9 quoted lines
> diff --git a/reftable/merged.h b/reftable/merged.h
> index 89bd0c4b35b..13a5fe4154e 100644
> --- a/reftable/merged.h
> +++ b/reftable/merged.h
> @@ -10,11 +10,12 @@ license that can be found in the LICENSE file or at
>  #define MERGED_H
>  
>  #include "system.h"
> +#include "basics.h"

Naive question, being that "merged.h" only depends on `reftable-basics.h:reftable_hash` and not any of the internal reftable basics components, would it be best to instead reference it directly? Or because "merged.h" is also internal do we also prefer to use the internal "basics.h"?

Probably doesn't really matter, but I was just curious if there was any reasoning. :)

-Justin
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 7 of 43 in “reftable: stop using Git subsystems”
  1. 0/7 reftable: stop using Git subsystemsPatrick Steinhardt, Oct 23, 2024
  2. 1/7 reftable/system: move "dir.h" to its only userPatrick Steinhardt, Oct 23, 2024
  3. Eric SunshineOct 24, 2024
  4. 2/7 reftable: explicitly handle hash format IDsPatrick Steinhardt, Oct 23, 2024
  5. Justin ToblerNov 7, 2024
  6. 3/7 reftable/system: stop depending on "hash.h"Patrick Steinhardt, Oct 23, 2024
  7. Justin ToblerNov 8, 2024
  8. Patrick SteinhardtNov 8, 2024
  9. 4/7 reftable/stack: stop using `fsync_component()` directlyPatrick Steinhardt, Oct 23, 2024
  10. Justin ToblerNov 8, 2024
  11. Patrick SteinhardtNov 8, 2024
  12. 5/7 reftable/system: provide thin wrapper for tempfile subsystemPatrick Steinhardt, Oct 23, 2024
  13. 6/7 reftable/stack: drop only use of `get_locked_file_path()`Patrick Steinhardt, Oct 23, 2024
  14. 7/7 reftable/system: provide thin wrapper for lockfile subsystemPatrick Steinhardt, Oct 23, 2024
  15. 0/7 reftable: stop using Git subsystemsPatrick Steinhardt, Nov 8, 2024
  16. 1/7 reftable/system: move "dir.h" to its only userPatrick Steinhardt, Nov 8, 2024
  17. 2/7 reftable: explicitly handle hash format IDsPatrick Steinhardt, Nov 8, 2024
  18. karthik nayakNov 18, 2024
  19. 3/7 reftable/system: stop depending on "hash.h"Patrick Steinhardt, Nov 8, 2024
  20. Junio C HamanoNov 12, 2024
  21. karthik nayakNov 18, 2024
  22. 4/7 reftable/stack: stop using `fsync_component()` directlyPatrick Steinhardt, Nov 8, 2024
  23. karthik nayakNov 18, 2024
  24. Patrick SteinhardtNov 18, 2024
  25. 5/7 reftable/system: provide thin wrapper for tempfile subsystemPatrick Steinhardt, Nov 8, 2024
  26. karthik nayakNov 18, 2024
  27. karthik nayakNov 18, 2024
  28. 6/7 reftable/stack: drop only use of `get_locked_file_path()`Patrick Steinhardt, Nov 8, 2024
  29. 7/7 reftable/system: provide thin wrapper for lockfile subsystemPatrick Steinhardt, Nov 8, 2024
  30. Justin ToblerNov 8, 2024
  31. Junio C HamanoNov 11, 2024
  32. karthik nayakNov 18, 2024
  33. Patrick SteinhardtNov 18, 2024
  34. 0/7 reftable: stop using Git subsystemsPatrick Steinhardt, Nov 18, 2024
  35. 1/7 reftable/system: move "dir.h" to its only userPatrick Steinhardt, Nov 18, 2024
  36. 2/7 reftable: explicitly handle hash format IDsPatrick Steinhardt, Nov 18, 2024
  37. 3/7 reftable/system: stop depending on "hash.h"Patrick Steinhardt, Nov 18, 2024
  38. 4/7 reftable/stack: stop using `fsync_component()` directlyPatrick Steinhardt, Nov 18, 2024
  39. 5/7 reftable/system: provide thin wrapper for tempfile subsystemPatrick Steinhardt, Nov 18, 2024
  40. 6/7 reftable/stack: drop only use of `get_locked_file_path()`Patrick Steinhardt, Nov 18, 2024
  41. 7/7 reftable/system: provide thin wrapper for lockfile subsystemPatrick Steinhardt, Nov 18, 2024
  42. karthik nayakNov 19, 2024
  43. Junio C HamanoNov 20, 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.