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

Re: [Outreachy][PATCH] abspath: reconcile `dir_exists()` and `is_directory()`

From
Jeff King <peff@peff.net>
Date
Oct 24, 2019, 18:13 UTC
Message-ID
<20191024181344.GD12892@sigill.intra.peff.net>
In-Reply-To
<20191024114148.GK4348@szeder.dev>
On Thu, Oct 24, 2019 at 01:41:48PM +0200, SZEDER Gábor wrote:
Show 23 quoted lines
> > diff --git a/builtin/clone.c b/builtin/clone.c
> > index c46ee29f0a..f89938bf94 100644
> > --- a/builtin/clone.c
> > +++ b/builtin/clone.c
> > @@ -899,12 +899,6 @@ static void dissociate_from_references(void)
> >  	free(alternates);
> >  }
> >  
> > -static int dir_exists(const char *path)
> > -{
> > -	struct stat sb;
> > -	return !stat(path, &sb);
> 
> But look at this, it only checks that the given path exists, but it
> could be a regular file or any other kind of path other than a
> directory as well!
> 
> So this function clearly doesn't do what it's name suggests.  That's
> bad.
> 
> Unfortunately, it gets worse: some of its callsites in
> 'builtin/clone.c' do expect it to check the existence of _any_ path,
> not just a directory.

Yes, that's the reason for the funny name (and the fact that it was never re-factored to use is_directory() in the first place). There's some more discussion in:

  https://public-inbox.org/git/xmqqbmi9dw55.fsf@gitster.mtv.corp.google.com/
and its subthread.
-Peff
Previous: SZEDER GáborNext: Emily Shaffer
Message 3 of 15 in “abspath: reconcile `dir_exists()` and `is_directory()`”
  1. Miriam RubioOct 24, 2019
  2. SZEDER GáborOct 24, 2019
  3. Jeff KingOct 24, 2019
  4. Emily ShafferOct 24, 2019
  5. Jeff KingOct 24, 2019
  6. Junio C HamanoOct 25, 2019
  7. Miriam R.Oct 24, 2019
  8. Junio C HamanoOct 25, 2019
  9. Miriam R.Oct 25, 2019
  10. Junio C HamanoOct 25, 2019
  11. Christian CouderOct 25, 2019
  12. Miriam R.Oct 25, 2019
  13. Miriam R.Oct 26, 2019
  14. Christian CouderOct 26, 2019
  15. Miriam R.Oct 26, 2019

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.