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>
Stefan Beller committed
Jun 18, 2018 at 17:06 UTC
e98317508c02b7cc65bf5b28f27788e47096b166
2 files changed
+29
builtin/submodule--helper.c
+24
@@ -1860,6 +1860,29 @@ static int check_name(int argc, const char **argv, const char *prefix)
1860
return 0;
1861
}
1862
1863
+static int connect_gitdir_workingtree(int argc, const char **argv, const char *prefix)
1864
+{
1865
+ struct strbuf sb = STRBUF_INIT;
1866
+ const char *name, *path;
1867
+ char *sm_gitdir;
1868
+
1869
+ if (argc != 3)
1870
+ BUG("submodule--helper connect-gitdir-workingtree <name> <path>");
1871
+
1872
+ name = argv[1];
1873
+ path = argv[2];
1874
+
1875
+ strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
1876
+ sm_gitdir = absolute_pathdup(sb.buf);
1877
+
1878
+ connect_work_tree_and_git_dir(path, sm_gitdir, 0);
1879
+
1880
+ strbuf_release(&sb);
1881
+ free(sm_gitdir);
1882
+
1883
+ return 0;
1884
+}
1885
+
1886
#define SUPPORT_SUPER_PREFIX (1<<0)
1887
1888
struct cmd_struct {
@@ -1873,6 +1896,7 @@ static struct cmd_struct commands[] = {
1896
{"name", module_name, 0},
1897
{"clone", module_clone, 0},
1898
{"update-clone", update_clone, 0},
1899
+ {"connect-gitdir-workingtree", connect_gitdir_workingtree, 0},
1900
{"relative-path", resolve_relative_path, 0},
1901
{"resolve-relative-url", resolve_relative_url, 0},
1902
{"resolve-relative-url-test", resolve_relative_url_test, 0},
git-submodule.sh
+5
@@ -615,6 +615,11 @@ cmd_update()
615
die "$(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")"
616
fi
617
618
+ if ! $(git config -f "$(git rev-parse --git-common-dir)/modules/$name/config" core.worktree) 2>/dev/null
619
+ then
620
+ git submodule--helper connect-gitdir-workingtree "$name" "$sm_path"
621
+ fi
622
+
623
if test "$subsha1" != "$sha1" || test -n "$force"
624
then
625
subforce=$force