@@ -75,6 +75,7 @@ add_submodule()
7575 local submodule=" $2 "
7676 local path=" ${3:- $submodule } "
7777 echo " +++ adding submodule $submodule to repo $repo "
78+ mkdir -p " $repo /$( dirname " $path " ) "
7879 git -C " $repo " submodule add ../" $submodule " " $path "
7980 git -C " $repo " add .
8081 git -C " $repo " commit -m " add submodule"
@@ -236,6 +237,18 @@ check_tar_content()
236237 check_tar_content test.tar " ${tar_files[@]} "
237238}
238239
240+ @test " repo with submodule, submodule in subfolder" {
241+ create_repo alpha
242+ create_repo beta
243+ add_submodule alpha beta subdir/beta
244+ cd alpha
245+ run_git_archive_all -o test.tar $( git rev-parse HEAD)
246+ local tar_files=(.gitmodules)
247+ repo_files tar_files+ alpha
248+ repo_files tar_files+ beta subdir/beta/
249+ check_tar_content test.tar " ${tar_files[@]} "
250+ }
251+
239252@test " repo with submodule, gzipped tar archive" {
240253 create_repo alpha
241254 create_repo beta
@@ -367,6 +380,22 @@ check_tar_content()
367380 check_tar_content test.tar " ${tar_files[@]} "
368381}
369382
383+ @test " repo with recursive submodules, submodules in subfolders" {
384+ create_repo alpha
385+ create_repo beta
386+ create_repo gamma
387+ add_submodule beta gamma other_subdir/gamma
388+ add_submodule alpha beta subdir/beta
389+ cd alpha
390+ git submodule update --init --recursive
391+ run_git_archive_all -o test.tar --fail-missing $( git rev-parse HEAD)
392+ local tar_files=(.gitmodules subdir/beta/.gitmodules)
393+ repo_files tar_files+ alpha
394+ repo_files tar_files+ beta subdir/beta/
395+ repo_files tar_files+ gamma subdir/beta/other_subdir/gamma/
396+ check_tar_content test.tar " ${tar_files[@]} "
397+ }
398+
370399@test " repo with recursive submodules, non-recursive archive" {
371400 create_repo alpha
372401 create_repo beta
0 commit comments