From: Junio C Hamano Date: Thu, 6 Jun 2013 19:17:55 +0000 (-0700) Subject: Merge branch 'nd/clone-connectivity-shortcut' X-Git-Tag: v1.8.4-rc0~205 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/72e719292d5dd6e037fecbc3a1c5e4d4f21f03b8?ds=inline;hp=-c Merge branch 'nd/clone-connectivity-shortcut' Special case "git clone" and use lighter-weight implementation to check the completeness of the history behind refs. * nd/clone-connectivity-shortcut: clone: open a shortcut for connectivity check index-pack: remove dead code (it should never happen) fetch-pack: prepare updated shallow file before fetching the pack clone: let the user know when check_everything_connected is run --- 72e719292d5dd6e037fecbc3a1c5e4d4f21f03b8 diff --combined builtin/clone.c index b6ffc6b4fe,069e81e26d..66bff5700f --- a/builtin/clone.c +++ b/builtin/clone.c @@@ -18,6 -18,7 +18,6 @@@ #include "transport.h" #include "strbuf.h" #include "dir.h" -#include "pack-refs.h" #include "sigchain.h" #include "branch.h" #include "remote.h" @@@ -541,12 -542,18 +541,18 @@@ static void update_remote_refs(const st const struct ref *mapped_refs, const struct ref *remote_head_points_at, const char *branch_top, - const char *msg) + const char *msg, + struct transport *transport) { const struct ref *rm = mapped_refs; - if (check_everything_connected(iterate_ref_map, 0, &rm)) + if (0 <= option_verbosity) + printf(_("Checking connectivity... ")); + if (check_everything_connected_with_transport(iterate_ref_map, + 0, &rm, transport)) die(_("remote did not send all necessary objects")); + if (0 <= option_verbosity) + printf(_("done\n")); if (refs) { write_remote_refs(mapped_refs); @@@ -782,8 -789,6 +788,8 @@@ int cmd_clone(int argc, const char **ar is_local = option_local != 0 && path && !is_bundle; if (is_local && option_depth) warning(_("--depth is ignored in local clones; use file:// instead.")); + if (option_local > 0 && !is_local) + warning(_("--local is ignored")); if (argc == 2) dir = xstrdup(argv[1]); @@@ -890,6 -895,9 +896,9 @@@ if (option_upload_pack) transport_set_option(transport, TRANS_OPT_UPLOADPACK, option_upload_pack); + + if (transport->smart_options && !option_depth) + transport->smart_options->check_self_contained_and_connected = 1; } refs = transport_get_remote_refs(transport); @@@ -951,7 -959,7 +960,7 @@@ transport_fetch_refs(transport, mapped_refs); update_remote_refs(refs, mapped_refs, remote_head_points_at, - branch_top.buf, reflog_msg.buf); + branch_top.buf, reflog_msg.buf, transport); update_head(our_head_points_at, remote_head, reflog_msg.buf); diff --combined git.c index 7dd07aae7a,88eef5a7cc..4359086fd6 --- a/git.c +++ b/git.c @@@ -4,6 -4,7 +4,7 @@@ #include "help.h" #include "quote.h" #include "run-command.h" + #include "commit.h" const char git_usage_string[] = "git [--version] [--help] [-c name=value]\n" @@@ -146,6 -147,12 +147,12 @@@ static int handle_options(const char ** setenv(GIT_LITERAL_PATHSPECS_ENVIRONMENT, "0", 1); if (envchanged) *envchanged = 1; + } else if (!strcmp(cmd, "--shallow-file")) { + (*argv)++; + (*argc)--; + set_alternate_shallow_file((*argv)[0]); + if (envchanged) + *envchanged = 1; } else { fprintf(stderr, "Unknown option: %s\n", cmd); usage(git_usage_string); @@@ -507,9 -514,8 +514,9 @@@ static int run_argv(int *argcp, const c } -int main(int argc, const char **argv) +int main(int argc, char **av) { + const char **argv = (const char **) av; const char *cmd; startup_info = &git_startup_info; diff --combined t/t5500-fetch-pack.sh index 6133d9ed13,557b073b36..fd2598e601 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@@ -135,6 -135,13 +135,13 @@@ test_expect_success 'clone shallow dept test "`git --git-dir=shallow0/.git rev-list --count HEAD`" = 1 ' + test_expect_success 'clone shallow depth 1 with fsck' ' + git config --global fetch.fsckobjects true && + git clone --no-single-branch --depth 1 "file://$(pwd)/." shallow0fsck && + test "`git --git-dir=shallow0fsck/.git rev-list --count HEAD`" = 1 && + git config --global --unset fetch.fsckobjects + ' + test_expect_success 'clone shallow' ' git clone --no-single-branch --depth 2 "file://$(pwd)/." shallow ' @@@ -373,20 -380,6 +380,20 @@@ test_expect_success 'clone shallow wit test_cmp count8.expected count8.actual ' +test_expect_success 'fetch in shallow repo unreachable shallow objects' ' + ( + git clone --bare --branch B --single-branch "file://$(pwd)/." no-reflog && + git clone --depth 1 "file://$(pwd)/no-reflog" shallow9 && + cd no-reflog && + git tag -d TAGB1 TAGB2 && + git update-ref refs/heads/B B~~ && + git gc --prune=now && + cd ../shallow9 && + git fetch origin && + git fsck --no-dangling + ) +' + test_expect_success 'setup tests for the --stdin parameter' ' for head in C D E F do