From: Junio C Hamano Date: Mon, 3 Oct 2016 20:30:34 +0000 (-0700) Subject: Merge branch 'nd/init-core-worktree-in-multi-worktree-world' X-Git-Tag: v2.11.0-rc0~93 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=53eb85e6230e2c09dbc06f88b67e7a3baccc4446;p=thirdparty%2Fgit.git Merge branch 'nd/init-core-worktree-in-multi-worktree-world' "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 --- 53eb85e6230e2c09dbc06f88b67e7a3baccc4446 diff --cc builtin/clone.c index 28ce9383a1,29b18329ee..fb75f7ee64 --- a/builtin/clone.c +++ b/builtin/clone.c @@@ -952,25 -939,11 +946,29 @@@ int cmd_clone(int argc, const char **ar fprintf(stderr, _("Cloning into '%s'...\n"), dir); } + 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(option_template, INIT_DB_QUIET); + 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); diff --cc builtin/init-db.c index 72e81447ae,37e318b116..2399b97d90 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@@ -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; }