git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] contrib/subtree: don't delete remote branches if split fails
@ 2013-05-01  8:25 John Keeping
  2013-05-01 17:13 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: John Keeping @ 2013-05-01  8:25 UTC (permalink / raw)
  To: git; +Cc: David A. Greene, Steffen Jaeckel, John Keeping

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>
---
 contrib/subtree/git-subtree.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..10daa8b 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -715,7 +715,8 @@ cmd_push()
 	    repository=$1
 	    refspec=$2
 	    echo "git push using: " $repository $refspec
-	    git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
+	    localrev=$(git subtree split --prefix="$prefix") || die
+	    git push $repository $localrev:refs/heads/$refspec
 	else
 	    die "'$dir' must already exist. Try 'git subtree add'."
 	fi
-- 
1.8.3.rc0.149.g98a72f2.dirty

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] contrib/subtree: don't delete remote branches if split fails
  2013-05-01  8:25 [PATCH] contrib/subtree: don't delete remote branches if split fails John Keeping
@ 2013-05-01 17:13 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2013-05-01 17:13 UTC (permalink / raw)
  To: John Keeping; +Cc: git, David A. Greene, Steffen Jaeckel

John Keeping <john@keeping.me.uk> writes:

> 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>
> ---
>  contrib/subtree/git-subtree.sh | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index 8a23f58..10daa8b 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -715,7 +715,8 @@ cmd_push()
>  	    repository=$1
>  	    refspec=$2
>  	    echo "git push using: " $repository $refspec
> -	    git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
> +	    localrev=$(git subtree split --prefix="$prefix") || die
> +	    git push $repository $localrev:refs/heads/$refspec
>  	else
>  	    die "'$dir' must already exist. Try 'git subtree add'."
>  	fi

Looks trivially correct to me.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-01 17:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-01  8:25 [PATCH] contrib/subtree: don't delete remote branches if split fails John Keeping
2013-05-01 17:13 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).