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

Re: Libification project (SoC)

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 16, 2007, 11:54 UTC
Message-ID
<Pine.LNX.4.63.0703161251200.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vps79wueu.fsf@assigned-by-dhcp.cox.net>
Hi,
On Thu, 15 Mar 2007, Junio C Hamano wrote:
Show 93 quoted lines
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> 
> > Junio C Hamano <junkio@cox.net> wrote:
> >> "Shawn O. Pearce" <spearce@spearce.org> writes:
> >> > On the other hand, many of the variables declared in environment.c
> >> > are repository specific configuration variables.  These probably
> >> > should be abstracted into some sort of wrapper, so that multiple
> >> > repositories can be accessed from within the same process.  Why?
> >> > a future mod_perl running gitweb.cgi accessing repositories through
> >> > libgit.a and Perl bindings of course!
> >> 
> >> I think if you are abstracting them out, into "struct repo_state",
> >> the index and object store related variables such as packed_git
> >> should go there as well, so your recommendation feels very
> >> inconsistent to me.
> >
> > I missed packed_git, but you are right, that should definately go
> > with a struct repo_state.  And maybe you are right that the index
> > should go with it... but I'm not sure the index should be tied to the
> > repository at all.  Its strictly convention that the index goes with
> > the repository; GIT_INDEX_FILE lets you say otherwise at the command
> > line level, why can't we do otherwise from a library level too?
> 
> Even within a plumbing, being able to shuffle multiple indices
> at once would be very useful.  For example, if I were to rewrite
> unpack-trees, I would most likely read from the current index
> and trees and populate a new index from emptiness by appending
> to it, thereby avoiding the binary-search and insert costs.
> 
> I've thought about the layering when Smurf first brought up the
> libification (which was a loooong time ago), and concluded three
> layered approach would be most useful.
> 
> The bottom layer is object store across repositories.  If we
> ignore SHA-1 collisions as an issue (and we _will_ ignore it for
> forseeable future), unless you are doing "read from one
> repository and write that to another repository", it is more
> handy to be able to name an object and get its data without
> knowing which repository's object store it comes from, and it
> would make "git log master~A..master~B" across repositories
> (i.e. 'master' of repository A and 'master' of repository B)
> possible.  An example interface would be like:
> 
> (current)
> void *read_sha1_file(const unsigned char *sha1,
> 		     enum object_type *type,
> 		     unsigned long *size);
> 
> (libified)
> void *git_read_sha1_file(struct gitlib *,
> 			 const unsigned char *sha1,
> 			 enum object_type *type,
> 			 unsigned long *size);
> 
> where "struct gitlib" has a list of "struct object_store", and
> we will have:
> 
> int git_add_object_store(struct gitlib *, const char *path);
> 
> to add one directory as object store the toplevel gitlib structure
> knows about.  In a sense, "struct gitlib" and object store is so
> global that we might not even need to have it as a parameter
> (iow, it and "struct object **obj_hash" from object.c can stay
> global).
> 
> The middle layer is repositories, primarily their refs and
> reflogs.  An example interface would be like:
> 
> (current)
> int get_sha1(const char *name, unsigned char *sha1);
> 
> (libified)
> int git_get_sha1(struct git_repo *, const char *name, unsigned char *sha1);
> 
> where "struct git_repo" is one repository (and it would have a
> pointer to "struct gitlib *" so that we can follow objects to
> follow parents and stuff).
> 
> And the top layer would have indices, and working trees as
> per-invocation parameter.
> 
> (current)
> int cache_name_pos(const char *name, int namelen);
> int unpack_trees(struct object_list *trees, struct unpack_trees_options *o);
> 
> (libified)
> int git_cache_name_pos(struct git_cache *, const char *name, int namelen);
> int git_unpack_trees(struct object_list *trees, struct git_unpack_trees_options *o);
> 
> where "struct git_cache" has "index" thingies, such as
> active_cache, active_nr, active_alloc, and active_cache_tree.
> And we would have pointer to "struct git_cache *" in unpack_trees_options
> structure.
Isn't this an awfully long shot?
I'd be happy if the libification project resulted
- in a (static!) libgit.a which can be linked to qgit or similar (being 
  reentrant, or at least optionally so, and not die()ing all the time), 
  and
- which does not fix the API yet (at least for the most parts).

We _can_ -- once we agree on a stable API -- expose _some_ functions in a libgit.so, but that does not have to be the goal for the first step!

Ciao, Dscho

Previous: Junio C HamanoNext: Rocco Rutte
Message 6 of 62 in “Libification project (SoC)”
  1. Luiz Fernando N. CapitulinoMar 16, 2007
  2. Shawn O. PearceMar 16, 2007
  3. Junio C HamanoMar 16, 2007
  4. Shawn O. PearceMar 16, 2007
  5. Junio C HamanoMar 16, 2007
  6. Johannes SchindelinMar 16, 2007
  7. Rocco RutteMar 16, 2007
  8. Johannes SchindelinMar 16, 2007
  9. Nicolas PitreMar 16, 2007
  10. Johannes SchindelinMar 16, 2007
  11. Nicolas PitreMar 16, 2007
  12. Steve FrécinauxMar 16, 2007
  13. Nicolas PitreMar 16, 2007
  14. Petr BaudisMar 18, 2007
  15. Johannes SchindelinMar 16, 2007
  16. Shawn O. PearceMar 16, 2007
  17. Marco CostalbaMar 16, 2007
  18. Marco CostalbaMar 16, 2007
  19. Nicolas PitreMar 16, 2007
  20. Marco CostalbaMar 16, 2007
  21. Johannes SchindelinMar 16, 2007
  22. Marco CostalbaMar 17, 2007
  23. Johannes SchindelinMar 17, 2007
  24. Andy ParkinsMar 16, 2007
  25. Petr BaudisMar 18, 2007
  26. Johannes SchindelinMar 18, 2007
  27. Petr BaudisMar 19, 2007
  28. Johannes SchindelinMar 19, 2007
  29. Theodore TsoMar 19, 2007
  30. Shawn O. PearceMar 19, 2007
  31. Johannes SchindelinMar 19, 2007
  32. Linus TorvaldsMar 19, 2007
  33. Linus TorvaldsMar 19, 2007
  34. Andreas EricssonMar 21, 2007
  35. Linus TorvaldsMar 21, 2007
  36. Andreas EricssonMar 22, 2007
  37. Marco CostalbaMar 19, 2007
  38. Steve FrécinauxMar 19, 2007
  39. Steve FrécinauxMar 19, 2007
  40. Johannes SchindelinMar 19, 2007
  41. Petr BaudisMar 19, 2007
  42. Johannes SchindelinMar 19, 2007
  43. Marco CostalbaMar 19, 2007
  44. Petr BaudisMar 16, 2007
  45. Luiz Fernando N. CapitulinoMar 16, 2007
  46. Petr BaudisMar 16, 2007
  47. Luiz Fernando N. CapitulinoMar 16, 2007
  48. Shawn O. PearceMar 16, 2007
  49. Luiz Fernando N. CapitulinoMar 17, 2007
  50. Shawn O. PearceMar 18, 2007
  51. Junio C HamanoMar 18, 2007
  52. Luiz Fernando N. CapitulinoMar 18, 2007
  53. Junio C HamanoMar 18, 2007
  54. Luiz Fernando N. CapitulinoMar 19, 2007
  55. Nicolas PitreMar 18, 2007
  56. Johannes SchindelinMar 16, 2007
  57. Johannes SixtMar 16, 2007
  58. Matthieu MoyMar 16, 2007
  59. Johannes SchindelinMar 16, 2007
  60. Petr BaudisMar 16, 2007
  61. Jakub NarebskiMar 17, 2007
  62. Shawn O. PearceMar 17, 2007

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.