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

[PATCH v2 00/18] Read loose references lazily

From
mhagger@alum.mit.edu <mhagger@alum.mit.edu>
Date
Apr 26, 2012, 22:26 UTC
Message-ID
<1335479227-7877-1-git-send-email-mhagger@alum.mit.edu>
From: Michael Haggerty <mhagger@alum.mit.edu>

This is the next installment of the ref-api saga. The main result of this patch series is to teach git to read loose references one directory at a time, only when they are needed.

This version of the patch series differs from v1 by avoiding the conversion of code from using (struct ref_dir *) to (struct ref_entry *). As Junio rightly pointed out, the use of ref_entry as the data type for dealing with directory entries was awkward and error-prone.

This version also changes how bits in ref_entry::flag are assigned, also at Junio's suggestion.

The first nine patches are unchanged from v1 except for a trivial change to a commit message. These patches convert get_ref_dir() and do_for_each_reflog() to use strbufs and to tighten up their specifications.

Patch 10 fixes a git_path() related bug in bisect.c. A filename obtained from git_path() was being used long after it was created. With the changes later in this patch series, the lazy-loose-reference-reading code will be activated while check_good_are_ancestors_of_bad() is still holding on to the filename. Therefore, this fix is a prerequisite to the later patches.

[I am nervous that there might be analogous bugs elsewhere in the code. Since the lazy-loose-reference-reading code can now spring to life in many situations where references are used, it might flush out problems in sloppy code elsewhere. But what can we do, short of getting rid of get_pathname() once and for all?]

Patch 11 Converts find_containing_dir() to use a strbuf. It makes the code a bit more straightforward but is otherwise not very interesting.

The rest of the patches teach the code to read loose references lazily. This is done by setting a REF_INCOMPLETE bit in ref_entry::flag for loose directory entries that haven't been read yet. The entries are read when they are accessed, namely when get_ref_dir() is called to extract a ref_dir from a directory ref_entry.

This patch series depends on mh/ref-api, which just recently made it to master. It passes all tests.

Michael Haggerty (18):
  get_ref_dir(): return early if directory cannot be read
  get_ref_dir(): use a strbuf to hold refname
  get_ref_dir(): rename "base" parameter to "dirname"
  get_ref_dir(): require that the dirname argument ends in '/'
  refs.c: extract function search_for_subdir()
  get_ref_dir(): take the containing directory as argument
  do_for_each_reflog(): return early on error
  do_for_each_reflog(): use a strbuf to hold logfile name
  do_for_each_reflog(): reuse strbuf across recursive function calls
  bisect: copy filename string obtained from git_path()
  find_containing_dir(): use strbuf in implementation of this function
  refs: wrap top-level ref_dirs in ref_entries
  read_loose_refs(): rename function from get_ref_dir()
  get_ref_dir(): add function for getting a ref_dir from a ref_entry
  search_for_subdir(): return (ref_dir *) instead of (ref_entry *)
  struct ref_dir: store a reference to the enclosing ref_cache
  read_loose_refs(): eliminate ref_cache argument
  refs: read loose references lazily
 bisect.c |    8 +-
 refs.c   |  378 ++++++++++++++++++++++++++++++++++++++++----------------------
 2 files changed, 247 insertions(+), 139 deletions(-)
-- 
1.7.10
Next: mhagger@alum.mit.edu
Message 1 of 26 in “Read loose references lazily”
  1. 00/18 Read loose references lazilymhagger@alum.mit.edu, Apr 26, 2012
  2. 01/18 get_ref_dir(): return early if directory cannot be readmhagger@alum.mit.edu, Apr 26, 2012
  3. 02/18 get_ref_dir(): use a strbuf to hold refnamemhagger@alum.mit.edu, Apr 26, 2012
  4. 03/18 get_ref_dir(): rename "base" parameter to "dirname"mhagger@alum.mit.edu, Apr 26, 2012
  5. 04/18 get_ref_dir(): require that the dirname argument ends in '/'mhagger@alum.mit.edu, Apr 26, 2012
  6. 05/18 refs.c: extract function search_for_subdir()mhagger@alum.mit.edu, Apr 26, 2012
  7. Junio C HamanoMay 3, 2012
  8. Junio C HamanoMay 3, 2012
  9. Michael HaggertyMay 4, 2012
  10. 06/18 get_ref_dir(): take the containing directory as argumentmhagger@alum.mit.edu, Apr 26, 2012
  11. 07/18 do_for_each_reflog(): return early on errormhagger@alum.mit.edu, Apr 26, 2012
  12. 08/18 do_for_each_reflog(): use a strbuf to hold logfile namemhagger@alum.mit.edu, Apr 26, 2012
  13. Junio C HamanoApr 26, 2012
  14. Michael HaggertyApr 27, 2012
  15. Junio C HamanoMay 2, 2012
  16. Michael HaggertyMay 3, 2012
  17. 09/18 do_for_each_reflog(): reuse strbuf across recursive function callsmhagger@alum.mit.edu, Apr 26, 2012
  18. 10/18 bisect: copy filename string obtained from git_path()mhagger@alum.mit.edu, Apr 26, 2012
  19. 11/18 find_containing_dir(): use strbuf in implementation of this functionmhagger@alum.mit.edu, Apr 26, 2012
  20. 12/18 refs: wrap top-level ref_dirs in ref_entriesmhagger@alum.mit.edu, Apr 26, 2012
  21. 13/18 read_loose_refs(): rename function from get_ref_dir()mhagger@alum.mit.edu, Apr 26, 2012
  22. 14/18 get_ref_dir(): add function for getting a ref_dir from a ref_entrymhagger@alum.mit.edu, Apr 26, 2012
  23. 15/18 search_for_subdir(): return (ref_dir *) instead of (ref_entry *)mhagger@alum.mit.edu, Apr 26, 2012
  24. 16/18 struct ref_dir: store a reference to the enclosing ref_cachemhagger@alum.mit.edu, Apr 26, 2012
  25. 17/18 read_loose_refs(): eliminate ref_cache argumentmhagger@alum.mit.edu, Apr 26, 2012
  26. 18/18 refs: read loose references lazilymhagger@alum.mit.edu, Apr 26, 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.