git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Rast <trast@student.ethz.ch>
To: Junio C Hamano <gitster@pobox.com>
Cc: <git@vger.kernel.org>
Subject: Re: Bug: bad errno report from lock_ref_sha1_basic() when contents bad
Date: Mon, 2 Apr 2012 20:12:05 +0200	[thread overview]
Message-ID: <87bonam2a2.fsf@thomas.inf.ethz.ch> (raw)
In-Reply-To: <7vhax2ghy1.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Mon, 02 Apr 2012 10:30:14 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Thomas Rast <trast@inf.ethz.ch> writes:
>
>> But in general, the "errno may
>> be crucial or worthless" interface of lock_ref_sha1_basic() seems a bit
>> broken...
>
> Sorry, but I am not sure what you mean by this.  The function is fairly
> careful using errno to base its decision and even saves errno when it
> calls helpers that may overwrite it, so the "interface" does not want "may
> be crucial or worthless".  The implementation may have been broken over
> time by many patches, but that is a different issue.  Which codepaths
> clobber errno, and is it something you can easily fix with a patch or two?

I meant something else, sorry for being so unclear and confused.  In
particular my comment was supposed to be about resolve_ref_unsafe().

It has two different failure modes:

* Some FS syscall went wrong, and errno is crucial for the user to debug
  it (e.g., ENOENT).

* Reading went fine, but we failed to parse the resulting buffer.  errno
  has some unknown value.

The user of the function needs to be aware of this distinction, and
handle it accordingly.  Otherwise it risks emitting outright wrong error
messages, e.g., in my case I got

  thomas@thomas:~/g(next u+107)$ echo garbage >.git/refs/remotes/origin/master
  thomas@thomas:~/g(next u+107)$ g fetch
  error: unable to resolve reference refs/remotes/origin/master: No such file or directory
  From git://git.kernel.org/pub/scm/git/git
   ! [new branch]      master     -> origin/master  (unable to update local ref)

(The IRC user who asked about this was lucky because "Success"
immediately told us that it was an error path not related to syscalls.)

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

      reply	other threads:[~2012-04-02 18:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-02 10:04 Bug: bad errno report from lock_ref_sha1_basic() when contents bad Thomas Rast
2012-04-02 17:30 ` Junio C Hamano
2012-04-02 18:12   ` Thomas Rast [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bonam2a2.fsf@thomas.inf.ethz.ch \
    --to=trast@student.ethz.ch \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).