contrib/subtree: don't delete remote branches if split fails
When using "git subtree push" to split out a subtree and push it to a remote repository, we do not detect if the split command fails which causes the LHS of the refspec to be empty, deleting the remote branch. Fix this by pulling the result of the split command into a variable so that we can die if the command fails. Reported-by: Steffen Jaeckel <steffen.jaeckel@stzedn.de> Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
John Keeping committed
May 1, 2013 at 09:25 UTC
3212d56ce528a86170f7809659f80a8769a5875f
1 file changed
+2
-1
contrib/subtree/git-subtree.sh
+2
-1
@@ -715,7 +715,8 @@ cmd_push()
715
repository=$1
716
refspec=$2
717
echo "git push using: " $repository $refspec
718
- git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
718
+ localrev=$(git subtree split --prefix="$prefix") || die
719
+ git push $repository $localrev:refs/heads/$refspec
720
else
721
die "'$dir' must already exist. Try 'git subtree add'."
722
fi