summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorLibravatar David A. Greene <greened@obbligato.org>2013-02-04 22:06:03 -0600
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-02-05 15:22:36 -0800
commit10a49587fabde88c0afbc80a99d97fae91811f5f (patch)
treea5cfeae24a94e54bceebeed804ca26ce90a14035 /contrib
parentcontrib/subtree: use %B for split subject/body (diff)
downloadtgif-10a49587fabde88c0afbc80a99d97fae91811f5f.tar.xz
contrib/subtree: better error handling for 'subtree add'
Check refspecs for validity before passing them on to other commands. This lets us generate more helpful error messages. Signed-off-by: David A. Greene <greened@obbligato.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/subtree/git-subtree.sh12
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 559821092d..771f39d031 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -497,12 +497,18 @@ cmd_add()
ensure_clean
if [ $# -eq 1 ]; then
- "cmd_add_commit" "$@"
+ git rev-parse -q --verify "$1^{commit}" >/dev/null ||
+ die "'$1' does not refer to a commit"
+
+ "cmd_add_commit" "$@"
elif [ $# -eq 2 ]; then
- "cmd_add_repository" "$@"
+ git rev-parse -q --verify "$2^{commit}" >/dev/null ||
+ die "'$2' does not refer to a commit"
+
+ "cmd_add_repository" "$@"
else
say "error: parameters were '$@'"
- die "Provide either a refspec or a repository and refspec."
+ die "Provide either a commit or a repository and commit."
fi
}