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>
This commit is contained in:
parent
a5b8e28e4e
commit
10a49587fa
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user