Re: [PATCH] git: --no-lazy-fetch option
From: Junio C Hamano <hidden>
Date: 2024-02-15 17:08:12
Jeff King [off-list ref] writes:
On Thu, Feb 08, 2024 at 03:17:31PM -0800, Junio C Hamano wrote:quoted
Sometimes, especially during tests of low level machinery, it is handy to have a way to disable lazy fetching of objects. This allows us to say, for example, "git cat-file -e <object-name>", to see if the object is locally available.That seems like a good feature, but...quoted
@@ -186,6 +187,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) use_pager = 0; if (envchanged) *envchanged = 1; + } else if (!strcmp(cmd, "--no-lazy-fetch")) { + fetch_if_missing = 0; } else if (!strcmp(cmd, "--no-replace-objects")) { disable_replace_refs(); setenv(NO_REPLACE_OBJECTS_ENVIRONMENT, "1", 1);This will only help builtin commands, and even then only the top-level one. If I run "git --no-lazy-fetch foo" and "foo" is a script or an alias, I'd expect it to still take effect. Ditto for sub-commands kicked off by a builtin (say, a "rev-list" connectivity check caused by a fetch). So this probably needs to be modeled after --no-replace-objects, etc, where we set an environment variable that makes it to child processes.
Yuck, I was hoping that we can get away with the tiny change only for builtins,but you're right.