From: Paul Campbell Date: Sun, 10 Mar 2013 23:41:15 GMT Subject: [PATCH v2 07/23] contrib/subtree: Teach push and pull to use .gittrees if needed Message-ID: <1362958891-26941-8-git-send-email-pcampbell@kemitix.net> In-Reply-To: <1362958891-26941-1-git-send-email-pcampbell@kemitix.net> From: Matt Hoffman Only when a repository and/or branch are not supplied on the command line will push and pull look for them in the .gittrees file. Signed-off-by: Paul Campbell --- contrib/subtree/git-subtree.sh | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh index 39d764b..98c508b 100755 --- a/contrib/subtree/git-subtree.sh +++ b/contrib/subtree/git-subtree.sh @@ -712,13 +712,21 @@ cmd_merge() cmd_pull() { - if [ $# -ne 1 ]; then - die "You must provide " + if [ $# -gt 2 ]; then + die "You should provide either or " fi if [ -e "$dir" ]; then ensure_clean - repository=$(git config -f .gittrees subtree.$prefix.url) - refspec=$1 + if [ $# -eq 1 ]; then + repository=$(git config -f .gittrees subtree.$prefix.url) + refspec=$1 + elif [ $# -eq 2 ]; then + repository=$1 + refspec=$2 + else + repository=$(git config -f .gittrees subtree.$prefix.url) + refspec=$(git config -f .gittrees subtree.$prefix.branch) + fi git fetch $repository $refspec || exit $? echo "git fetch using: " $repository $refspec revs=FETCH_HEAD @@ -731,12 +739,20 @@ cmd_pull() cmd_push() { - if [ $# -ne 1 ]; then - die "You must provide " + if [ $# -gt 2 ]; then + die "You shold provide either or " fi if [ -e "$dir" ]; then - repository=$(git config -f .gittrees subtree.$prefix.url) - refspec=$1 + if [ $# -eq 1 ]; then + repository=$(git config -f .gittrees subtree.$prefix.url) + refspec=$1 + elif [ $# -eq 2 ]; then + repository=$1 + refspec=$2 + else + repository=$(git config -f .gittrees subtree.$prefix.url) + refspec=$(git config -f .gittrees subtree.$prefix.branch) + fi echo "git push using: " $repository $refspec git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec else -- 1.8.2.rc1