Re: [PATCH 3/8] Better Error Handling for add

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"David A. Greene" <greened@xxxxxxxxxxxxx> writes:

> From: "David A. Greene" <greened@xxxxxxxxxxxxx>
>
> 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@xxxxxxxxxxxxx>
> ---
>  contrib/subtree/git-subtree.sh |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index 7ceb413..b8a807a 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -509,8 +509,20 @@ cmd_add()
>  	ensure_clean
>  	
>  	if [ $# -eq 1 ]; then
> +	        ref=$(git check-ref-format --normalize "refs/heads/$1") ||
> +                die "'$1' is not a valid refspec.  Are you missing a branch?"

Is a user forbidden from passing a commit that is not at the tip of
an existing branch?  In other words, is

	$ subtree add origin/next~4^2

forbidden?

> +	        rev=$(git rev-parse --verify $1) ||
> +                die "'$1' is not a valid refspec.  Are you missing a branch?"
> +
>  		"cmd_add_commit" "$@"

If you want to make sure you give a comit to add_commit, you can
probably say something like this:

	git rev-parse -q --verify "$1^{commit}" >/dev/null ||
        die "'$1' does not refer to a commit"

>  	elif [ $# -eq 2 ]; then
> +	        ref=$(git check-ref-format --normalize "refs/heads/$2") ||
> +                die "'$2' is not a valid refspec."
> +
> +	        rev=$(git rev-parse --verify $2) ||
> +                die "'$2' is not a valid refspec."
> +

Likewise.

>  		"cmd_add_repository" "$@"
>  	else
>  	    say "error: parameters were '$@'"
--
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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]