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

Re: [PATCH] git.c: remove the_repository dependence in run_builtin()

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 12, 2025, 17:16 UTC
Message-ID
<xmqqecvoev8g.fsf@gitster.g>
In-Reply-To
<20250612045905.3023227-1-502024330056@smail.nju.edu.cn>
Lidong Yan <yldhome2d2@gmail.com> writes:
> run_builtin() takes a repo parameter, so the use of the_repository
> is no longer necessary. Removed the usage of the_repository.

Good. The caller always calls this function with the_repository, so this patch does not change anything in the bigger picture.

> The comment before trace_repo_setup() advises not to use get_git_dir(),
> but this note is unrelated to trace_repo_setup() itself. Additionally,
> get_git_dir() has now been renamed to repo_get_git_dir(). Remove this
> comment line.

Isn't it still relevant to explain the reason why this codepath avoids calling the repo_get_git_dir() function?

e5b17bda (git: ensure correct git directory setup with -h, 2021-12-06) tells us that the comment is about use of startup_info->have_repository, which was added by a9ca8a85 (builtins: print setup info if repo is found, 2010-11-26).

Show 24 quoted lines
> Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
> ---
>  git.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/git.c b/git.c
> index 77c4359522..429ad1c2fb 100644
> --- a/git.c
> +++ b/git.c
> @@ -462,12 +462,11 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
>  	precompose_argv_prefix(argc, argv, NULL);
>  	if (use_pager == -1 && run_setup &&
>  		!(p->option & DELAY_PAGER_CONFIG))
> -		use_pager = check_pager_config(the_repository, p->cmd);
> +		use_pager = check_pager_config(repo, p->cmd);
>  	if (use_pager == -1 && p->option & USE_PAGER)
>  		use_pager = 1;
>  	if (run_setup && startup_info->have_repository)
> -		/* get_git_dir() may set up repo, avoid that */
> -		trace_repo_setup(the_repository);
> +		trace_repo_setup(repo);
>  	commit_pager_choice();
>  
>  	if (!help && p->option & NEED_WORK_TREE)
Previous: Lidong YanNext: lidongyan
Message 2 of 16 in “git.c: remove the_repository dependence in run_builtin()”
  1. git.c: remove the_repository dependence in run_builtin()Lidong Yan, Jun 12, 2025
  2. Junio C HamanoJun 12, 2025
  3. lidongyanJun 13, 2025
  4. Junio C HamanoJun 13, 2025
  5. git.c: remove the_repository dependence in run_builtin()Lidong Yan, Jun 14, 2025
  6. Junio C HamanoJun 14, 2025
  7. Lidong YanJun 15, 2025
  8. Junio C HamanoJun 16, 2025
  9. Lidong YanJun 16, 2025
  10. Junio C HamanoJun 16, 2025
  11. 0/2 small fixes for git.c and setup.cLidong Yan, Jun 15, 2025
  12. 1/2 git.c: remove the_repository dependence in run_builtin()Lidong Yan, Jun 15, 2025
  13. 2/2 setup: fix NEEDSWORK in setup_git_directory_gently()Lidong Yan, Jun 15, 2025
  14. Junio C HamanoJun 16, 2025
  15. Lidong YanJun 16, 2025
  16. git.c: remove the_repository dependence in run_builtin()Lidong Yan, Jun 16, 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.