]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'nd/init-core-worktree-in-multi-worktree-world'
authorJunio C Hamano <gitster@pobox.com>
Mon, 3 Oct 2016 20:30:34 +0000 (13:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Oct 2016 20:30:35 +0000 (13:30 -0700)
"git init" tried to record core.worktree in the repository's
'config' file when GIT_WORK_TREE environment variable was set and
it was different from where GIT_DIR appears as ".git" at its top,
but the logic was faulty when .git is a "gitdir:" file that points
at the real place, causing trouble in working trees that are
managed by "git worktree".  This has been corrected.

* nd/init-core-worktree-in-multi-worktree-world:
  init: kill git_link variable
  init: do not set unnecessary core.worktree
  init: kill set_git_dir_init()
  init: call set_git_dir_init() from within init_db()
  init: correct re-initialization from a linked worktree

1  2 
builtin/clone.c
builtin/init-db.c
cache.h

diff --cc builtin/clone.c
index 28ce9383a14ced7ea3f135bdc0d42226aaf790af,29b18329ee449f0b195dff8e06367b8b7db377a3..fb75f7ee64a29e4bb79f163e82c73bb8a7bd5280
@@@ -952,25 -939,11 +946,29 @@@ int cmd_clone(int argc, const char **ar
                        fprintf(stderr, _("Cloning into '%s'...\n"), dir);
        }
  
-       init_db(option_template, INIT_DB_QUIET);
 +      if (option_recursive) {
 +              if (option_required_reference.nr &&
 +                  option_optional_reference.nr)
 +                      die(_("clone --recursive is not compatible with "
 +                            "both --reference and --reference-if-able"));
 +              else if (option_required_reference.nr) {
 +                      string_list_append(&option_config,
 +                              "submodule.alternateLocation=superproject");
 +                      string_list_append(&option_config,
 +                              "submodule.alternateErrorStrategy=die");
 +              } else if (option_optional_reference.nr) {
 +                      string_list_append(&option_config,
 +                              "submodule.alternateLocation=superproject");
 +                      string_list_append(&option_config,
 +                              "submodule.alternateErrorStrategy=info");
 +              }
 +      }
 +
+       init_db(git_dir, real_git_dir, option_template, INIT_DB_QUIET);
+       if (real_git_dir)
+               git_dir = real_git_dir;
        write_config(&option_config);
  
        git_config(git_default_config, NULL);
index 72e81447ae84c8e69799fff5a6fe7050241bea9b,37e318b1162145c84e882701a21228ce3a0f5b8a..2399b97d902668a08c3c881d544f4d6a88f4e263
@@@ -407,18 -397,16 +398,19 @@@ int init_db(const char *git_dir, const 
        if (!(flags & INIT_DB_QUIET)) {
                int len = strlen(git_dir);
  
 -              /* TRANSLATORS: The first '%s' is either "Reinitialized
 -                 existing" or "Initialized empty", the second " shared" or
 -                 "", and the last '%s%s' is the verbatim directory name. */
 -              printf(_("%s%s Git repository in %s%s\n"),
 -                     reinit ? _("Reinitialized existing") : _("Initialized empty"),
 -                     get_shared_repository() ? _(" shared") : "",
 -                     git_dir, len && git_dir[len-1] != '/' ? "/" : "");
 +              if (reinit)
 +                      printf(get_shared_repository()
 +                             ? _("Reinitialized existing shared Git repository in %s%s\n")
 +                             : _("Reinitialized existing Git repository in %s%s\n"),
 +                             git_dir, len && git_dir[len-1] != '/' ? "/" : "");
 +              else
 +                      printf(get_shared_repository()
 +                             ? _("Initialized empty shared Git repository in %s%s\n")
 +                             : _("Initialized empty Git repository in %s%s\n"),
 +                             git_dir, len && git_dir[len-1] != '/' ? "/" : "");
        }
  
+       free(original_git_dir);
        return 0;
  }
  
diff --cc cache.h
Simple merge