Skip to content

Commit 3212d56

Browse files
johnkeepinggitster
authored andcommitted
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 <[email protected]> Signed-off-by: John Keeping <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8301b97 commit 3212d56

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ cmd_push()
715715
repository=$1
716716
refspec=$2
717717
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
719720
else
720721
die "'$dir' must already exist. Try 'git subtree add'."
721722
fi

0 commit comments

Comments
 (0)