From 5b2c151c40712fd549a0632fda9ed7d39658afe6 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sun, 9 Sep 2018 19:10:26 -0700 Subject: [PATCH] debian: apply two last-minute regression fixes Git 2.19 is likely to include these two patches to address regressions discovered at the last minute. Apply them now so they get some early exposure. Fixes: https://bugs.debian.org/907587 Signed-off-by: Jonathan Nieder --- debian/changelog | 13 ++ ...01-http-backend-allow-empty-CONTENT_LENGTH.diff | 65 +++++++ ...rt-Merge-branch-sb-submodule-core-worktree.diff | 200 +++++++++++++++++++++ debian/patches/series | 2 + 4 files changed, 280 insertions(+) create mode 100644 debian/patches/0001-http-backend-allow-empty-CONTENT_LENGTH.diff create mode 100644 debian/patches/0002-Revert-Merge-branch-sb-submodule-core-worktree.diff create mode 100644 debian/patches/series diff --git a/debian/changelog b/debian/changelog index 6724ee6044..ec18fd925a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +git (1:2.19.0~rc2-2) unstable; urgency=low + + * debian/patches: + * 0001-http-backend-allow-empty-CONTENT_LENGTH: new from + upstream: http-backend: treat empty CONTENT_LENGTH as absent + (closes: #907587). + * 0002-Revert-Merge-branch-sb-submodule-core-worktree.diff: new + from upstream: stop setting and unsetting core.worktree in + submodules, since the code to do so does not handle submodules + with an embedded .git directory (thx Allan Sandfeld Jensen). + + -- Jonathan Nieder Sun, 09 Sep 2018 19:08:55 -0700 + git (1:2.19.0~rc2-1) unstable; urgency=low * new upstream release candidate. diff --git a/debian/patches/0001-http-backend-allow-empty-CONTENT_LENGTH.diff b/debian/patches/0001-http-backend-allow-empty-CONTENT_LENGTH.diff new file mode 100644 index 0000000000..42f76e47c3 --- /dev/null +++ b/debian/patches/0001-http-backend-allow-empty-CONTENT_LENGTH.diff @@ -0,0 +1,65 @@ +From 46e5466d0b34ce8391b899fa402f700823afcf97 Mon Sep 17 00:00:00 2001 +From: Max Kirillov +Date: Fri, 7 Sep 2018 06:36:07 +0300 +Subject: http-backend: allow empty CONTENT_LENGTH +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +commit 574c513e8dda5598e9e08e8ca2a048bf120a5709 upstream. + +According to RFC3875, empty environment variable is equivalent to unset, +and for CONTENT_LENGTH it should mean zero body to read. + +However, unset CONTENT_LENGTH is also used for chunked encoding to indicate +reading until EOF. At least, the test "large fetch-pack requests can be split +across POSTs" from t5551 starts faliing, if unset or empty CONTENT_LENGTH is +treated as zero length body. So keep the existing behavior as much as possible. + +Add a test for the case. + +Reported-By: Jelmer Vernooij +Signed-off-by: Max Kirillov +Signed-off-by: Junio C Hamano +Signed-off-by: Jonathan Nieder +--- + http-backend.c | 2 +- + t/t5562-http-backend-content-length.sh | 11 +++++++++++ + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/http-backend.c b/http-backend.c +index 88c38c834b..458642ef72 100644 +--- a/http-backend.c ++++ b/http-backend.c +@@ -353,7 +353,7 @@ static ssize_t get_content_length(void) + ssize_t val = -1; + const char *str = getenv("CONTENT_LENGTH"); + +- if (str && !git_parse_ssize_t(str, &val)) ++ if (str && *str && !git_parse_ssize_t(str, &val)) + die("failed to parse CONTENT_LENGTH: %s", str); + return val; + } +diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh +index 43570ce120..f94d01f69e 100755 +--- a/t/t5562-http-backend-content-length.sh ++++ b/t/t5562-http-backend-content-length.sh +@@ -153,4 +153,15 @@ test_expect_success 'CONTENT_LENGTH overflow ssite_t' ' + grep "fatal:.*CONTENT_LENGTH" err + ' + ++test_expect_success 'empty CONTENT_LENGTH' ' ++ env \ ++ QUERY_STRING=/repo.git/HEAD \ ++ PATH_TRANSLATED="$PWD"/.git/HEAD \ ++ GIT_HTTP_EXPORT_ALL=TRUE \ ++ REQUEST_METHOD=GET \ ++ CONTENT_LENGTH="" \ ++ git http-backend act.out 2>act.err && ++ verify_http_result "200 OK" ++' ++ + test_done +-- +2.19.0.rc2.392.g5ba43deb5a + diff --git a/debian/patches/0002-Revert-Merge-branch-sb-submodule-core-worktree.diff b/debian/patches/0002-Revert-Merge-branch-sb-submodule-core-worktree.diff new file mode 100644 index 0000000000..473cbd7a4d --- /dev/null +++ b/debian/patches/0002-Revert-Merge-branch-sb-submodule-core-worktree.diff @@ -0,0 +1,200 @@ +From b67b127881cf743e642636f4041742341abac373 Mon Sep 17 00:00:00 2001 +From: Jonathan Nieder +Date: Fri, 7 Sep 2018 17:09:46 -0700 +Subject: Revert "Merge branch 'sb/submodule-core-worktree'" + +commit f178c13fdac42763a7aa58bf260aa67d9f4393ec upstream. + +This reverts commit 7e25437d35a70791b345872af202eabfb3e1a8bc, reversing +changes made to 00624d608cc69bd62801c93e74d1ea7a7ddd6598. + +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 +Helped-by: Stefan Beller +Signed-off-by: Jonathan Nieder +Signed-off-by: Junio C Hamano +Signed-off-by: Jonathan Nieder +--- + builtin/submodule--helper.c | 26 -------------------------- + git-submodule.sh | 5 ----- + submodule.c | 14 -------------- + submodule.h | 2 -- + t/lib-submodule-update.sh | 5 ++--- + t/t7400-submodule-basic.sh | 5 ----- + 6 files changed, 2 insertions(+), 55 deletions(-) + +diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c +index b56028ba9d..f6fb8991f3 100644 +--- a/builtin/submodule--helper.c ++++ b/builtin/submodule--helper.c +@@ -1123,8 +1123,6 @@ static void deinit_submodule(const char *path, const char *prefix, + if (!(flags & OPT_QUIET)) + printf(format, displaypath); + +- submodule_unset_core_worktree(sub); +- + strbuf_release(&sb_rm); + } + +@@ -2005,29 +2003,6 @@ 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 = 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 { +@@ -2041,7 +2016,6 @@ 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}, +diff --git a/git-submodule.sh b/git-submodule.sh +index f7fd80345c..1cb2c0a31b 100755 +--- a/git-submodule.sh ++++ b/git-submodule.sh +@@ -580,11 +580,6 @@ 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 +diff --git a/submodule.c b/submodule.c +index 50cbf5f13e..a2b266fbfa 100644 +--- a/submodule.c ++++ b/submodule.c +@@ -1534,18 +1534,6 @@ int bad_to_remove_submodule(const char *path, unsigned flags) + return ret; + } + +-void submodule_unset_core_worktree(const struct submodule *sub) +-{ +- char *config_path = xstrfmt("%s/modules/%s/config", +- get_git_common_dir(), sub->name); +- +- if (git_config_set_in_file_gently(config_path, "core.worktree", NULL)) +- warning(_("Could not unset core.worktree setting in submodule '%s'"), +- sub->path); +- +- free(config_path); +-} +- + static const char *get_super_prefix_or_empty(void) + { + const char *s = get_super_prefix(); +@@ -1711,8 +1699,6 @@ int submodule_move_head(const char *path, + + if (is_empty_dir(path)) + rmdir_or_warn(path); +- +- submodule_unset_core_worktree(sub); + } + } + out: +diff --git a/submodule.h b/submodule.h +index 7d476cefa7..e452919aa4 100644 +--- a/submodule.h ++++ b/submodule.h +@@ -127,8 +127,6 @@ int submodule_move_head(const char *path, + const char *new_head, + unsigned flags); + +-void submodule_unset_core_worktree(const struct submodule *sub); +- + /* + * Prepare the "env_array" parameter of a "struct child_process" for executing + * a submodule by clearing any repo-specific environment variables, but +diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh +index 5b56b23166..016391723c 100755 +--- a/t/lib-submodule-update.sh ++++ b/t/lib-submodule-update.sh +@@ -235,7 +235,7 @@ reset_work_tree_to_interested () { + then + mkdir -p submodule_update/.git/modules/sub1/modules && + cp -r submodule_update_repo/.git/modules/sub1/modules/sub2 submodule_update/.git/modules/sub1/modules/sub2 +- # core.worktree is unset for sub2 as it is not checked out ++ GIT_WORK_TREE=. git -C submodule_update/.git/modules/sub1/modules/sub2 config --unset core.worktree + fi && + # indicate we are interested in the submodule: + git -C submodule_update config submodule.sub1.url "bogus" && +@@ -709,8 +709,7 @@ test_submodule_recursing_with_args_common() { + git branch -t remove_sub1 origin/remove_sub1 && + $command remove_sub1 && + test_superproject_content origin/remove_sub1 && +- ! test -e sub1 && +- test_must_fail git config -f .git/modules/sub1/config core.worktree ++ ! test -e sub1 + ) + ' + # ... absorbing a .git directory along the way. +diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh +index 7d3d984210..c0ffc1022a 100755 +--- a/t/t7400-submodule-basic.sh ++++ b/t/t7400-submodule-basic.sh +@@ -984,11 +984,6 @@ test_expect_success 'submodule deinit should remove the whole submodule section + rmdir init + ' + +-test_expect_success 'submodule deinit should unset core.worktree' ' +- test_path_is_file .git/modules/example/config && +- test_must_fail git config -f .git/modules/example/config core.worktree +-' +- + test_expect_success 'submodule deinit from subdirectory' ' + git submodule update --init && + git config submodule.example.foo bar && +-- +2.19.0.rc2.392.g5ba43deb5a + diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000000..a4638f0073 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,2 @@ +0001-http-backend-allow-empty-CONTENT_LENGTH.diff +0002-Revert-Merge-branch-sb-submodule-core-worktree.diff -- 2.11.4.GIT