From b2394d577f4463785a3a4b661edcaae8ef6220d5 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Thu, 9 Nov 2017 19:07:48 -0500 Subject: [PATCH] handling branches a little better the pull hopefully is now going to always be correct. not sure about push yet. --- scripts/rev_control/version_control.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/rev_control/version_control.sh b/scripts/rev_control/version_control.sh index 9f955d28..3eaa05ba 100644 --- a/scripts/rev_control/version_control.sh +++ b/scripts/rev_control/version_control.sh @@ -86,8 +86,8 @@ function do_checkin() retval+=${PIPESTATUS[0]} # upload any changes to the upstream repo so others can see them. - if [ "$(git_branch_name)" != "master" ]; then - git push origin "$(git_branch_name)" 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs + if [ "$(my_branch_name)" != "master" ]; then + git push origin "$(my_branch_name)" 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs retval+=${PIPESTATUS[0]} fi @@ -218,9 +218,15 @@ function squash_first_few_crs() # a helpful method that reports the git branch for the current directory's # git repository. -function git_branch_name() +function my_branch_name() { - echo "$(git branch | grep \* | cut -d ' ' -f2-)" + echo "$(git branch | grep \* | cut -d ' ' -f2)" +} + +# this reports the upstream branch for the current repo. +function parent_branch_name() +{ + echo "$(git branch -vv | grep \* | cut -d ' ' -f2)" } # gets the latest versions of the assets from the upstream repository. @@ -256,12 +262,10 @@ function do_update() $blatt retval=0 - if [ "$(git_branch_name)" != "master" ]; then - git pull origin master 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs - retval+=${PIPESTATUS[0]} - fi + git pull origin "$(parent_branch_name)" 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs + retval+=${PIPESTATUS[0]} - git pull 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs + git pull origin "$(my_branch_name)" 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs retval+=${PIPESTATUS[0]} fi else -- 2.34.1