Merge branch 'jk/check-corrupt-objects-carefully'
authorJunio C Hamano <gitster@pobox.com>
Sun, 28 Apr 2013 18:57:54 +0000 (11:57 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 28 Apr 2013 18:57:54 +0000 (11:57 -0700)
* jk/check-corrupt-objects-carefully:
clone: Make the 'junk_mode' symbol a file static

1  2 
builtin/clone.c
diff --combined builtin/clone.c
index 58fee9874f0fea4ed52acf31f757268be5383267,2238ae82861940b9f1cc24dbe470771509e26fdf..035ab649504d69a83f87b854582c8003a2dcb905
@@@ -232,26 -232,16 +232,26 @@@ static void strip_trailing_slashes(cha
  static int add_one_reference(struct string_list_item *item, void *cb_data)
  {
        char *ref_git;
 +      const char *repo;
        struct strbuf alternate = STRBUF_INIT;
  
 -      /* Beware: real_path() and mkpath() return static buffer */
 +      /* Beware: read_gitfile(), real_path() and mkpath() return static buffer */
        ref_git = xstrdup(real_path(item->string));
 -      if (is_directory(mkpath("%s/.git/objects", ref_git))) {
 +
 +      repo = read_gitfile(ref_git);
 +      if (!repo)
 +              repo = read_gitfile(mkpath("%s/.git", ref_git));
 +      if (repo) {
 +              free(ref_git);
 +              ref_git = xstrdup(repo);
 +      }
 +
 +      if (!repo && is_directory(mkpath("%s/.git/objects", ref_git))) {
                char *ref_git_git = mkpathdup("%s/.git", ref_git);
                free(ref_git);
                ref_git = ref_git_git;
        } else if (!is_directory(mkpath("%s/objects", ref_git)))
 -              die(_("reference repository '%s' is not a local directory."),
 +              die(_("reference repository '%s' is not a local repository."),
                    item->string);
  
        strbuf_addf(&alternate, "%s/objects", ref_git);
@@@ -387,7 -377,7 +387,7 @@@ static void clone_local(const char *src
  static const char *junk_work_tree;
  static const char *junk_git_dir;
  static pid_t junk_pid;
- enum {
static enum {
        JUNK_LEAVE_NONE,
        JUNK_LEAVE_REPO,
        JUNK_LEAVE_ALL