Skip to content

Commit f178c13

Browse files
jrngitster
authored andcommitted
Revert "Merge branch 'sb/submodule-core-worktree'"
This reverts commit 7e25437, reversing changes made to 00624d6. v2.19.0-rc0~165^2~1 (submodule: ensure core.worktree is set after update, 2018-06-18) assumes an "absorbed" submodule layout, where the submodule's Git directory is in the superproject's .git/modules/ directory and .git in the submodule worktree is a .git file pointing there. In particular, it uses $GIT_DIR/modules/$name to find the submodule to find out whether it already has core.worktree set, and it uses connect_work_tree_and_git_dir if not, resulting in fatal: could not open sub/.git for writing The context behind that patch: v2.19.0-rc0~165^2~2 (submodule: unset core.worktree if no working tree is present, 2018-06-12) unsets core.worktree when running commands like "git checkout --recurse-submodules" to switch to a branch without the submodule. If a user then uses "git checkout --no-recurse-submodules" to switch back to a branch with the submodule and runs "git submodule update", this patch is needed to ensure that commands using the submodule directly are aware of the path to the worktree. It is late in the release cycle, so revert the whole 3-patch series. We can try again later for 2.20. Reported-by: Allan Sandfeld Jensen <[email protected]> Helped-by: Stefan Beller <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c05048d commit f178c13

File tree

6 files changed

+2
-55
lines changed

6 files changed

+2
-55
lines changed

builtin/submodule--helper.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,8 +1123,6 @@ static void deinit_submodule(const char *path, const char *prefix,
11231123
if (!(flags & OPT_QUIET))
11241124
printf(format, displaypath);
11251125

1126-
submodule_unset_core_worktree(sub);
1127-
11281126
strbuf_release(&sb_rm);
11291127
}
11301128

@@ -2005,29 +2003,6 @@ static int check_name(int argc, const char **argv, const char *prefix)
20052003
return 0;
20062004
}
20072005

2008-
static int connect_gitdir_workingtree(int argc, const char **argv, const char *prefix)
2009-
{
2010-
struct strbuf sb = STRBUF_INIT;
2011-
const char *name, *path;
2012-
char *sm_gitdir;
2013-
2014-
if (argc != 3)
2015-
BUG("submodule--helper connect-gitdir-workingtree <name> <path>");
2016-
2017-
name = argv[1];
2018-
path = argv[2];
2019-
2020-
strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
2021-
sm_gitdir = absolute_pathdup(sb.buf);
2022-
2023-
connect_work_tree_and_git_dir(path, sm_gitdir, 0);
2024-
2025-
strbuf_release(&sb);
2026-
free(sm_gitdir);
2027-
2028-
return 0;
2029-
}
2030-
20312006
#define SUPPORT_SUPER_PREFIX (1<<0)
20322007

20332008
struct cmd_struct {
@@ -2041,7 +2016,6 @@ static struct cmd_struct commands[] = {
20412016
{"name", module_name, 0},
20422017
{"clone", module_clone, 0},
20432018
{"update-clone", update_clone, 0},
2044-
{"connect-gitdir-workingtree", connect_gitdir_workingtree, 0},
20452019
{"relative-path", resolve_relative_path, 0},
20462020
{"resolve-relative-url", resolve_relative_url, 0},
20472021
{"resolve-relative-url-test", resolve_relative_url_test, 0},

git-submodule.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,6 @@ cmd_update()
580580
die "$(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")"
581581
fi
582582

583-
if ! $(git config -f "$(git rev-parse --git-common-dir)/modules/$name/config" core.worktree) 2>/dev/null
584-
then
585-
git submodule--helper connect-gitdir-workingtree "$name" "$sm_path"
586-
fi
587-
588583
if test "$subsha1" != "$sha1" || test -n "$force"
589584
then
590585
subforce=$force

submodule.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,18 +1534,6 @@ int bad_to_remove_submodule(const char *path, unsigned flags)
15341534
return ret;
15351535
}
15361536

1537-
void submodule_unset_core_worktree(const struct submodule *sub)
1538-
{
1539-
char *config_path = xstrfmt("%s/modules/%s/config",
1540-
get_git_common_dir(), sub->name);
1541-
1542-
if (git_config_set_in_file_gently(config_path, "core.worktree", NULL))
1543-
warning(_("Could not unset core.worktree setting in submodule '%s'"),
1544-
sub->path);
1545-
1546-
free(config_path);
1547-
}
1548-
15491537
static const char *get_super_prefix_or_empty(void)
15501538
{
15511539
const char *s = get_super_prefix();
@@ -1711,8 +1699,6 @@ int submodule_move_head(const char *path,
17111699

17121700
if (is_empty_dir(path))
17131701
rmdir_or_warn(path);
1714-
1715-
submodule_unset_core_worktree(sub);
17161702
}
17171703
}
17181704
out:

submodule.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ int submodule_move_head(const char *path,
127127
const char *new_head,
128128
unsigned flags);
129129

130-
void submodule_unset_core_worktree(const struct submodule *sub);
131-
132130
/*
133131
* Prepare the "env_array" parameter of a "struct child_process" for executing
134132
* a submodule by clearing any repo-specific environment variables, but

t/lib-submodule-update.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ reset_work_tree_to_interested () {
235235
then
236236
mkdir -p submodule_update/.git/modules/sub1/modules &&
237237
cp -r submodule_update_repo/.git/modules/sub1/modules/sub2 submodule_update/.git/modules/sub1/modules/sub2
238-
# core.worktree is unset for sub2 as it is not checked out
238+
GIT_WORK_TREE=. git -C submodule_update/.git/modules/sub1/modules/sub2 config --unset core.worktree
239239
fi &&
240240
# indicate we are interested in the submodule:
241241
git -C submodule_update config submodule.sub1.url "bogus" &&
@@ -709,8 +709,7 @@ test_submodule_recursing_with_args_common() {
709709
git branch -t remove_sub1 origin/remove_sub1 &&
710710
$command remove_sub1 &&
711711
test_superproject_content origin/remove_sub1 &&
712-
! test -e sub1 &&
713-
test_must_fail git config -f .git/modules/sub1/config core.worktree
712+
! test -e sub1
714713
)
715714
'
716715
# ... absorbing a .git directory along the way.

t/t7400-submodule-basic.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -984,11 +984,6 @@ test_expect_success 'submodule deinit should remove the whole submodule section
984984
rmdir init
985985
'
986986

987-
test_expect_success 'submodule deinit should unset core.worktree' '
988-
test_path_is_file .git/modules/example/config &&
989-
test_must_fail git config -f .git/modules/example/config core.worktree
990-
'
991-
992987
test_expect_success 'submodule deinit from subdirectory' '
993988
git submodule update --init &&
994989
git config submodule.example.foo bar &&

0 commit comments

Comments
 (0)