@matheusbsbs / matheus-bagliano / commits / e362fadcd0
Fork 0

clone: remove fetch_if_missing=0

Commit 6462d5eb9a ("fetch: remove fetch_if_missing=0", 2019-11-08) strove to remove the need for fetch_if_missing=0 from the fetching mechanism, so it is plausible to attempt removing fetch_if_missing=0 from clone as well. But doing so reveals a bug - when the server does not send an object directly pointed to by a ref, this should be an error, not a trigger for a lazy fetch. (This case in the fetching mechanism was covered by a test using "git clone", not "git fetch", which is why the aforementioned commit didn't uncover the bug.) The bug can be fixed by suppressing lazy-fetching during the connectivity check. Fix this bug, and remove fetch_if_missing from clone. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Nov 12, 2019 at 16:34 UTC e362fadcd03753471cf8e7fc91d6d721b7423b8f
2 files changed +2 -4
builtin/clone.c
-3
@@ -927,8 +927,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
927
928 struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
929
930 - fetch_if_missing = 0;
931 -
930 packet_trace_identity("clone");
931 argc = parse_options(argc, argv, prefix, builtin_clone_options,
932 builtin_clone_usage, 0);
@@ -1265,7 +1263,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1263 }
1264
1265 junk_mode = JUNK_LEAVE_REPO;
1268 - fetch_if_missing = 1;
1266 err = checkout(submodule_progress);
1267
1268 strbuf_release(&reflog_msg);
connected.c
+2 -1
@@ -62,7 +62,8 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
62 * received the objects pointed to by each wanted ref.
63 */
64 do {
65 - if (!repo_has_object_file(the_repository, &oid))
65 + if (!repo_has_object_file_with_flags(the_repository, &oid,
66 + OBJECT_INFO_SKIP_FETCH_OBJECT))
67 return 1;
68 } while (!fn(cb_data, &oid));
69 return 0;