From f32ca9d7cf99db7dad823f0adafc6d899fd534a8 Mon Sep 17 00:00:00 2001 From: Joe Block Date: Thu, 4 Jan 2018 09:11:12 -0700 Subject: [PATCH 1/2] Make git-upstream-sync use a configurable remote Make it read the upstream remote with git config and default to using upstream if that is unset --- bin/git-upstream-sync | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/git-upstream-sync b/bin/git-upstream-sync index 9fb363373..49e61e6be 100755 --- a/bin/git-upstream-sync +++ b/bin/git-upstream-sync @@ -7,11 +7,17 @@ # Sync to upstream/yourforkname and rebase into your local fork. then push # back into yourfork/yourforkname # -# Assumes that your upstream fork's remote is named upstream +# Assumes that your upstream fork's remote is named upstream unless you +# set upstream-sync.remote with git config branch_name=$(git symbolic-ref --short -q HEAD) +upstream_remote=$(git config --get upstream-sync.remote) +if [[ $? != 0 ]]; then + echo 'Using default remote of upstream' + upstream_remote='upstream' +fi -git fetch upstream && \ - git rebase upstream/${branch_name} && \ +git fetch ${upstream_remote} && \ + git rebase ${upstream_remote}/${branch_name} && \ git push && \ git fetch -p From 089458715a403f7f0a9291b879465d81cbccd76a Mon Sep 17 00:00:00 2001 From: Joe Block Date: Thu, 4 Jan 2018 09:18:22 -0700 Subject: [PATCH 2/2] Humor shellcheck --- bin/git-upstream-sync | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/git-upstream-sync b/bin/git-upstream-sync index 49e61e6be..80e1e0977 100755 --- a/bin/git-upstream-sync +++ b/bin/git-upstream-sync @@ -12,12 +12,13 @@ branch_name=$(git symbolic-ref --short -q HEAD) upstream_remote=$(git config --get upstream-sync.remote) +# shellcheck disable=SC2181 if [[ $? != 0 ]]; then echo 'Using default remote of upstream' upstream_remote='upstream' fi git fetch ${upstream_remote} && \ - git rebase ${upstream_remote}/${branch_name} && \ + git rebase "${upstream_remote}/${branch_name}" && \ git push && \ git fetch -p