diff --git a/lib/git/repo_index.sh b/lib/git/repo_index.sh index b197d49..3d2e9c7 100644 --- a/lib/git/repo_index.sh +++ b/lib/git/repo_index.sh @@ -68,8 +68,8 @@ function git_index() { elif [ "$1" = "--list" ] || [ "$1" = "-l" ]; then echo -e "$_bld_col$(_git_index_count)$_txt_col Git repositories in $_bld_col$GIT_REPO_DIR$_txt_col:\n" for repo in $(_git_index_dirs_without_home); do - echo $(basename $repo) : $repo - done | sort | column -t -s ':' + echo $(basename $repo | sed "s/ /_/g") : $repo + done | sort -t ":" -k1,1 | column -t -s ':' elif [ "$1" = "--count-by-host" ]; then echo -e "=== Producing a report of the number of repos per host...\n" _git_index_batch_cmd git remote -v | \grep "origin.*(fetch)" | @@ -148,8 +148,8 @@ function _rebuild_git_index() { # Get repos from src dir and custom dirs, then sort by basename IFS=$'\n' for repo in $(echo -e "$(_find_git_repos)\n$(echo $GIT_REPOS | sed "s/:/\\\\n/g")"); do - echo $(basename $repo | sed "s/ /_/g") $repo - done | sort | cut -d " " -f2- >| "$GIT_REPO_DIR/.git_index" + echo $(basename $repo | sed "s/ /_/g"):$repo + done | sort -t ":" -k1,1 | cut -d ":" -f2- >| "$GIT_REPO_DIR/.git_index" unset IFS if [ "$1" != "--silent" ]; then diff --git a/test/lib/git/repo_index_test.sh b/test/lib/git/repo_index_test.sh index f7006ed..c2d2571 100755 --- a/test/lib/git/repo_index_test.sh +++ b/test/lib/git/repo_index_test.sh @@ -94,16 +94,19 @@ test_repo_index_command() { git_index --rebuild > /dev/null # Test that all repos are detected, and sorted alphabetically - assertIncludes "$(index_no_newlines)" "bitbucket.*\ -blue_submodule.*\ -github.*\ -green_submodule.*\ -red_submodule.*\ -source_forge.*\ -submodules_everywhere.*\ -test_repo_11.*\ -test_repo_1" - + assertIncludes "$(index_no_newlines)" $( + cat <