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

[PATCH v2 00/12] Use refs API more consistently

From
mhagger@alum.mit.edu <mhagger@alum.mit.edu>
Date
Oct 28, 2011, 11:27 UTC
Message-ID
<1319801284-15625-1-git-send-email-mhagger@alum.mit.edu>
From: Michael Haggerty <mhagger@alum.mit.edu>

This is a re-roll of the patch series on top of v3 of "Tidying up references code", which in turn applies to gitster/master.

This series conflicts with the "Checking full vs. partial refnames" series but not in a fundamental way. Unless there is an important reason to merge the latter to master before this patch series, I suggest that I reroll "Checking full vs. partial refnames" on top of these ref-api changes after they hit master.

This patch series primarily has to do with using the refs API more consistently within refs.c itself. We want to minimize the surface area for accessing the ref_cache data structure so that when it is changed into a tree (we're on the verge of that change now, I promise!) we don't have to change callers more than necessary. There is also a bit of an eat-your-own-dogfood thing going on here; if for_each_ref() and its friends are good enough for "outsiders", they should be good enough for most internal use.

The first two patches are trivial preparation cleanups.

The third verifies that refnames read from packed-ref files are properly formatted. When the REFNAME_FULL changes become available, this check can be tightened up.

The do_for_each_ref_in_{array,arrays}() functions provide an iterator-like interface to iterating over a single ref_array and iterating over two ref_arrays in parallel. These are useful abstractions in and of themselves (the former is used to reimplement repack_without_ref() and is_refname_available() in patches 9 and 12 respectively). And they will be even more useful when references are stored hierarchically.

Michael Haggerty (12):
  Rename another local variable name -> refname
  repack_without_ref(): remove temporary
  parse_ref_line(): add a check that the refname is properly formatted
  create_ref_entry(): extract function from add_ref()
  add_ref(): take a (struct ref_entry *) parameter
  do_for_each_ref(): correctly terminate while processesing extra_refs
  do_for_each_ref_in_array(): new function
  do_for_each_ref_in_arrays(): new function
  repack_without_ref(): reimplement using do_for_each_ref_in_array()
  names_conflict(): new function, extracted from is_refname_available()
  names_conflict(): simplify implementation
  is_refname_available(): reimplement using do_for_each_ref_in_array()
 refs.c |  255 ++++++++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 160 insertions(+), 95 deletions(-)
-- 
1.7.7
Next: mhagger@alum.mit.edu
Message 1 of 13 in “Use refs API more consistently”
  1. 00/12 Use refs API more consistentlymhagger@alum.mit.edu, Oct 28, 2011
  2. 01/12 Rename another local variable name -> refnamemhagger@alum.mit.edu, Oct 28, 2011
  3. 02/12 repack_without_ref(): remove temporarymhagger@alum.mit.edu, Oct 28, 2011
  4. 03/12 parse_ref_line(): add a check that the refname is properly formattedmhagger@alum.mit.edu, Oct 28, 2011
  5. 04/12 create_ref_entry(): extract function from add_ref()mhagger@alum.mit.edu, Oct 28, 2011
  6. 05/12 add_ref(): take a (struct ref_entry *) parametermhagger@alum.mit.edu, Oct 28, 2011
  7. 06/12 do_for_each_ref(): correctly terminate while processesing extra_refsmhagger@alum.mit.edu, Oct 28, 2011
  8. 07/12 do_for_each_ref_in_array(): new functionmhagger@alum.mit.edu, Oct 28, 2011
  9. 08/12 do_for_each_ref_in_arrays(): new functionmhagger@alum.mit.edu, Oct 28, 2011
  10. 09/12 repack_without_ref(): reimplement using do_for_each_ref_in_array()mhagger@alum.mit.edu, Oct 28, 2011
  11. 10/12 names_conflict(): new function, extracted from is_refname_available()mhagger@alum.mit.edu, Oct 28, 2011
  12. 11/12 names_conflict(): simplify implementationmhagger@alum.mit.edu, Oct 28, 2011
  13. 12/12 is_refname_available(): reimplement using do_for_each_ref_in_array()mhagger@alum.mit.edu, Oct 28, 2011

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.