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

Re: [PATCH 07/39] sha1_file: add repository argument to alt_odb_usable

From
BWBrandon Williams <bmwill@google.com>
Date
Aug 30, 2017, 22:40 UTC
Message-ID
<20170830224028.GE50018@google.com>
In-Reply-To
<20170830065631.GH153983@aiede.mtv.corp.google.com>
On 08/29, Jonathan Nieder wrote:
Show 14 quoted lines
> From: Stefan Beller <sbeller@google.com>
> 
> Add a repository argument to allow the alt_odb_usable caller to be
> more specific about which repository to act on. This is a small
> mechanical change; it doesn't change the implementation to handle
> repositories other than the_repository yet.
> 
> Since the implementation does not yet work with other repositories,
> use a wrapper macro to enforce that the caller passes in
> the_repository as the first argument. It would be more appealing to
> use BUILD_ASSERT_OR_ZERO to enforce this, but that doesn't work
> because it requires a compile-time constant and common compilers like
> gcc 4.8.4 do not consider "r == the_repository" a compile-time
> constant.
Very clever trick :)
Show 34 quoted lines
> 
> Signed-off-by: Stefan Beller <sbeller@google.com>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
>  sha1_file.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/sha1_file.c b/sha1_file.c
> index 7c6ffd205a..1c757b44a3 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -280,7 +280,9 @@ static const char *alt_sha1_path(struct alternate_object_database *alt,
>  /*
>   * Return non-zero iff the path is usable as an alternate object database.
>   */
> -static int alt_odb_usable(struct strbuf *path, const char *normalized_objdir)
> +#define alt_odb_usable(r, p, n) alt_odb_usable_##r(p, n)
> +static int alt_odb_usable_the_repository(struct strbuf *path,
> +					 const char *normalized_objdir)
>  {
>  	struct alternate_object_database *alt;
>  
> @@ -348,7 +350,7 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base,
>  	while (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')
>  		strbuf_setlen(&pathbuf, pathbuf.len - 1);
>  
> -	if (!alt_odb_usable(&pathbuf, normalized_objdir)) {
> +	if (!alt_odb_usable(the_repository, &pathbuf, normalized_objdir)) {
>  		strbuf_release(&pathbuf);
>  		return -1;
>  	}
> -- 
> 2.14.1.581.gf28d330327
> 
-- 
Brandon Williams
Previous: Jonathan NiederNext: Jonathan Nieder
Message 11 of 46 in “per-repository object store, part 1”
  1. 00/39 per-repository object store, part 1Jonathan Nieder, Aug 30, 2017
  2. 01/39 pack: make packed_git_mru global a value instead of a pointerJonathan Nieder, Aug 30, 2017
  3. Jeff KingAug 30, 2017
  4. Junio C HamanoSep 6, 2017
  5. 02/39 repository: introduce object store fieldJonathan Nieder, Aug 30, 2017
  6. 03/39 object-store: move alt_odb_list and alt_odb_tail to object storeJonathan Nieder, Aug 30, 2017
  7. 04/39 object-store: move packed_git and packed_git_mru to object storeJonathan Nieder, Aug 30, 2017
  8. 05/39 pack: move prepare_packed_git_run_once to object storeJonathan Nieder, Aug 30, 2017
  9. 06/39 pack: move approximate object count to object storeJonathan Nieder, Aug 30, 2017
  10. 07/39 sha1_file: add repository argument to alt_odb_usableJonathan Nieder, Aug 30, 2017
  11. Brandon WilliamsAug 30, 2017
  12. 08/39 sha1_file: add repository argument to link_alt_odb_entryJonathan Nieder, Aug 30, 2017
  13. 09/39 sha1_file: add repository argument to read_info_alternatesJonathan Nieder, Aug 30, 2017
  14. 10/39 sha1_file: add repository argument to link_alt_odb_entriesJonathan Nieder, Aug 30, 2017
  15. 11/39 sha1_file: add repository argument to stat_sha1_fileJonathan Nieder, Aug 30, 2017
  16. 12/39 sha1_file: add repository argument to open_sha1_fileJonathan Nieder, Aug 30, 2017
  17. 13/39 sha1_file: add repository argument to map_sha1_file_1Jonathan Nieder, Aug 30, 2017
  18. 14/39 sha1_file: add repository argument to sha1_loose_object_infoJonathan Nieder, Aug 30, 2017
  19. 15/39 object-store: add repository argument to prepare_alt_odbJonathan Nieder, Aug 30, 2017
  20. 16/39 object-store: add repository argument to foreach_alt_odbJonathan Nieder, Aug 30, 2017
  21. 17/39 pack: add repository argument to install_packed_gitJonathan Nieder, Aug 30, 2017
  22. 18/39 pack: add repository argument to prepare_packed_git_oneJonathan Nieder, Aug 30, 2017
  23. 19/39 pack: add repository argument to rearrange_packed_gitJonathan Nieder, Aug 30, 2017
  24. 20/39 pack: add repository argument to prepare_packed_git_mruJonathan Nieder, Aug 30, 2017
  25. 21/39 pack: add repository argument to prepare_packed_gitJonathan Nieder, Aug 30, 2017
  26. 22/39 pack: add repository argument to reprepare_packed_gitJonathan Nieder, Aug 30, 2017
  27. 23/39 pack: add repository argument to sha1_file_nameJonathan Nieder, Aug 30, 2017
  28. 24/39 pack: add repository argument to map_sha1_fileJonathan Nieder, Aug 30, 2017
  29. 25/39 sha1_file: allow alt_odb_usable to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  30. Junio C HamanoSep 6, 2017
  31. Stefan BellerSep 6, 2017
  32. 26/39 object-store: allow prepare_alt_odb to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  33. 27/39 object-store: allow foreach_alt_odb to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  34. 28/39 pack: allow install_packed_git to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  35. 29/39 pack: allow rearrange_packed_git to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  36. 30/39 pack: allow prepare_packed_git_mru to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  37. 31/39 pack: allow prepare_packed_git_one to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  38. 32/39 pack: allow prepare_packed_git to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  39. 33/39 pack: allow reprepare_packed_git to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  40. 34/39 pack: allow sha1_file_name to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  41. 35/39 pack: allow stat_sha1_file to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  42. 36/39 pack: allow open_sha1_file to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  43. 37/39 pack: allow map_sha1_file_1 to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  44. 38/39 pack: allow map_sha1_file to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  45. 39/39 pack: allow sha1_loose_object_info to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  46. Brandon WilliamsAug 30, 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.