Revert "submodules: fix of regression on fetching of non-init subsub-repo"
This reverts commit 1b7ac4e6d4d490b224f5206af7418ed74e490608; in <CAN0XMOLiS_8JZKF_wW70BvRRxkDHyUoa=Z3ODtB_Bd6f5Y=7JQ@mail.gmail.com>, Ralf Thielow reports that "git fetch" with submodule.recurse set can result in a bogus and infinitely recursive fetching of the same submodule.
Junio C Hamano committed
Dec 2, 2020 at 15:07 UTC
7091499bc0a9bccd81a1c864de7b5f87a366480e
2 files changed
+10
-67
submodule.c
+10
-4
@@ -499,6 +499,12 @@ void prepare_submodule_repo_env(struct strvec *out)
499
DEFAULT_GIT_DIR_ENVIRONMENT);
500
}
501
502
+static void prepare_submodule_repo_env_in_gitdir(struct strvec *out)
503
+{
504
+ prepare_submodule_repo_env_no_git_dir(out);
505
+ strvec_pushf(out, "%s=.", GIT_DIR_ENVIRONMENT);
506
+}
507
+
508
/*
509
* Initialize a repository struct for a submodule based on the provided 'path'.
510
*
@@ -1449,8 +1455,8 @@ static int get_next_submodule(struct child_process *cp,
1455
if (task->repo) {
1456
struct strbuf submodule_prefix = STRBUF_INIT;
1457
child_process_init(cp);
1452
- cp->dir = task->repo->worktree;
1453
- prepare_submodule_repo_env(&cp->env_array);
1458
+ cp->dir = task->repo->gitdir;
1459
+ prepare_submodule_repo_env_in_gitdir(&cp->env_array);
1460
cp->git_cmd = 1;
1461
if (!spf->quiet)
1462
strbuf_addf(err, _("Fetching submodule %s%s\n"),
@@ -1499,9 +1505,9 @@ static int get_next_submodule(struct child_process *cp,
1505
spf->prefix, task->sub->path);
1506
1507
child_process_init(cp);
1502
- prepare_submodule_repo_env(&cp->env_array);
1508
+ prepare_submodule_repo_env_in_gitdir(&cp->env_array);
1509
cp->git_cmd = 1;
1504
- cp->dir = task->repo->worktree;
1510
+ cp->dir = task->repo->gitdir;
1511
1512
strvec_init(&cp->args);
1513
strvec_pushv(&cp->args, spf->args.v);
t/t5526-fetch-submodules.sh
-63
@@ -719,67 +719,4 @@ test_expect_success 'fetch new submodule commit intermittently referenced by sup
719
)
720
'
721
722
-add_commit_push () {
723
- dir="$1"
724
- msg="$2"
725
- shift 2
726
- git -C "$dir" add "$@" &&
727
- git -C "$dir" commit -a -m "$msg" &&
728
- git -C "$dir" push
729
-}
730
-
731
-compare_refs_in_dir () {
732
- fail= &&
733
- if test "x$1" = 'x!'
734
- then
735
- fail='!' &&
736
- shift
737
- fi &&
738
- git -C "$1" rev-parse --verify "$2" >expect &&
739
- git -C "$3" rev-parse --verify "$4" >actual &&
740
- eval $fail test_cmp expect actual
741
-}
742
-
743
-
744
-test_expect_success 'setup nested submodule fetch test' '
745
- # does not depend on any previous test setups
746
-
747
- for repo in outer middle inner
748
- do
749
- (
750
- git init --bare $repo &&
751
- git clone $repo ${repo}_content &&
752
- echo "$repo" >"${repo}_content/file" &&
753
- add_commit_push ${repo}_content "initial" file
754
- ) || return 1
755
- done &&
756
-
757
- git clone outer A &&
758
- git -C A submodule add "$pwd/middle" &&
759
- git -C A/middle/ submodule add "$pwd/inner" &&
760
- add_commit_push A/middle/ "adding inner sub" .gitmodules inner &&
761
- add_commit_push A/ "adding middle sub" .gitmodules middle &&
762
-
763
- git clone outer B &&
764
- git -C B/ submodule update --init middle &&
765
-
766
- compare_refs_in_dir A HEAD B HEAD &&
767
- compare_refs_in_dir A/middle HEAD B/middle HEAD &&
768
- test -f B/file &&
769
- test -f B/middle/file &&
770
- ! test -f B/middle/inner/file &&
771
-
772
- echo "change on inner repo of A" >"A/middle/inner/file" &&
773
- add_commit_push A/middle/inner "change on inner" file &&
774
- add_commit_push A/middle "change on inner" inner &&
775
- add_commit_push A "change on inner" middle
776
-'
777
-
778
-test_expect_success 'fetching a superproject containing an uninitialized sub/sub project' '
779
- # depends on previous test for setup
780
-
781
- git -C B/ fetch &&
782
- compare_refs_in_dir A origin/master B origin/master
783
-'
784
-
722
test_done