From f483adb65ce3845a400488bd289eb3b6eac4b53a Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 15 Apr 2024 15:28:36 +0300 Subject: [PATCH] Feat(submodules/remove): Cleanup Remove `.gitmodules` if it's empty. Remove `.git/modules` if it's empty. --- submodules/remove | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/submodules/remove b/submodules/remove index 90cb02f..1db57c2 100755 --- a/submodules/remove +++ b/submodules/remove @@ -23,4 +23,12 @@ fi git rm "$path" && rm -rf "`git rev-parse --git-dir`"/modules/"$name" && -exec git config --remove-section submodule."$name" +git config --remove-section submodule."$name" && + +if [ \! -s .gitmodules ]; then + git rm -f .gitmodules +fi && + +if [ -z $(ls -A "`git rev-parse --git-dir`/modules") ]; then + exec rmdir "`git rev-parse --git-dir`/modules" +fi -- 2.39.5