git-sortmodules (279B)
1 #!/bin/sh 2 3 awk '/^\[submodule/ { count++; smods[count] = $0; next } 4 /^\t/ { smods[count] = smods[count] $0 } 5 END { for (line in smods) print smods[line] }' \ 6 .gitmodules \ 7 | sort \ 8 | awk '{ gsub("\t", "\n\t"); print }' \ 9 > .gitmodules.new && mv .gitmodules.new .gitmodules