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

Re: [PATCH 06/14] server-info: stop using `the_repository`

From
shejialuo <shejialuo@gmail.com>
Date
Dec 17, 2024, 12:31 UTC
Message-ID
<Z2FvCKYdRLZzHJVC@ArchLinux>
In-Reply-To
<20241217-pks-use-the-repository-conversion-v1-6-0dba48bcc239@pks.im>
On Tue, Dec 17, 2024 at 07:43:53AM +0100, Patrick Steinhardt wrote:
Show 18 quoted lines
> Stop using `the_repository` in the "server-info" subsystem by passing in
> a repository when updating server info and storing the repository in the
> `update_info_ctx` structure to make it accessible to other functions.
> 
> Adjust callers accordingly by using `the_repository`. While there may be
> some callers that have a repository available in their context, this
> trivial conversion allows for easier verification and bubbles up the use
> of `the_repository` by one level.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  builtin/receive-pack.c       |  2 +-
>  builtin/repack.c             |  2 +-
>  builtin/update-server-info.c |  2 +-
>  server-info.c                | 40 ++++++++++++++++++++++------------------
>  server-info.h                |  4 +++-
>  5 files changed, 28 insertions(+), 22 deletions(-)
> 
Show 21 quoted lines
> -int update_server_info(int force)
> +int update_server_info(struct repository *r, int force)
>  {
>  	/* We would add more dumb-server support files later,
>  	 * including index of available pack files and their
>  	 * intended audiences.
>  	 */
>  	int errs = 0;
> +	char *path;
>  
> -	errs = errs | update_info_refs(force);
> -	errs = errs | update_info_packs(force);
> +	errs = errs | update_info_refs(r, force);
> +	errs = errs | update_info_packs(r, force);
>  
>  	/* remove leftover rev-cache file if there is any */
> -	unlink_or_warn(git_path("info/rev-cache"));
> +	path = repo_git_path(r, "info/rev-cache");
> +	unlink_or_warn(path);
> +	free(path);
>  

The original "git_path" will be returned from the static string buffers, so there is no need to free. But "repo_git_path" will return a allocated string, the caller need to explicit free this. Make sense.

>  	return errs;
>  }
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 13 of 26 in “Stop using `the_repository` in some trivial cases”
  1. 00/14 Stop using `the_repository` in some trivial casesPatrick Steinhardt, Dec 17, 2024
  2. 01/14 progress: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  3. Karthik NayakDec 31, 2024
  4. Toon ClaesJan 6, 2025
  5. Patrick SteinhardtJan 7, 2025
  6. 02/14 pager: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  7. shejialuoDec 17, 2024
  8. Karthik NayakDec 31, 2024
  9. 03/14 trace: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  10. 04/14 serve: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  11. 05/14 send-pack: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  12. 06/14 server-info: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  13. shejialuoDec 17, 2024
  14. 07/14 diagnose: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  15. 08/14 mailinfo: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  16. 09/14 credential: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  17. 10/14 resolve-undo: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  18. 11/14 tmp-objdir: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  19. 12/14 add-interactive: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  20. 13/14 graph: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  21. 14/14 match-trees: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  22. shejialuoDec 17, 2024
  23. Patrick SteinhardtDec 27, 2024
  24. Karthik NayakJan 7, 2025
  25. Toon ClaesJan 7, 2025
  26. Junio C HamanoJan 7, 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.