diff --git a/lib/git-subrepo b/lib/git-subrepo index 42fd0ec9..2153b9bf 100755 --- a/lib/git-subrepo +++ b/lib/git-subrepo @@ -157,17 +157,13 @@ main() { command-init if $all_wanted && [[ ! $command =~ ^(help|status)$ ]]; then - if [[ -n $subrepo_branch ]]; then - error "options --branch and --all are not compatible" - fi - # Run the command on all subrepos local args=( "${command_arguments[@]}" ) get-all-subrepos for subdir in ${subrepos[*]}; do command-prepare subrepo_remote= - subrepo_branch= + subrepo_branch=$override_branch command_arguments=( "$subdir" "${args[@]}" ) "command:$command" done @@ -195,7 +191,7 @@ command:clone() { local reclone_up_to_date=false subrepo:clone if "$reclone_up_to_date"; then - say "Subrepo '$subdir' is up to date." + say "Subrepo '$subdir' ($subrepo_branch) is up to date." return fi @@ -234,7 +230,7 @@ command:pull() { if OK; then say "Subrepo '$subdir' pulled from '$subrepo_remote' ($subrepo_branch)." elif [[ $CODE -eq -1 ]]; then - say "Subrepo '$subdir' is up to date." + say "Subrepo '$subdir' ($subrepo_branch) is up to date." elif [[ $CODE -eq 1 ]]; then error-join return "$CODE" @@ -253,7 +249,7 @@ command:push() { if OK; then say "Subrepo '$subdir' pushed to '$subrepo_remote' ($subrepo_branch)." elif [[ $CODE -eq -2 ]]; then - say "Subrepo '$subdir' has no new commits to push." + say "Subrepo '$subdir' ($subrepo_branch) has no new commits to push." elif [[ $CODE -eq 1 ]]; then error-join return "$CODE" @@ -694,6 +690,16 @@ subrepo:fetch() { error "Can't fetch subrepo. Remote is 'none' in '$subdir/.gitrepo'." fi + if $all_wanted && [[ -n $subrepo_branch ]]; then + o "Check if the remote branch ($subrepo_branch) exists." + OUT=true RUN git ls-remote --heads "$subrepo_remote" "$subrepo_branch" + if [[ -z $output ]]; then + SAY=false OUT=true RUN git config --file="$gitrepo" subrepo.branch + o "Remote branch ($subrepo_branch) in '$subrepo_remote' not exists, using branch ($output) from subrepo config." + subrepo_branch="$output" + fi + fi + o "Fetch the upstream: $subrepo_remote ($subrepo_branch)." RUN git fetch --no-tags --quiet "$subrepo_remote" "$subrepo_branch" OK || return