Re: [PATCH 06/11] fetch: avoid unnecessary work when there is no current branch
- From
Jeff King <peff@peff.net>
- Date
- May 15, 2025, 20:11 UTC
- Message-ID
- <20250515201145.GG3320240@coredump.intra.peff.net>
- In-Reply-To
- <dff0a3ec886cdccf199bdc3881094ec0ab8b3bca.1747314709.git.gitgitgadget@gmail.com>
On Thu, May 15, 2025 at 01:11:44PM +0000, Johannes Schindelin via GitGitGadget wrote:
> As pointed out by CodeQL, `branch_get()` may return `NULL`, in which > case `branch_has_merge_config()` would return early, but we can even > avoid enumerating the refs prefixes in that case, saving even more CPU > cycles.
I am not sure how this patch changes anything with respect to CPU. If branch is NULL, then branch_has_merge_config(branch) will always return false.
I think this is just an issue that CodeQL is not looking inside branch_has_merge_config(), and thus does not realize we will never hit the rest of the short-circuit conditional (let alone the body) in that case?
Still may be worth dealing with, but it makes me a little sad to have to add an extra redundant check (one place is not a big deal, but as a general pattern).
-Peff