mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
submodule: ensure core.worktree is set after update
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4fa4f90ccd
commit
e98317508c
@ -1860,6 +1860,29 @@ static int check_name(int argc, const char **argv, const char *prefix)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int connect_gitdir_workingtree(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
const char *name, *path;
|
||||
char *sm_gitdir;
|
||||
|
||||
if (argc != 3)
|
||||
BUG("submodule--helper connect-gitdir-workingtree <name> <path>");
|
||||
|
||||
name = argv[1];
|
||||
path = argv[2];
|
||||
|
||||
strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
|
||||
sm_gitdir = absolute_pathdup(sb.buf);
|
||||
|
||||
connect_work_tree_and_git_dir(path, sm_gitdir, 0);
|
||||
|
||||
strbuf_release(&sb);
|
||||
free(sm_gitdir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SUPPORT_SUPER_PREFIX (1<<0)
|
||||
|
||||
struct cmd_struct {
|
||||
@ -1873,6 +1896,7 @@ static struct cmd_struct commands[] = {
|
||||
{"name", module_name, 0},
|
||||
{"clone", module_clone, 0},
|
||||
{"update-clone", update_clone, 0},
|
||||
{"connect-gitdir-workingtree", connect_gitdir_workingtree, 0},
|
||||
{"relative-path", resolve_relative_path, 0},
|
||||
{"resolve-relative-url", resolve_relative_url, 0},
|
||||
{"resolve-relative-url-test", resolve_relative_url_test, 0},
|
||||
|
@ -615,6 +615,11 @@ cmd_update()
|
||||
die "$(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")"
|
||||
fi
|
||||
|
||||
if ! $(git config -f "$(git rev-parse --git-common-dir)/modules/$name/config" core.worktree) 2>/dev/null
|
||||
then
|
||||
git submodule--helper connect-gitdir-workingtree "$name" "$sm_path"
|
||||
fi
|
||||
|
||||
if test "$subsha1" != "$sha1" || test -n "$force"
|
||||
then
|
||||
subforce=$force
|
||||
|
Loading…
Reference in New Issue
Block a user