git-submodule: replace duplicated code with a module_list function