All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Campbell <pcampbell@kemitix.net>
To: git <git@vger.kernel.org>
Cc: David Greene <greened@obbligato.org>,
	Michael Hart <michael@adslot.com>,
	Paul Campbell <pcampbell@kemitix.net>
Subject: [PATCH 1/4] contrib/subtree: Teach push to abort if split fails
Date: Wed, 13 Mar 2013 22:32:40 +0000	[thread overview]
Message-ID: <1363213963-4065-2-git-send-email-pcampbell@kemitix.net> (raw)
In-Reply-To: <1363213963-4065-1-git-send-email-pcampbell@kemitix.net>

From: Michael Hart <michael@adslot.com>

If the subtree split fails it doesn't return the SHA that should be
pushed to the other repository.

Added a check to ensure that split succeeds before trying to push
and display an error message.

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
 contrib/subtree/git-subtree.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..c68cc6f 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -715,7 +715,12 @@ cmd_push()
 	    repository=$1
 	    refspec=$2
 	    echo "git push using: " $repository $refspec
-	    git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
+	    rev=$(git subtree split --prefix=$prefix)
+	    if [ -n "$rev" ]; then
+		git push $repository $rev:refs/heads/$refspec
+	    else
+		die "Couldn't push, 'git subtree split' failed."
+	    fi
 	else
 	    die "'$dir' must already exist. Try 'git subtree add'."
 	fi
-- 
1.8.2

  reply	other threads:[~2013-03-13 22:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-13 22:32 [PATCH 0/4] contrib/subtree: general updates Paul Campbell
2013-03-13 22:32 ` Paul Campbell [this message]
2013-03-13 22:32 ` [PATCH 2/4] contrib/subtree: Teach push to use --force option Paul Campbell
2013-03-13 22:32 ` [PATCH 3/4] contrib/subtree: Fix typo (s/incldued/included/) Paul Campbell
2013-03-13 22:32 ` [PATCH 4/4] contrib/subtree: Replace invisible carriage return with a visible \r Paul Campbell
2013-03-13 22:36   ` Paul Campbell
2013-03-13 22:42     ` [PATCH] " Paul Campbell
2013-03-14  2:52 ` [PATCH 0/4] contrib/subtree: general updates Miles Bader
2013-03-14  3:30   ` Junio C Hamano
2013-03-24  0:16     ` Paul Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1363213963-4065-2-git-send-email-pcampbell@kemitix.net \
    --to=pcampbell@kemitix.net \
    --cc=git@vger.kernel.org \
    --cc=greened@obbligato.org \
    --cc=michael@adslot.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.