Re: [PATCH 3/8] Better Error Handling for add
- From
greened@obbligato.org <greened@obbligato.org>
- Date
- Jan 1, 2013, 22:33 UTC
- Message-ID
- <87obh8fs8e.fsf@waller.obbligato.org>
- In-Reply-To
- <7v1ue4a8i0.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
>> 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.
Show 10 quoted lines
>> + 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