1964
return 0;
1965
}
1966
1967
+static int ensure_core_worktree(int argc, const char **argv, const char *prefix)
1968
+{
1969
+ const struct submodule *sub;
1970
+ const char *path;
1971
+ char *cw;
1972
+ struct repository subrepo;
1973
+
1974
+ if (argc != 2)
1975
+ BUG("submodule--helper connect-gitdir-workingtree <name> <path>");
1976
+
1977
+ path = argv[1];
1978
+
1979
+ sub = submodule_from_path(the_repository, &null_oid, path);
1980
+ if (!sub)
1981
+ BUG("We could get the submodule handle before?");
1982
+
1983
+ if (repo_submodule_init(&subrepo, the_repository, path))
1984
+ die(_("could not get a repository handle for submodule '%s'"), path);
1985
+
1986
+ if (!repo_config_get_string(&subrepo, "core.worktree", &cw)) {
1987
+ char *cfg_file, *abs_path;
1988
+ const char *rel_path;
1989
+ struct strbuf sb = STRBUF_INIT;
1990
+
1991
+ cfg_file = repo_git_path(&subrepo, "config");
1992
+
1993
+ abs_path = absolute_pathdup(path);
1994
+ rel_path = relative_path(abs_path, subrepo.gitdir, &sb);
1995
+
1996
+ git_config_set_in_file(cfg_file, "core.worktree", rel_path);
1997
+
1998
+ free(cfg_file);
1999
+ free(abs_path);
2000
+ strbuf_release(&sb);
2001
+ }
2002
+
2003
+ return 0;
2004
+}
2005
+
2006
static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
2007
{
2008
int i;
2068
return 0;
2069
}
2070
2032
-static int connect_gitdir_workingtree(int argc, const char **argv, const char *prefix)
2033
-{
2034
- struct strbuf sb = STRBUF_INIT;
2035
- const char *name, *path;
2036
- char *sm_gitdir;
2037
-
2038
- if (argc != 3)
2039
- BUG("submodule--helper connect-gitdir-workingtree <name> <path>");
2040
-
2041
- name = argv[1];
2042
- path = argv[2];
2043
-
2044
- strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
2045
- sm_gitdir = absolute_pathdup(sb.buf);
2046
-
2047
- connect_work_tree_and_git_dir(path, sm_gitdir, 0);
2048
-
2049
- strbuf_release(&sb);
2050
- free(sm_gitdir);
2051
-
2052
- return 0;
2053
-}
2054
-
2071
#define SUPPORT_SUPER_PREFIX (1<<0)
2072
2073
struct cmd_struct {
2081
{"name", module_name, 0},
2082
{"clone", module_clone, 0},
2083
{"update-clone", update_clone, 0},
2068
- {"connect-gitdir-workingtree", connect_gitdir_workingtree, 0},
2084
+ {"ensure-core-worktree", ensure_core_worktree, 0},
2085
{"relative-path", resolve_relative_path, 0},
2086
{"resolve-relative-url", resolve_relative_url, 0},
2087
{"resolve-relative-url-test", resolve_relative_url_test, 0},