From: Oleg Broytman Date: Mon, 15 Apr 2024 12:28:36 +0000 (+0300) Subject: Feat(submodules/remove): Cleanup X-Git-Url: https://git.phdru.name/?p=git-scripts.git;a=commitdiff_plain;h=f483adb65ce3845a400488bd289eb3b6eac4b53a Feat(submodules/remove): Cleanup Remove `.gitmodules` if it's empty. Remove `.git/modules` if it's empty. --- 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