git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jérémy Rosen" <jeremy.rosen@openwide.fr>
To: git@vger.kernel.org
Cc: greened@obbligato.org, pcampbell@kemitix.net, gitster@pobox.com,
	"Jérémy Rosen" <jeremy.rosen@openwide.fr>
Subject: [PATCH 2/2] git-subtree: use ls-remote to check the refspec passed to pull and add
Date: Wed, 13 Mar 2013 17:17:32 +0100	[thread overview]
Message-ID: <1363191452-28804-3-git-send-email-jeremy.rosen@openwide.fr> (raw)
In-Reply-To: <1363191452-28804-1-git-send-email-jeremy.rosen@openwide.fr>

ls-remote is the correct way to check that a parameter is a valid fetchable target


Signed-off-by: Jérémy Rosen <jeremy.rosen@openwide.fr>
---
 contrib/subtree/git-subtree.sh |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8b9d114..61d4eab 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -503,13 +503,8 @@ cmd_add()
 
 	    "cmd_add_commit" "$@"
 	elif [ $# -eq 2 ]; then
-	    # Technically we could accept a refspec here but we're
-	    # just going to turn around and add FETCH_HEAD under the
-	    # specified directory.  Allowing a refspec might be
-	    # misleading because we won't do anything with any other
-	    # branches fetched via the refspec.
-	    git rev-parse -q --verify "$2^{commit}" >/dev/null ||
-	    die "'$2' does not refer to a commit"
+		git ls-remote --exit-code "$1" "$2" ||
+		die "'$2' is not a correct reference on '$1'"
 
 	    "cmd_add_repository" "$@"
 	else
@@ -700,6 +695,8 @@ cmd_merge()
 cmd_pull()
 {
 	ensure_clean
+	git ls-remote --exit-code "$1" "$2" ||
+		die "'$2' is not a correct reference on '$1'"
 	git fetch "$@" || exit $?
 	revs=FETCH_HEAD
 	set -- $revs
-- 
1.7.10.4

      parent reply	other threads:[~2013-03-13 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-13 16:17 [PATCH 0/2] git subtree: properly handle remote refs Jérémy Rosen
2013-03-13 16:17 ` [PATCH 1/2] git-subtree: make sure the SHA saved as ancestor is a commit Jérémy Rosen
2013-03-13 16:17 ` Jérémy Rosen [this message]

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=1363191452-28804-3-git-send-email-jeremy.rosen@openwide.fr \
    --to=jeremy.rosen@openwide.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=greened@obbligato.org \
    --cc=pcampbell@kemitix.net \
    /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 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).