Description
Describe the bug
My submodule was added for a non-default branch. The "in" script calls:
git submodule update --init --no-fetch --depth=1 $submodule_parameters "$submodule_path"
With git version 2.45.1 this effectively, creates a shallow clone of the default branch and then calls deepen_shallow_clone_until_ref_is_found_then_check_out 1 ref which is of no help here because it doesn't pass $ref
when it calls get fetch
.
Without --no-fetch git additionally fetches the necessary commit and because the repo is already shallow this commit is also fetched in a shallow manner. By the time deepen_shallow_clone_until_ref_is_found_then_check_out
is called there are two shallow heads: the default branch head and the recorded submodule. Perhaps the authors wanted to have a connected history between the remote branch head and the recorded commit. If you remove "--no-fetch" the two shallow commits will be disconnected from each other even if they belong to the same remote branch, but I think it's an acceptable tradeoff. Also, the custom deepen command won't be necessary after that.
I have this problem on a Concourse server and it's reproducible with the latest in
script when I just type commands in terminal.
Reproduction steps
echo "# create demo repo"
rm -rf /tmp/reproduce
mkdir -p /tmp/reproduce/get /tmp/reproduce/bin
curl -q -L -o /tmp/reproduce/bin/deepen_shallow_clone_until_ref_is_found_then_check_out "https://raw.githubusercontent.com/concourse/git-resource/702bf5aa6bb3268ae366a13b49fff9471a321a1d/assets/deepen_shallow_clone_until_ref_is_found_then_check_out"
chmod +x /tmp/reproduce/bin/deepen_shallow_clone_until_ref_is_found_then_check_out
cd /tmp/reproduce/get
git init
git submodule init
git submodule add -b latest https://github.com/mendix/docker-mendix-buildpack.git
cd docker-mendix-buildpack/
git reset --hard 07f286acff13ce7fe901241fd46454ae56f679ed
cd ..
git commit -a -mroot
echo "# cleanup"
git submodule deinit --all -f
rm -rf .git/modules/docker-mendix-buildpack
# `in` script variables
submodule_name=docker-mendix-buildpack
bin_dir=/tmp/reproduce/bin
depth=1
depthflag=--depth=1
submodule_path="$(git config --file .gitmodules --get "submodule.${submodule_name}.path")"
echo "# reproduce"
git submodule sync
git config "submodule.${submodule_name}.update" '!'"$bin_dir/deepen_shallow_clone_until_ref_is_found_then_check_out $depth"
git submodule update --init $depthflag $submodule_parameters "$submodule_path"
git submodule deinit --all -f
rm -rf .git/modules/docker-mendix-buildpack
git submodule sync
git config "submodule.${submodule_name}.update" '!'"$bin_dir/deepen_shallow_clone_until_ref_is_found_then_check_out $depth"
git submodule update --init --no-fetch $depthflag $submodule_parameters "$submodule_path"
Output:
+ echo '# create demo repo'
# create demo repo
+ rm -rf /tmp/reproduce
+ mkdir -p /tmp/reproduce/get /tmp/reproduce/bin
+ curl -q -L -o /tmp/reproduce/bin/deepen_shallow_clone_until_ref_is_found_then_check_out https://raw.githubusercontent.com/concourse/git-resource/702bf5aa6bb3268ae366a13b49fff9471a321a1d/assets/deepen_shallow_clone_until_ref_is_found_then_check_out
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1718 100 1718 0 0 6869 0 --:--:-- --:--:-- --:--:-- 6955
+ chmod +x /tmp/reproduce/bin/deepen_shallow_clone_until_ref_is_found_then_check_out
+ cd /tmp/reproduce/get
+ git init
Initialized empty Git repository in /tmp/reproduce/get/.git/
+ git submodule init
+ git submodule add -b latest https://github.com/mendix/docker-mendix-buildpack.git
Cloning into '/tmp/reproduce/get/docker-mendix-buildpack'...
remote: Enumerating objects: 1314, done.
remote: Counting objects: 100% (411/411), done.
remote: Compressing objects: 100% (186/186), done.
Receiving objectsremote: Total 1314 (delta 249), reused 347 (delta 206), pack-reused 903 (from 1)
Receiving objects: 100% (1314/1314), 329.16 KiB | 1.73 MiB/s, done.
Resolving deltas: 100% (750/750), done.
+ cd docker-mendix-buildpack/
+ git reset --hard 07f286acff13ce7fe901241fd46454ae56f679ed
HEAD is now at 07f286a Merge pull request #201 from mendix/mxbuild-externally
+ cd ..
+ git commit -a -mroot
[master (root-commit) fa806e1] root
2 files changed, 5 insertions(+)
create mode 100644 .gitmodules
create mode 160000 docker-mendix-buildpack
+ echo '# cleanup'
# cleanup
+ git submodule deinit --all -f
Cleared directory 'docker-mendix-buildpack'
Submodule 'docker-mendix-buildpack' (https://github.com/mendix/docker-mendix-buildpack.git) unregistered for path 'docker-mendix-buildpack'
+ rm -rf .git/modules/docker-mendix-buildpack
+ submodule_name=docker-mendix-buildpack
+ bin_dir=/tmp/reproduce/bin
+ depth=1
+ depthflag=--depth=1
++ git config --file .gitmodules --get submodule.docker-mendix-buildpack.path
+ submodule_path=docker-mendix-buildpack
+ echo '# reproduce'
# reproduce
+ git submodule sync
+ git config submodule.docker-mendix-buildpack.update '!/tmp/reproduce/bin/deepen_shallow_clone_until_ref_is_found_then_check_out 1'
+ git submodule update --init --depth=1 docker-mendix-buildpack
Submodule 'docker-mendix-buildpack' (https://github.com/mendix/docker-mendix-buildpack.git) registered for path 'docker-mendix-buildpack'
Cloning into '/tmp/reproduce/get/docker-mendix-buildpack'...
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 27 (delta 9), reused 10 (delta 2), pack-reused 0 (from 0)
Unpacking objects: 100% (27/27), 17.39 KiB | 282.00 KiB/s, done.
From https://github.com/mendix/docker-mendix-buildpack
* branch 07f286acff13ce7fe901241fd46454ae56f679ed -> FETCH_HEAD
Submodule path 'docker-mendix-buildpack': '/tmp/reproduce/bin/deepen_shallow_clone_until_ref_is_found_then_check_out 1 07f286acff13ce7fe901241fd46454ae56f679ed'
+ git submodule deinit --all -f
Cleared directory 'docker-mendix-buildpack'
Submodule 'docker-mendix-buildpack' (https://github.com/mendix/docker-mendix-buildpack.git) unregistered for path 'docker-mendix-buildpack'
+ rm -rf .git/modules/docker-mendix-buildpack
+ git submodule sync
+ git config submodule.docker-mendix-buildpack.update '!/tmp/reproduce/bin/deepen_shallow_clone_until_ref_is_found_then_check_out 1'
+ git submodule update --init --no-fetch --depth=1 docker-mendix-buildpack
Submodule 'docker-mendix-buildpack' (https://github.com/mendix/docker-mendix-buildpack.git) registered for path 'docker-mendix-buildpack'
Cloning into '/tmp/reproduce/get/docker-mendix-buildpack'...
Could not find ref 07f286acff13ce7fe901241fd46454ae56f679ed~0 in a shallow clone of depth 1
Deepening the shallow clone by an additional 2...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 11 (delta 6), reused 5 (delta 1), pack-reused 0 (from 0)
Unpacking objects: 100% (11/11), 1.89 KiB | 71.00 KiB/s, done.
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
From https://github.com/mendix/docker-mendix-buildpack
* [new tag] v3.5.3 -> v3.5.3
Could not find ref 07f286acff13ce7fe901241fd46454ae56f679ed~0 in a shallow clone of depth 3
Deepening the shallow clone by an additional 4...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (45/45), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 29 (delta 16), reused 19 (delta 6), pack-reused 0 (from 0)
Unpacking objects: 100% (29/29), 5.32 KiB | 85.00 KiB/s, done.
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
From https://github.com/mendix/docker-mendix-buildpack
* [new tag] v3.5.1 -> v3.5.1
* [new tag] v3.5.2 -> v3.5.2
Could not find ref 07f286acff13ce7fe901241fd46454ae56f679ed~0 in a shallow clone of depth 7
Deepening the shallow clone by an additional 8...
remote: Enumerating objects: 133, done.
remote: Counting objects: 100% (111/111), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 81 (delta 48), reused 61 (delta 29), pack-reused 0 (from 0)
Unpacking objects: 100% (81/81), 15.64 KiB | 85.00 KiB/s, done.
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
From https://github.com/mendix/docker-mendix-buildpack
* [new tag] v3.3.0 -> v3.3.0
* [new tag] v3.3.1 -> v3.3.1
* [new tag] v3.4.0 -> v3.4.0
* [new tag] v3.5.0 -> v3.5.0
Could not find ref 07f286acff13ce7fe901241fd46454ae56f679ed~0 in a shallow clone of depth 15
Deepening the shallow clone by an additional 16...
remote: Enumerating objects: 365, done.
remote: Counting objects: 100% (307/307), done.
remote: Compressing objects: 100% (124/124), done.
remote: Total 262 (delta 166), reused 215 (delta 123), pack-reused 0 (from 0)
Receiving objects: 100% (262/262), 48.17 KiB | 1.93 MiB/s, done.
Resolving deltas: 100% (166/166), completed with 21 local objects.
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
From https://github.com/mendix/docker-mendix-buildpack
* [new tag] 3.0.2 -> 3.0.2
* [new tag] v2.0.0 -> v2.0.0
* [new tag] v2.1.0 -> v2.1.0
* [new tag] v2.2.0 -> v2.2.0
* [new tag] v3.0.0 -> v3.0.0
* [new tag] v3.0.1 -> v3.0.1
* [new tag] v3.1.0 -> v3.1.0
* [new tag] v3.1.1 -> v3.1.1
* [new tag] v3.2.0 -> v3.2.0
Could not find ref 07f286acff13ce7fe901241fd46454ae56f679ed~0 in a shallow clone of depth 31
Deepening the shallow clone by an additional 32...
remote: Enumerating objects: 619, done.
remote: Counting objects: 100% (549/549), done.
remote: Compressing objects: 100% (210/210), done.
remote: Total 480 (delta 280), reused 466 (delta 267), pack-reused 0 (from 0)
Receiving objects: 100% (480/480), 101.71 KiB | 2.42 MiB/s, done.
Resolving deltas: 100% (280/280), completed with 25 local objects.
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
From https://github.com/mendix/docker-mendix-buildpack
* [new tag] 1.2.0 -> 1.2.0
* [new tag] 1.4.0 -> 1.4.0
* [new tag] 1.5.0 -> 1.5.0
* [new tag] 1.6.0 -> 1.6.0
* [new tag] 1.7.0 -> 1.7.0
* [new tag] v1.0.0 -> v1.0.0
* [new tag] v1.2.0 -> v1.2.0
* [new tag] v1.3.0 -> v1.3.0
* [new tag] v1.4.0 -> v1.4.0
* [new tag] v1.5.0 -> v1.5.0
* [new tag] v1.6.0 -> v1.6.0
* [new tag] v1.7.0 -> v1.7.0
* [new tag] v2.3.0 -> v2.3.0
* [new tag] v2.3.1 -> v2.3.1
* [new tag] v2.3.2 -> v2.3.2
* [new tag] v2.4.0 -> v2.4.0
Could not find ref 07f286acff13ce7fe901241fd46454ae56f679ed~0 in a shallow clone of depth 63
Deepening the shallow clone by an additional 64...
remote: Enumerating objects: 116, done.
remote: Counting objects: 100% (101/101), done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 70 (delta 37), reused 64 (delta 31), pack-reused 0 (from 0)
Unpacking objects: 100% (70/70), 22.36 KiB | 154.00 KiB/s, done.
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
From https://github.com/mendix/docker-mendix-buildpack
* [new tag] v1.0.0-beta -> v1.0.0-beta
Reached max depth of the origin repo while deepening the shallow clone, it's a deep clone now
fatal: unable to read tree (07f286acff13ce7fe901241fd46454ae56f679ed)
fatal: Execution of '/tmp/reproduce/bin/deepen_shallow_clone_until_ref_is_found_then_check_out 1 07f286acff13ce7fe901241fd46454ae56f679ed' failed in submodule path 'docker-mendix-buildpack'
Expected behavior
no error
Additional context
No response