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

Re: [PATCH] refs.c: get_ref_cache: use a bucket hash

From
Jeff King <peff@peff.net>
Date
Mar 17, 2015, 05:48 UTC
Message-ID
<20150317054759.GA16860@peff.net>
In-Reply-To
<xmqqd248p4o9.fsf@gitster.dls.corp.google.com>
On Mon, Mar 16, 2015 at 10:35:18PM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> > It looks like we don't even really care about the value of HEAD. We just
> > want to know "is it a git directory?". I think in other places (like
> > "git add"), we just do an existence check for "$dir/.git". That would
> > not catch a bare repository, but I do not think the current check does
> > either (it is looking for submodules, which always have a .git).
> 
> If we wanted to be consistent, perhaps we should be reusing the "is
> this a git repository?" check used by the auto-discovery codepath
> (setup.c:is_git_directory(), perhaps?), but the idea looks simple
> enough and sounds sensible.

Yeah, I almost suggested that, but I'm concerned that would make us inconsistent with how we report untracked files. I thought that dir.c used ".git" as a magic token there.

But it seems I'm wrong. We do ignore ".git" directly in treat_path(), but treat_directory actually checks resolve_gitlink_ref. I think this will suffer the same problem as Andreas's original issue (e.g., if you run "git ls-files -o").

Likewise, I think dir.c:remove_dir_recurse is in a similar boat. Grepping for resolve_gitlink_ref, it looks like there may be others, too.

All of these should be using the same test, I think. Doing that with is_git_directory() is probably OK. It is a little more expensive than we might want for mass-use (it actually opens and parses the HEAD file in each directory), but it quits early when we _don't_ see a git directory, which would be the common case here.

-Peff
Previous: Junio C HamanoNext: Andreas Krey
Message 7 of 12 in “refs.c: get_ref_cache: use a bucket hash”
  1. refs.c: get_ref_cache: use a bucket hashAndreas Krey, Mar 16, 2015
  2. Thomas GummererMar 16, 2015
  3. Junio C HamanoMar 16, 2015
  4. Andreas KreyMar 16, 2015
  5. Jeff KingMar 17, 2015
  6. Junio C HamanoMar 17, 2015
  7. Jeff KingMar 17, 2015
  8. Andreas KreyNov 13, 2015
  9. Jeff KingNov 14, 2015
  10. Andreas KreyNov 14, 2015
  11. Andreas KreyNov 14, 2015
  12. Jeff KingNov 16, 2015

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.