From c82da07912d5fe23dd6ec0e261b6cd752dc4ceda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99=C3=ADnek?= Date: Thu, 1 Jul 2021 13:08:27 +0200 Subject: [PATCH 1/3] Allow -b and --all check if branch exists --- lib/git-subrepo | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/git-subrepo b/lib/git-subrepo index 42fd0ec9..cbc49bad 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 @@ -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 From 90b10823735a47163b76e40a7f10f14d9fe17b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99=C3=ADnek?= Date: Thu, 1 Jul 2021 13:51:26 +0200 Subject: [PATCH 2/3] Add branch name to messages --- lib/git-subrepo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git-subrepo b/lib/git-subrepo index cbc49bad..0abc7941 100755 --- a/lib/git-subrepo +++ b/lib/git-subrepo @@ -191,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 @@ -249,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" From c3b8efc87eb494d8c11f1a3b75a5aaad645c2301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99=C3=ADnek?= Date: Thu, 18 Nov 2021 16:17:38 +0100 Subject: [PATCH 3/3] Add branch name to another message --- lib/git-subrepo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git-subrepo b/lib/git-subrepo index 0abc7941..2153b9bf 100755 --- a/lib/git-subrepo +++ b/lib/git-subrepo @@ -230,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"