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

Re: [WIP/RFC 17/23] repo: introduce new repository object

From
BWBrandon Williams <bmwill@google.com>
Date
May 23, 2017, 17:35 UTC
Message-ID
<20170523173509.GC115919@google.com>
In-Reply-To
<CAGZ79kZoCkrF_ruzkpULQVSZ7=WEgFP+8PcgDhacWBh7ZCac5Q@mail.gmail.com>
On 05/20, Stefan Beller wrote:
Show 9 quoted lines
> On Thu, May 18, 2017 at 4:21 PM, Brandon Williams <bmwill@google.com> wrote:
> > Introduce 'struct repo' an object used to represent a repository.
> 
> Is this the right place to outline what you expect from a repo object?
> Are you planning to use it everywhere?
> Is it lazy-init'd and it takes care of it itself, or would the caller
> have to take
> care of the state of the repo? ("the repo object is just a place to put the
> current globals")

Those are all great questions, questions that I don't think I have all the answers for right now. Since this is still in the idea phase I'm hoping to hear what other people think this would look like in an ideal world. I don't think everything would need to be lazy-init'd or can easily be done that way. At least the index stuff isn't set up to be able to do that. I can see the config being lazy-init'd in one way or another, though that would require passing in a repo object instead of a config-set when you want to look-up a config value (which is probably very reasonable) that way the config-set stored in the repo object can be properly initialized.

Show 36 quoted lines
> 
> >
> > Signed-off-by: Brandon Williams <bmwill@google.com>
> > ---
> >  Makefile |  1 +
> >  repo.c   | 42 ++++++++++++++++++++++++++++++++++++++++++
> >  repo.h   | 15 +++++++++++++++
> >  3 files changed, 58 insertions(+)
> >  create mode 100644 repo.c
> >  create mode 100644 repo.h
> >
> > diff --git a/Makefile b/Makefile
> > index e35542e63..a49d2f96a 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -821,6 +821,7 @@ LIB_OBJS += refs/ref-cache.o
> >  LIB_OBJS += ref-filter.o
> >  LIB_OBJS += remote.o
> >  LIB_OBJS += replace_object.o
> > +LIB_OBJS += repo.o
> >  LIB_OBJS += rerere.o
> >  LIB_OBJS += resolve-undo.o
> >  LIB_OBJS += revision.o
> > diff --git a/repo.c b/repo.c
> > new file mode 100644
> > index 000000000..d47e98d95
> > --- /dev/null
> > +++ b/repo.c
> > @@ -0,0 +1,42 @@
> > +#include "cache.h"
> > +#include "repo.h"
> > +
> > +int
> > +repo_init(struct repo *repo, const char *gitdir, const char *worktree)
> 
> style ;)

Darn, I forgot to change this before sending out. An easy fix, though I still like this style better :P

Show 10 quoted lines
> 
> 
> > +       /* Maybe need a check to verify that a worktree is indeed a worktree? */
> 
> add NEEDSWORK/FIXME prefix to comment?
> 
> > +void
> > +repo_clear(struct repo *repo)
> 
> style ;)
-- 
Brandon Williams
Previous: Stefan BellerNext: Brandon Williams
Message 25 of 41 in “[WIP/RFC 00/23] repository object”
  1. Brandon WilliamsMay 18, 2017
  2. 02/23 convert: convert crlf_to_git to take an indexBrandon Williams, May 18, 2017
  3. 03/23 convert: convert convert_to_git_filter_fd to take an indexBrandon Williams, May 18, 2017
  4. 01/23 convert: convert get_cached_convert_stats_ascii to take an indexBrandon Williams, May 18, 2017
  5. 04/23 convert: convert convert_to_git to take an indexBrandon Williams, May 18, 2017
  6. 10/23 ls-files: convert show_other_files to take an indexBrandon Williams, May 18, 2017
  7. 11/23 ls-files: convert show_ru_info to take an indexBrandon Williams, May 18, 2017
  8. 06/23 tree: convert read_tree to take an index parameterBrandon Williams, May 18, 2017
  9. 14/23 ls-files: convert show_files to take an indexBrandon Williams, May 18, 2017
  10. 05/23 convert: convert renormalize_buffer to take an indexBrandon Williams, May 18, 2017
  11. 12/23 ls-files: convert ce_excluded to take an indexBrandon Williams, May 18, 2017
  12. 15/23 ls-files: factor out debug info into a functionBrandon Williams, May 18, 2017
  13. 08/23 ls-files: convert write_eolinfo to take an indexBrandon Williams, May 18, 2017
  14. 07/23 ls-files: convert overlay_tree_on_cache to take an indexBrandon Williams, May 18, 2017
  15. 09/23 ls-files: convert show_killed_files to take an indexBrandon Williams, May 18, 2017
  16. 16/23 ls-files: factor out tag calculationBrandon Williams, May 18, 2017
  17. 20/23 submodule-config: refactor to allow for multiple submodule_cache'sBrandon Williams, May 18, 2017
  18. 19/23 repo: add per repo configBrandon Williams, May 18, 2017
  19. 22/23 submodule: add is_submodule_activeBrandon Williams, May 18, 2017
  20. 21/23 repo: add repo_read_gitmodulesBrandon Williams, May 18, 2017
  21. 18/23 repo: add index_state to struct repoBrandon Williams, May 18, 2017
  22. Stefan BellerMay 20, 2017
  23. 17/23 repo: introduce new repository objectBrandon Williams, May 18, 2017
  24. Stefan BellerMay 20, 2017
  25. Brandon WilliamsMay 23, 2017
  26. 13/23 ls-files: convert prune_cache to take an indexBrandon Williams, May 18, 2017
  27. 23/23 ls-files: use repository objectBrandon Williams, May 18, 2017
  28. Jeff HostetlerMay 19, 2017
  29. Ben PeartMay 19, 2017
  30. Brandon WilliamsMay 23, 2017
  31. Stefan BellerMay 20, 2017
  32. Johannes SchindelinMay 22, 2017
  33. Jacob KellerMay 21, 2017
  34. brian m. carlsonMay 21, 2017
  35. Jeff KingMay 22, 2017
  36. Brandon WilliamsMay 23, 2017
  37. Junio C HamanoMay 24, 2017
  38. Duy NguyenMay 29, 2017
  39. Ævar Arnfjörð BjarmasonMay 29, 2017
  40. Duy NguyenMay 29, 2017
  41. Brandon WilliamsMay 30, 2017

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.