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@xxxxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html