Git submodule deletion test

For test results, bug reports, announcements of new builds etc.

Moderators: another_commander, winston, Getafix

Post Reply
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 790
Joined: Sun Jun 20, 2010 6:00 pm

Git submodule deletion test

Post by mcarans »

Below are steps for deleting submodule cleanly shown on test repos submodule_deletion_parent and submodule_deletion_child:

1. Cloned parent repo:

Code: Select all

> git clone --filter=blob:none [email protected]:mcarans/submodule_deletion_parent.git
Cloning into 'submodule_deletion_parent'...
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Total 2 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (2/2), done.
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (1/1), 79 bytes | 79.00 KiB/s, done.
Updating files: 100% (1/1), done.
mcarans@Holly [~/Code/OoliteRelated] ○                                                                                                                                                                                   [py-'python'] [11:23:44]
> cd submodule_deletion_parent/
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main ✓                                                                                                                                                  
2. Added child repo:

Code: Select all

[py-'python'] [11:39:56]
130 > git submodule add https://github.com/mcarans/submodule_deletion_child.git
Cloning into '/home/mcarans/Code/OoliteRelated/submodule_deletion_parent/submodule_deletion_child'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (3/3), done.
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main S:2 ✗                                                                                                                                              [py-'python'] [11:40:15]
> git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   .gitmodules
        new file:   submodule_deletion_child

mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main S:2 ✗                                                                                                                                              [py-'python'] [11:40:59]
> git commit -m "Added submodule_deletion_child"
[main 95a24e8] Added submodule_deletion_child
 2 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 submodule_deletion_child
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main ↑1 ✓                                                                                                                                               [py-'python'] [11:41:25]
> git push origin main
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 415 bytes | 415.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:mcarans/submodule_deletion_parent.git
   66d66df..95a24e8  main -> main
Here is parent repo in GitHub showing child submodule:
Image

3. I deleted the parent repo submodule_deletion_parent locally so I could clone again recursively to ensure it is correct:

Code: Select all

> git clone --recursive --filter=blob:none [email protected]:mcarans/submodule_deletion_parent.git
Cloning into 'submodule_deletion_parent'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 2 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (4/4), done.
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 0), reused 1 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (2/2), 171 bytes | 171.00 KiB/s, done.
Updating files: 100% (3/3), done.
Submodule 'submodule_deletion_child' (https://github.com/mcarans/submodule_deletion_child.git) registered for path 'submodule_deletion_child'
Cloning into '/home/mcarans/Code/OoliteRelated/submodule_deletion_parent/submodule_deletion_child'...
remote: Enumerating objects: 3, done.        
remote: Counting objects: 100% (3/3), done.        
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)        
Receiving objects: 100% (3/3), done.
Submodule path 'submodule_deletion_child': checked out 'af72e49678ea5bfee2f492f3986f3b2c45eec0c6'
mcarans@Holly [~/Code/OoliteRelated] ○                                                                                                                                                                                   [py-'python'] [11:56:46]
> cd submodule_deletion_parent/
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main ✓                                                                                                                                                  [py-'python'] [11:56:53]
> ls
README.md  submodule_deletion_child
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main ✓                                                                                                                                                  [py-'python'] [11:56:56]
> ls submodule_deletion_child/
README.md
4. Here is the submodule deletion:

Code: Select all

mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main ✓                                                                                                                                                  [py-'python'] [11:56:58]
> git submodule deinit -f submodule_deletion_child
Cleared directory 'submodule_deletion_child'
Submodule 'submodule_deletion_child' (https://github.com/mcarans/submodule_deletion_child.git) unregistered for path 'submodule_deletion_child'
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main ✓                                                                                                                                                  [py-'python'] [11:57:16]
> git rm -f submodule_deletion_child
rm 'submodule_deletion_child'
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main S:2 ✗                                                                                                                                              [py-'python'] [11:57:26]
> rm -rf .git/modules/submodule_deletion_child
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main S:2 ✗                                                                                                                                              [py-'python'] [11:57:38]
> ls
README.md
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main S:2 ✗                                                                                                                                              [py-'python'] [11:57:40]
> 
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main S:2 ✗                                                                                                                                              [py-'python'] [11:58:08]
> 
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main S:2 ✗                                                                                                                                              [py-'python'] [11:58:09]
> cat .gitmodules
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main S:2 ✗                                                                                                                                              [py-'python'] [11:58:17]
> git commit -m "Deleted submodule_deletion_child"
[main 332982a] Deleted submodule_deletion_child
 2 files changed, 4 deletions(-)
 delete mode 160000 submodule_deletion_child
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± main ↑1 ✓                                                                                                                                               [py-'python'] [11:58:45]
> git push origin main
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 286 bytes | 286.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:mcarans/submodule_deletion_parent.git
   95a24e8..332982a  main -> main
Here is the parent repo with submodule removed:
Image

You can look at it direct here: https://github.com/mcarans/submodule_deletion_parent.

You can see https://github.com/mcarans/submodule_deletion_child was not deleted as we want.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 7207
Joined: Wed Feb 28, 2007 7:54 am

Re: Git submodule deletion test

Post by another_commander »

Looks good. I responded to the closed github PR, just one thing to check: see if you can switch smoothly back and forth to/from previous revisions You may have to do a few dummy commits before executing the submodule deletion to test this.
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 790
Joined: Sun Jun 20, 2010 6:00 pm

Re: Git submodule deletion test

Post by mcarans »

another_commander wrote: Thu Apr 02, 2026 5:26 am
Looks good. I responded to the closed github PR, just one thing to check: see if you can switch smoothly back and forth to/from previous revisions You may have to do a few dummy commits before executing the submodule deletion to test this.
I made a branch at the commit (the commit before I deleted the submodule):
https://github.com/mcarans/submodule_de ... 38afbee313

Code: Select all

> git checkout -b when_submodule_added 95a24e80c9e0c4025f37c89ac788b438afbee313
Switched to a new branch 'when_submodule_added'
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± when_submodule_added ✓                                                                                                                                  [py-'python'] [20:25:32]
> git submodule update --init --recursive
Submodule 'submodule_deletion_child' (https://github.com/mcarans/submodule_deletion_child.git) registered for path 'submodule_deletion_child'
Cloning into '/home/mcarans/Code/OoliteRelated/submodule_deletion_parent/submodule_deletion_child'...
Submodule path 'submodule_deletion_child': checked out 'af72e49678ea5bfee2f492f3986f3b2c45eec0c6'
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± when_submodule_added ✓                                                                                                                                  [py-'python'] [20:29:00]
> ls
README.md  submodule_deletion_child
mcarans@Holly [~/Code/OoliteRelated/submodule_deletion_parent] ± when_submodule_added ✓                                                                                                                                  [py-'python'] [20:29:05]
> ls -l submodule_deletion_child/
total 4
-rw-rw-r-- 1 mcarans mcarans 26 Apr  2 20:29 README.md
You can see the README.md from submodule_deletion_child. Here is the branch:
https://github.com/mcarans/submodule_de ... dule_added

I'll go ahead tomorrow with the PR unless you want me to test something else.
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 790
Joined: Sun Jun 20, 2010 6:00 pm

Re: Git submodule deletion test

Post by mcarans »

another_commander wrote: Thu Apr 02, 2026 5:26 am
Looks good. I responded to the closed github PR, just one thing to check: see if you can switch smoothly back and forth to/from previous revisions You may have to do a few dummy commits before executing the submodule deletion to test this.
I've made new PR: https://github.com/OoliteProject/oolite ... 67/changes
User avatar
Lone_Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 838
Joined: Wed Aug 08, 2007 10:59 pm
Location: Netherlands

Re: Git submodule deletion test

Post by Lone_Wolf »

No probems with running master after oolite-git package stopped downloading the deleted gitsubmodules.
OS : Arch Linux 64-bit - rolling release

From: The Netherlands, Europe

OXPs : My user page (needs updating)

Retired, occasionally active
User avatar
hiran
Theorethicist
Posts: 2656
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Git submodule deletion test

Post by hiran »

I never did this myself, but...

One git repository (=parent) declares others to be loaded as submodules.
As long as the declarations in the parent are changed, version control should allow to go back in time and still load the correct stuff.

But if the submodule's repository is removed there is no going back. So I guess we need to keep these additional repositories in OoliteProject for a long time even if unused, just for our history to work.
Sunshine - Moonlight - Good Times - Oolite
Post Reply