Skip to content

Moving global state into the repository object (part 1)

Stefan Beller git 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest27 patches 9 repliesIn review
  2. v327 patches 31 repliesSuperseded
  3. v216 patches 9 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v126 patches19 repliesSuperseded

Changes in v4 from the cover letter

* addressed feedback from the single patches (mostly nits)
* rebased on latest master

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/27repository: introduce raw object store fieldbuiltin/grep.c environment.c object-store.h +4 more+43 -125 replies
2/27object-store: migrate alternates struct and functions from cache.hcache.h object-store.h+51 -510 replies
3/27object-store: move alt_odb_list and alt_odb_tail to object storebuiltin/fsck.c object-store.h packfile.c +2 more+25 -190 replies
4/27object-store: free alt_odb_listobject.c+17 -00 replies
5/27object-store: move packed_git and packed_git_mru to object storebuiltin/count-objects.c builtin/fsck.c builtin/gc.c +12 more+98 -750 replies
6/27object-store: close all packs upon clearing the object storebuiltin/am.c builtin/clone.c builtin/fetch.c +5 more+11 -120 replies
7/27pack: move prepare_packed_git_run_once to object storeobject-store.h packfile.c+10 -50 replies
8/27pack: move approximate object count to object storeobject-store.h packfile.c+14 -70 replies
9/27sha1_file: add raw_object_store argument to alt_odb_usablesha1_file.c+5 -30 replies
10/27sha1_file: add repository argument to link_alt_odb_entrysha1_file.c+5 -30 replies
11/27sha1_file: add repository argument to read_info_alternatessha1_file.c+7 -40 replies
12/27sha1_file: add repository argument to link_alt_odb_entriessha1_file.c+13 -60 replies
13/27sha1_file: add repository argument to prepare_alt_odbbuiltin/fsck.c object-store.h packfile.c +2 more+12 -100 replies
14/27sha1_file: allow link_alt_odb_entries to handle arbitrary repositoriesobject-store.h sha1_file.c+20 -200 replies
15/27sha1_file: allow prepare_alt_odb to handle arbitrary repositoriesobject-store.h sha1_file.c+6 -90 replies
16/27sha1_file: add repository argument to sha1_file_namecache.h http-walker.c http.c +2 more+16 -150 replies
17/27sha1_file: add repository argument to stat_sha1_filesha1_file.c+5 -40 replies
18/27sha1_file: add repository argument to open_sha1_filesha1_file.c+4 -20 replies
19/27sha1_file: add repository argument to map_sha1_file_1sha1_file.c+6 -50 replies
20/27sha1_file: add repository argument to map_sha1_filecache.h object-store.h sha1_file.c +1 more+9 -40 replies
21/27sha1_file: add repository argument to sha1_loose_object_infosha1_file.c+5 -40 replies
22/27sha1_file: allow sha1_file_name to handle arbitrary repositoriesobject-store.h sha1_file.c+3 -40 replies
23/27sha1_file: allow stat_sha1_file to handle arbitrary repositoriessha1_file.c+5 -60 replies
24/27sha1_file: allow open_sha1_file to handle arbitrary repositoriessha1_file.c+5 -60 replies
25/27sha1_file: allow map_sha1_file_1 to handle arbitrary repositoriessha1_file.c+3 -50 replies
26/27sha1_file: allow map_sha1_file to handle arbitrary repositoriesobject-store.h sha1_file.c+4 -40 replies
27/27sha1_file: allow sha1_loose_object_info to handle arbitrary repositoriessha1_file.c+5 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCHv4 00/27] Moving global state into the repository object (part 1)

v4:
* addressed feedback from the single patches (mostly nits)
* rebased on latest master

v3:
* reverted back to use the repository for most of the functions (including unduplicating 'ignore_env')
* rebased on master again (I lost that state when doing v2, as I did both rebase as well as conversion to object store in one go)
* one additional patch, that moves the alternates related things to object-store.h, such that inclusion of cache.h (in object-store.h) is not required any more.

v2:
* duplicated the 'ignore_env' bit into the object store as well
* the #define trick no longer works as we do not have a "the_objectstore" global, which means there is just one patch per function that is converted. As this follows the same structure of the previous series, I am still confident there is no hidden dependencies to globals outside the object store in these converted functions.
* rebased on top of current master, resolving the merge conflicts.
I think I used the list.h APIs right, but please double check.

Thanks,
Stefan

v1:
This is a real take on the first part of the recent RFC[1].

Jonathan Tan suggested[2] that "sha1_loose_object_info to handle arbitrary repositories" might be a good breaking point for a first part at that RFC at patch 38. This series is smaller and contains only 26 patches as the patches in the big RFC were slightly out of order.

I developed this series partly by writing patches, but mostly by cherrypicking from that RFC on top of current master. I noticed no external conflicts apart from one addition to the repositories _INIT macro, which was easy to resolve.

Comments in the early range of that RFC were on 003 where Junio pointed out that the coccinelle patch ought to be not in contrib/coccinelle, so I put it in a sub directory there, as 'make coccicheck' doesn't traverse subdirs.

brian had a questoin on patch 25 in the RFC, but that seemed to resolve itself without any suggestion to include into this series[3].

Duy suggested that we shall not use the repository blindly, but should carefully examine whether to pass on an object store or the refstore or such[4], which I agree with if it makes sense. This series unfortunately has an issue with that as I would not want to pass down the ignore_env flag separately from the object store, so I made all functions that only take the object store to have the raw object store as the first parameter, and others using the full repository.

Eric Sunshine brought up memory leaks with the RFC, and I would think to have plugged all holes.

[1] https://public-inbox.org/git/[email protected]/
[2] https://public-inbox.org/git/[email protected]/
[3] https://public-inbox.org/git/[email protected]/
[4] https://public-inbox.org/git/CACsJy8CGgekpX4cZkyyTSPrj87uQVKZSOL7fyT__P2dh_1LmVQ@mail.gmail.com/

Thanks,
Stefan

Jonathan Nieder (2):
sha1_file: allow map_sha1_file_1 to handle arbitrary repositories
sha1_file: allow sha1_loose_object_info to handle arbitrary
repositories

Stefan Beller (25):
repository: introduce raw object store field
object-store: migrate alternates struct and functions from cache.h
object-store: move alt_odb_list and alt_odb_tail to object store
object-store: free alt_odb_list
object-store: move packed_git and packed_git_mru to object store
object-store: close all packs upon clearing the object store
pack: move prepare_packed_git_run_once to object store
pack: move approximate object count to object store
sha1_file: add raw_object_store argument to alt_odb_usable
sha1_file: add repository argument to link_alt_odb_entry
sha1_file: add repository argument to read_info_alternates
sha1_file: add repository argument to link_alt_odb_entries
sha1_file: add repository argument to prepare_alt_odb
sha1_file: allow link_alt_odb_entries to handle arbitrary repositories
sha1_file: allow prepare_alt_odb to handle arbitrary repositories
sha1_file: add repository argument to sha1_file_name
sha1_file: add repository argument to stat_sha1_file
sha1_file: add repository argument to open_sha1_file
sha1_file: add repository argument to map_sha1_file_1
sha1_file: add repository argument to map_sha1_file
sha1_file: add repository argument to sha1_loose_object_info
sha1_file: allow sha1_file_name to handle arbitrary repositories
sha1_file: allow stat_sha1_file to handle arbitrary repositories
sha1_file: allow open_sha1_file to handle arbitrary repositories
sha1_file: allow map_sha1_file to handle arbitrary repositories

 builtin/am.c             |   2 +-
 builtin/clone.c          |   2 +-
 builtin/count-objects.c  |   5 +-
 builtin/fetch.c          |   2 +-
 builtin/fsck.c           |  12 ++--
 builtin/gc.c             |   3 +-
 builtin/grep.c           |   2 +-
 builtin/merge.c          |   2 +-
 builtin/pack-objects.c   |  20 ++++---
 builtin/pack-redundant.c |   5 +-
 builtin/receive-pack.c   |   2 +-
 cache.h                  |  87 ---------------------------
 environment.c            |   5 +-
 fast-import.c            |   7 ++-
 http-backend.c           |   5 +-
 http-walker.c            |   3 +-
 http.c                   |   5 +-
 object-store.h           | 124 ++++++++++++++++++++++++++++++++++++++
 object.c                 |  27 +++++++++
 pack-bitmap.c            |   3 +-
 packfile.c               |  64 ++++++++++----------
 packfile.h               |   2 +-
 path.c                   |   2 +-
 repository.c             |  21 +++++--
 repository.h             |   7 ++-
 server-info.c            |   5 +-
 sha1_file.c              | 125 +++++++++++++++++++++------------------
 sha1_name.c              |  10 ++--
 streaming.c              |   5 +-
 29 files changed, 335 insertions(+), 229 deletions(-)
 create mode 100644 object-store.h
Signature · 1 line
2.16.1.291.g4437f3f132-goog