summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2018-07-05 10:31:54 +0100
committerFrediano Ziglio <fziglio@redhat.com>2018-07-05 10:31:54 +0100
commitb6ded0122c02dd113acaa4bc2db562cf523945ff (patch)
treebe53a39e71ac537adb4629212b7bd1970ff6ba90
parent1a86711ff7e6f9a8944fccb388e0d3afd1738c1b (diff)
rebasepp: Do not attempt to push on remotes which we don't want
REMOTE_PUSH specify the remote which we want to update, if a branch is not going to that remote do not push it.
-rwxr-xr-xspice-server/rebase21
1 files changed, 17 insertions, 4 deletions
diff --git a/spice-server/rebase b/spice-server/rebase
index 2c90db6..db56751 100755
--- a/spice-server/rebase
+++ b/spice-server/rebase
@@ -129,13 +129,26 @@ all_branches() {
git show-ref --heads | perl -ne 'print $1 if m, refs/heads/(.*)$,s'
}
+# get remote based on branch
+branch_get_remote() {
+ local branch="$1"
+ {
+ git config "branch.${branch}.pushRemote" || \
+ git config "remote.pushDefault" || \
+ git config "branch.${branch}.remote";
+ } 2> /dev/null
+}
+
branch_need_push() {
local branch="$1" remote
if [ -n "$REMOTE_PUSH" ]; then
- remote=$(get_id "remotes/$REMOTE_PUSH/$branch" 2> /dev/null) && {
- if [ "$remote" != "" -a "$(get_id heads/$branch)" != "$remote" ]; then
- return 0
- fi
+ # check that the upstream for this branch is our specified remote
+ remote=$(branch_get_remote "$branch") && [ "$REMOTE_PUSH" = "$remote" ] && {
+ remote=$(get_id "remotes/$REMOTE_PUSH/$branch" 2> /dev/null) && {
+ if [ "$remote" != "" -a "$(get_id heads/$branch)" != "$remote" ]; then
+ return 0
+ fi
+ }
}
fi
return 1