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

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

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

>> 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?

Good point.  It probably shouldn't be.  I think rev-parse should be
enough of a check.

>> +	        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"

What does $1^{commit} mean?  I think your suggestion is what I want but
I don't know what it means yet.  :)

                           -David
--
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]