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

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

From
Lidong Yan <502024330056@smail.nju.edu.cn>
Date
Jun 16, 2025, 05:36 UTC
Message-ID
<191FDEFA-786C-4CD7-9D4F-06495FCBDDA6@smail.nju.edu.cn>
In-Reply-To
<xmqqsek04id9.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> e5b17bda (git: ensure correct git directory setup with -h,
> 2021-12-06) unfortunately moved lines around and made it look like
> the comment is about what happens when the if() condition holds, but
> if we look at the way how a9ca8a85 (builtins: print setup info if
> repo is found, 2010-11-26) initially placed this comment, we can see
> that this comment was to only explain the reason why we look at
> startup_info->have_repository there.  "Only if we know we have
> repository, do the trace_repo_setup() thing because that one calls
> get_git_dir() that would die otherwise" is what the comment wants to
> say, and if we revert the moving-line-around done by e5b17bda to
> recover the original layout in a9ca8a85, I think it is clear enough.
I’ve changed my mind. Layout like
	if (run_setup &&
		startup_info->have_repository) /* get_git_dir() may set up repo, avoid that */
		trace_repo_setup(repo);

Looks unbalanced, and git-clang-format tries to format this code snippet into

	if (run_setup && startup_info->have_repository) /* get_git_dir() may set
							   up repo, avoid that
							 */
Which looks even worse, I will leave this comment intact.

Thanks, Lidong

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