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

Re: [PATCH 2/5] First step, making setup (somewhat) reentrant

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 7, 2008, 09:22 UTC
Message-ID
<7v4pdq0z30.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LSU.1.00.0801070845270.10101@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Which brings me to a more fundamental question: what do you need reentrant 
> setup_directory() for?  If it is just to allow multiple calls to that 
> function for the _same_ repository, I say clean up your code.
IIRC, he is writing a set-of-repositories browser.

But I think the right approach of cleaning up is to design a layer of containers like we did for "the_index" libification [*1*]. We would probably want:

 * a container that abstracts accesses to a single repository
   that includes:
    - set of refs;
    - object database and object hash (because different
      repositories can have different notion of who is parent of
      whom);
 * a container that abstracts accesses to a state of the index
   (we already have this -- the_index).
 * a container that abstracts a manipulation state in a single
   repository, that points at the first one but somehow knows
   what in-core objects are rewritten during its operation
   (e.g. history simplification rewrites parents list in in-core
   commit objects).

and a relatively low impact approach to transition to such a scheme would be to use "the_index" libification as the model. I.e. make the real API to take an explicit container as one of their parameter, but define the default container to work on for each level, and express the existing API in terms of the updated API that works on the default container.

[Reference]
  228e94f93570b580da388069900c56b813c91953 (Move index-related
  variables into a structure.)
  4aab5b46f44a7ba860e07a52be506b7b57b2bd5f (Make read-cache.c
  "the_index" free.)
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 7 of 8 in “Add streq() to compat-util”
  1. 1/5 Add streq() to compat-utilChristian Thaeter, Jan 7, 2008
  2. 2/5 First step, making setup (somewhat) reentrantChristian Thaeter, Jan 7, 2008
  3. 3/5 provide a reset_packed_git() functionChristian Thaeter, Jan 7, 2008
  4. 4/5 Export some more functions to enable resetting the git stateChristian Thaeter, Jan 7, 2008
  5. 5/5 Make setup_git_directory reentrantChristian Thaeter, Jan 7, 2008
  6. Johannes SchindelinJan 7, 2008
  7. Junio C HamanoJan 7, 2008
  8. Johannes SchindelinJan 7, 2008

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.