Skip to content

Commit f3e5dcd

Browse files
committed
Merge branch 'pk/subsub-fetch-fix'
An earlier attempt to fix "git fetch --recurse-submodules" broke another use case; revert it until a better fix is found. * pk/subsub-fetch-fix: Revert "submodules: fix of regression on fetching of non-init subsub-repo"
2 parents f3a112a + 7091499 commit f3e5dcd

File tree

2 files changed

+10
-67
lines changed

2 files changed

+10
-67
lines changed

submodule.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,12 @@ void prepare_submodule_repo_env(struct strvec *out)
499499
DEFAULT_GIT_DIR_ENVIRONMENT);
500500
}
501501

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+
502508
/*
503509
* Initialize a repository struct for a submodule based on the provided 'path'.
504510
*
@@ -1449,8 +1455,8 @@ static int get_next_submodule(struct child_process *cp,
14491455
if (task->repo) {
14501456
struct strbuf submodule_prefix = STRBUF_INIT;
14511457
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);
14541460
cp->git_cmd = 1;
14551461
if (!spf->quiet)
14561462
strbuf_addf(err, _("Fetching submodule %s%s\n"),
@@ -1499,9 +1505,9 @@ static int get_next_submodule(struct child_process *cp,
14991505
spf->prefix, task->sub->path);
15001506

15011507
child_process_init(cp);
1502-
prepare_submodule_repo_env(&cp->env_array);
1508+
prepare_submodule_repo_env_in_gitdir(&cp->env_array);
15031509
cp->git_cmd = 1;
1504-
cp->dir = task->repo->worktree;
1510+
cp->dir = task->repo->gitdir;
15051511

15061512
strvec_init(&cp->args);
15071513
strvec_pushv(&cp->args, spf->args.v);

t/t5526-fetch-submodules.sh

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -719,67 +719,4 @@ test_expect_success 'fetch new submodule commit intermittently referenced by sup
719719
)
720720
'
721721

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-
785722
test_done

0 commit comments

Comments
 (0)