git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 3/8] absolute_path(): reject the empty string

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 9, 2012, 04:59 UTC
Message-ID
<7vbohfu6yg.fsf@alter.siamese.dyndns.org>
In-Reply-To
<504C1F86.4060608@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 38 quoted lines
> On 09/07/2012 01:09 AM, Junio C Hamano wrote:
>> Michael Haggerty <mhagger@alum.mit.edu> writes:
>> 
>>> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
>>> ---
>> 
>> I think I asked why this matters (iow, why it is the right thing to
>> do to reject an empty string, instead of treating it as "the current
>> directory") in the previous round.  I would have expected to find
>> the answer be above the S-o-b line here.
>
> The reasons that the change is desirable:
>
> 1. The empty string is not a legitimate path according to POSIX; e.g.,
> see Linux's path_resolution(7):
>
>    Empty pathname
>        In the original UNIX, the empty pathname referred to the current
>        directory.   Nowadays  POSIX  decrees  that  an  empty  pathname
>        must not be resolved successfully.  Linux returns ENOENT in this
>        case.
>
> Accordingly, comparable standard functions like realpath(3) reject the
> empty string.
>
> 2. The functions did not handle the empty path consistently with the way
> they handled other paths (namely, the return value contained a trailing
> slash).
>
> 3. This unusual behavior was undocumented.
>
> The above points let me to the conclusion that the anomalous handling of
> the empty string was a bug in the implementation rather than an intended
> behavior.  Moreover, a quick check of callers didn't turn up any that
> seemed to rely on the strange behavior.
>
> Do you want a re-roll with this verbiage added to the commit messages of
> the two relevant commits?

What the function used to do does not really matter when we are trying to see if the behaviour of the new implementation makes sense, even though it is a good supporting argument to help us judge that this change will not cause regressions to existing callers.

A two sentence paragraph, with "realpath(3) from POSIX.1 rejects an empty string as input" as the primary justification, with "no existing callers passes an empty string and expects to get the current directory" as a supporting argument, should suffice, I would think.

Previous: Michael HaggertyNext: Michael Haggerty
Message 7 of 14 in “Fix some bugs in abspath.c”
  1. 0/8 Fix some bugs in abspath.cMichael Haggerty, Sep 6, 2012
  2. 1/8 t0060: move tests of real_path() from t0000 to hereMichael Haggerty, Sep 6, 2012
  3. 2/8 t0060: verify that absolute_path() fails if passed the empty stringMichael Haggerty, Sep 6, 2012
  4. 3/8 absolute_path(): reject the empty stringMichael Haggerty, Sep 6, 2012
  5. Junio C HamanoSep 6, 2012
  6. Michael HaggertySep 9, 2012
  7. Junio C HamanoSep 9, 2012
  8. 4/8 t0060: verify that real_path() fails if passed the empty stringMichael Haggerty, Sep 6, 2012
  9. 5/8 real_path(): reject the empty stringMichael Haggerty, Sep 6, 2012
  10. 6/8 t0060: verify that real_path() works correctly with absolute pathsMichael Haggerty, Sep 6, 2012
  11. 7/8 real_path(): properly handle nonexistent top-level pathsMichael Haggerty, Sep 6, 2012
  12. 8/8 t0060: verify that real_path() removes extra slashesMichael Haggerty, Sep 6, 2012
  13. 9/8 t0060: split absolute path test in two to exercise some of it on WindowsJohannes Sixt, Sep 9, 2012
  14. Michael HaggertySep 10, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.