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