From eca37a5121b788b1a89c86b10b78c235b731ee52 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Wed, 9 Aug 2023 11:30:11 +0200 Subject: [PATCH] Don't try any rebase --onto when both repos have matching HEADs If both integration.git and security.git, for a given branch, have already the same HEADs, then we don't need to rebase anything, because they are already the same. The only option to perform is to update the -lastbased branch to point to the same HEAD and forget. --- rebase_security/rebase_security.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rebase_security/rebase_security.sh b/rebase_security/rebase_security.sh index dd3d2f90..819d69ff 100755 --- a/rebase_security/rebase_security.sh +++ b/rebase_security/rebase_security.sh @@ -175,6 +175,16 @@ ${mydir}/../git_garbage_collector/git_garbage_collector.sh # (NOTE: checkout -B means create if branch doesn't exist or reset if it does.) $gitcmd checkout -B $securitybranch security/$securitybranch +# If integration.git and security.git HEADs are already the same, there is nothing +# to rebase. Just update lastbased to the very same HEAD and done. +if [ $(git rev-parse integration/$gitbranch) == $(git rev-parse security/$gitbranch) ]; then + info "integration.git and security.git ($gitbranch branch) already match. Nothing to rebase" + info "Both are pointing to $(git rev-parse integration/$gitbranch)" + info "Force pushing updated reference branch:" + $gitcmd push -f security integration/$gitbranch:$referencebranch + exit 0 # We are done! +fi + # Do the magic! # ABRACADABRA!!🌟 info "Rebasing security branch:"