Merge branch 'nd/clone-connectivity-shortcut'
authorJunio C Hamano <gitster@pobox.com>
Thu, 6 Jun 2013 19:17:55 +0000 (12:17 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Jun 2013 19:17:55 +0000 (12:17 -0700)
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

1  2 
builtin/clone.c
git.c
t/t5500-fetch-pack.sh
diff --combined builtin/clone.c
index b6ffc6b4feb2dc56d8239cbfcea7d6467a652e6d,069e81e26d1393f6ca581503410814476b115387..66bff5700f1e33c009c69fc44ba327dff1acb135
@@@ -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]);
                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);
                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 7dd07aae7a13aca1c910d6f126495e8280d00a71,88eef5a7cc6d36f6e17f4855945116dd6f1b0681..4359086fd6c47f1bfc3fc408b7bc986517eea9a0
--- 1/git.c
--- 2/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 6133d9ed13804d1cda4044e906ada1065fbad4a6,557b073b36248522445b6bd7343b4af16b9a7611..fd2598e60190fe04381652c7dfe997e01b4ea0c5
@@@ -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