debian: apply two last-minute regression fixes
[git/debian.git] / debian / patches / 0002-Revert-Merge-branch-sb-submodule-core-worktree.diff
blob473cbd7a4d1c508eaef107dd99e9ef3cac44927d
1 From b67b127881cf743e642636f4041742341abac373 Mon Sep 17 00:00:00 2001
2 From: Jonathan Nieder <jrnieder@gmail.com>
3 Date: Fri, 7 Sep 2018 17:09:46 -0700
4 Subject: Revert "Merge branch 'sb/submodule-core-worktree'"
6 commit f178c13fdac42763a7aa58bf260aa67d9f4393ec upstream.
8 This reverts commit 7e25437d35a70791b345872af202eabfb3e1a8bc, reversing
9 changes made to 00624d608cc69bd62801c93e74d1ea7a7ddd6598.
11 v2.19.0-rc0~165^2~1 (submodule: ensure core.worktree is set after
12 update, 2018-06-18) assumes an "absorbed" submodule layout, where the
13 submodule's Git directory is in the superproject's .git/modules/
14 directory and .git in the submodule worktree is a .git file pointing
15 there. In particular, it uses $GIT_DIR/modules/$name to find the
16 submodule to find out whether it already has core.worktree set, and it
17 uses connect_work_tree_and_git_dir if not, resulting in
19 fatal: could not open sub/.git for writing
21 The context behind that patch: v2.19.0-rc0~165^2~2 (submodule: unset
22 core.worktree if no working tree is present, 2018-06-12) unsets
23 core.worktree when running commands like "git checkout
24 --recurse-submodules" to switch to a branch without the submodule. If
25 a user then uses "git checkout --no-recurse-submodules" to switch back
26 to a branch with the submodule and runs "git submodule update", this
27 patch is needed to ensure that commands using the submodule directly
28 are aware of the path to the worktree.
30 It is late in the release cycle, so revert the whole 3-patch series.
31 We can try again later for 2.20.
33 Reported-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
34 Helped-by: Stefan Beller <sbeller@google.com>
35 Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
36 Signed-off-by: Junio C Hamano <gitster@pobox.com>
37 Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
38 ---
39 builtin/submodule--helper.c | 26 --------------------------
40 git-submodule.sh | 5 -----
41 submodule.c | 14 --------------
42 submodule.h | 2 --
43 t/lib-submodule-update.sh | 5 ++---
44 t/t7400-submodule-basic.sh | 5 -----
45 6 files changed, 2 insertions(+), 55 deletions(-)
47 diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
48 index b56028ba9d..f6fb8991f3 100644
49 --- a/builtin/submodule--helper.c
50 +++ b/builtin/submodule--helper.c
51 @@ -1123,8 +1123,6 @@ static void deinit_submodule(const char *path, const char *prefix,
52 if (!(flags & OPT_QUIET))
53 printf(format, displaypath);
55 - submodule_unset_core_worktree(sub);
57 strbuf_release(&sb_rm);
60 @@ -2005,29 +2003,6 @@ static int check_name(int argc, const char **argv, const char *prefix)
61 return 0;
64 -static int connect_gitdir_workingtree(int argc, const char **argv, const char *prefix)
66 - struct strbuf sb = STRBUF_INIT;
67 - const char *name, *path;
68 - char *sm_gitdir;
70 - if (argc != 3)
71 - BUG("submodule--helper connect-gitdir-workingtree <name> <path>");
73 - name = argv[1];
74 - path = argv[2];
76 - strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
77 - sm_gitdir = absolute_pathdup(sb.buf);
79 - connect_work_tree_and_git_dir(path, sm_gitdir, 0);
81 - strbuf_release(&sb);
82 - free(sm_gitdir);
84 - return 0;
87 #define SUPPORT_SUPER_PREFIX (1<<0)
89 struct cmd_struct {
90 @@ -2041,7 +2016,6 @@ static struct cmd_struct commands[] = {
91 {"name", module_name, 0},
92 {"clone", module_clone, 0},
93 {"update-clone", update_clone, 0},
94 - {"connect-gitdir-workingtree", connect_gitdir_workingtree, 0},
95 {"relative-path", resolve_relative_path, 0},
96 {"resolve-relative-url", resolve_relative_url, 0},
97 {"resolve-relative-url-test", resolve_relative_url_test, 0},
98 diff --git a/git-submodule.sh b/git-submodule.sh
99 index f7fd80345c..1cb2c0a31b 100755
100 --- a/git-submodule.sh
101 +++ b/git-submodule.sh
102 @@ -580,11 +580,6 @@ cmd_update()
103 die "$(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")"
106 - if ! $(git config -f "$(git rev-parse --git-common-dir)/modules/$name/config" core.worktree) 2>/dev/null
107 - then
108 - git submodule--helper connect-gitdir-workingtree "$name" "$sm_path"
109 - fi
111 if test "$subsha1" != "$sha1" || test -n "$force"
112 then
113 subforce=$force
114 diff --git a/submodule.c b/submodule.c
115 index 50cbf5f13e..a2b266fbfa 100644
116 --- a/submodule.c
117 +++ b/submodule.c
118 @@ -1534,18 +1534,6 @@ int bad_to_remove_submodule(const char *path, unsigned flags)
119 return ret;
122 -void submodule_unset_core_worktree(const struct submodule *sub)
124 - char *config_path = xstrfmt("%s/modules/%s/config",
125 - get_git_common_dir(), sub->name);
127 - if (git_config_set_in_file_gently(config_path, "core.worktree", NULL))
128 - warning(_("Could not unset core.worktree setting in submodule '%s'"),
129 - sub->path);
131 - free(config_path);
134 static const char *get_super_prefix_or_empty(void)
136 const char *s = get_super_prefix();
137 @@ -1711,8 +1699,6 @@ int submodule_move_head(const char *path,
139 if (is_empty_dir(path))
140 rmdir_or_warn(path);
142 - submodule_unset_core_worktree(sub);
145 out:
146 diff --git a/submodule.h b/submodule.h
147 index 7d476cefa7..e452919aa4 100644
148 --- a/submodule.h
149 +++ b/submodule.h
150 @@ -127,8 +127,6 @@ int submodule_move_head(const char *path,
151 const char *new_head,
152 unsigned flags);
154 -void submodule_unset_core_worktree(const struct submodule *sub);
157 * Prepare the "env_array" parameter of a "struct child_process" for executing
158 * a submodule by clearing any repo-specific environment variables, but
159 diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
160 index 5b56b23166..016391723c 100755
161 --- a/t/lib-submodule-update.sh
162 +++ b/t/lib-submodule-update.sh
163 @@ -235,7 +235,7 @@ reset_work_tree_to_interested () {
164 then
165 mkdir -p submodule_update/.git/modules/sub1/modules &&
166 cp -r submodule_update_repo/.git/modules/sub1/modules/sub2 submodule_update/.git/modules/sub1/modules/sub2
167 - # core.worktree is unset for sub2 as it is not checked out
168 + GIT_WORK_TREE=. git -C submodule_update/.git/modules/sub1/modules/sub2 config --unset core.worktree
169 fi &&
170 # indicate we are interested in the submodule:
171 git -C submodule_update config submodule.sub1.url "bogus" &&
172 @@ -709,8 +709,7 @@ test_submodule_recursing_with_args_common() {
173 git branch -t remove_sub1 origin/remove_sub1 &&
174 $command remove_sub1 &&
175 test_superproject_content origin/remove_sub1 &&
176 - ! test -e sub1 &&
177 - test_must_fail git config -f .git/modules/sub1/config core.worktree
178 + ! test -e sub1
181 # ... absorbing a .git directory along the way.
182 diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
183 index 7d3d984210..c0ffc1022a 100755
184 --- a/t/t7400-submodule-basic.sh
185 +++ b/t/t7400-submodule-basic.sh
186 @@ -984,11 +984,6 @@ test_expect_success 'submodule deinit should remove the whole submodule section
187 rmdir init
190 -test_expect_success 'submodule deinit should unset core.worktree' '
191 - test_path_is_file .git/modules/example/config &&
192 - test_must_fail git config -f .git/modules/example/config core.worktree
195 test_expect_success 'submodule deinit from subdirectory' '
196 git submodule update --init &&
197 git config submodule.example.foo bar &&
199 2.19.0.rc2.392.g5ba43deb5a