]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git: --no-lazy-fetch option
authorJunio C Hamano <gitster@pobox.com>
Thu, 8 Feb 2024 23:17:31 +0000 (15:17 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Feb 2024 20:53:15 +0000 (12:53 -0800)
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.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git.txt
git.c

index 2535a30194f978af900c0f84228680b3b8edf93a..95f451b22baa67b1c26f11a32f8ea636f7937281 100644 (file)
@@ -177,6 +177,11 @@ If you just want to run git as if it was started in `<path>` then use
        Do not use replacement refs to replace Git objects. See
        linkgit:git-replace[1] for more information.
 
+--no-lazy-fetch::
+       Do not fetch missing objects from the promisor remote on
+       demand.  Useful together with `git cat-file -e <object>` to
+       see if the object is locally available.
+
 --literal-pathspecs::
        Treat pathspecs literally (i.e. no globbing, no pathspec magic).
        This is equivalent to setting the `GIT_LITERAL_PATHSPECS` environment
diff --git a/git.c b/git.c
index c67e44dd82d2e4fc01fb841c8f863282607f6ac7..28e8bf7497fed262e6d40f0cf57450aebafec5d7 100644 (file)
--- a/git.c
+++ b/git.c
@@ -4,6 +4,7 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "help.h"
+#include "object-file.h"
 #include "pager.h"
 #include "read-cache-ll.h"
 #include "run-command.h"
@@ -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);