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
lidongyan <502024330056@smail.nju.edu.cn>
Date
Jun 13, 2025, 01:53 UTC
Message-ID
<11AE19A1-7B19-45CE-AFCE-98D89A4570F7@smail.nju.edu.cn>
In-Reply-To
<xmqqecvoev8g.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 写道:
Show 21 quoted lines
> 
> 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).

In commit a9ca8a85, the intention was to avoid calling get_git_dir() before confirming that we are indeed inside a Git repository and determining the prefix between the current working directory and the repository root.

However, I believe this concern is no longer relevant: repo_get_git_dir() no longer sets up the Git repository environment as the original comment implied. Instead, all the necessary setup is now handled by setup_git_env(), which is invoked by setup_git_directory_gently() after the prefix has been determined. As a result, I believe it is no longer necessary to retain this comment message.

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 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.