librelist archives

« back to archive

git mktag and libgit2 error handling

git mktag and libgit2 error handling

From:
David Glesser
Date:
2011-05-31 @ 13:54
Hello,

In our minimal git client, we have a problem with the errors produced by
libgit2 and the errors expected by git's tests. Git mktag reports
malformatted input by a message that looks like: "error: char124: trailing
garbage in tag header". Actually I can't have the character number and the
precise type of the error. Git's tests can't pass without these details.

Do you think we should implement in libgit2 a way to know which character
is wrong? How?

David G.

Re: [libgit2] git mktag and libgit2 error handling

From:
Carlos Martín Nieto
Date:
2011-05-31 @ 15:03
On Tue, May 31, 2011 at 03:54:01PM +0200, David Glesser wrote:
> Hello,
> 
> In our minimal git client, we have a problem with the errors produced by
> libgit2 and the errors expected by git's tests. Git mktag reports
> malformatted input by a message that looks like: "error: char124: trailing
> garbage in tag header". Actually I can't have the character number and the
> precise type of the error. Git's tests can't pass without these details.
> 
> Do you think we should implement in libgit2 a way to know which character
> is wrong? How?

With a small change to the existing code, you can figure it out. Store
where the buffer starts at the beggining of the function and substract
the current position from the beginning of the buffer.

This assumes there are no multibyte characters. Otherwise, it becomes
unbearably complicated.

Cheers,
   cmn

Re: [libgit2] git mktag and libgit2 error handling

From:
David Glesser
Date:
2011-05-31 @ 16:58
> With a small change to the existing code, you can figure it out. Store
> where the buffer starts at the beggining of the function and substract
> the current position from the beginning of the buffer.

I know that it's possible. My real question is : how can it be added
nicely to the API?
Should I only change the error messages? Or add an argument "int
*error_character" to git_create_tag_frombuffer? Or add an another function?


David G.

Re: [libgit2] git mktag and libgit2 error handling

From:
Michael Schubert
Date:
2011-05-31 @ 18:30
On 05/31/2011 06:58 PM, David Glesser wrote:
>> With a small change to the existing code, you can figure it out. Store
>> where the buffer starts at the beggining of the function and substract
>> the current position from the beginning of the buffer.
> 
> I know that it's possible. My real question is : how can it be added
> nicely to the API?
> Should I only change the error messages? Or add an argument "int
> *error_character" to git_create_tag_frombuffer? Or add an another function?

Imho you shouldn't change the API to fit the test but vice versa.

Re: [libgit2] git mktag and libgit2 error handling

From:
Carlos Martín Nieto
Date:
2011-05-31 @ 18:30
On Tue, May 31, 2011 at 06:58:30PM +0200, David Glesser wrote:
> > With a small change to the existing code, you can figure it out. Store
> > where the buffer starts at the beggining of the function and substract
> > the current position from the beginning of the buffer.
> 
> I know that it's possible. My real question is : how can it be added
> nicely to the API?
> Should I only change the error messages? Or add an argument "int
> *error_character" to git_create_tag_frombuffer? Or add an another function?

I'd recommend just adding it to the error message and tweaking the
git.git tests so they'll admit the libgit2 ones, as that particular
information is only actually needed by these tests and no other code
should care where exactly the error happened.

Cheers,
   cmn