git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 00/17] cocci: remove "the_index" wrapper macros
@ 2023-03-17 15:35 Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
                   ` (18 more replies)
  0 siblings, 19 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

In 2.40 the last use of "USE_THE_INDEX_COMPATIBILITY_MACROS" went
away, this series does the same for our long-standing migration of
"NO_THE_REPOSITORY_COMPATIBILITY_MACROS".

For review the only interesting patches here are 01-04/17 and
16-17/17, the rest are all a result of mechanically applying the
coccinelle rules incrementally on a header-by-header basis.

For 3x of those I made minor tweaks to the coccille output, because:

 * For whatever reason, it sometimes emits output that would fail
   "diff --check".
 * It would produce very long lines in some cases, which have been
   manually wrapped.
 * For the few that needed casts it wanted to add whitespace between
   the closing ")" and the function name, but the pre-image didn't use
   that, so I adjusted it back.

When merging this to "seen" there's a very trivial conflict in
commit.h, the resolution is to delete both sides:
	
	diff --cc commit.h
	index d4adf111019,d65f1e00145..00000000000
	--- a/commit.h
	+++ b/commit.h
	@@@ -193,7 -207,9 +195,13 @@@ void free_commit_list(struct commit_lis
	  
	  struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
	  
	++<<<<<<< HEAD
	 +int has_non_ascii(const char *text);
	++=======
	+ const char *logmsg_reencode(const struct commit *commit,
	+                           char **commit_encoding,
	+                           const char *output_encoding);
	++>>>>>>> origin/seen
	  const char *repo_logmsg_reencode(struct repository *r,
	                                 const struct commit *commit,
	                                 char **commit_encoding,

Branch & CI for this at:
https://github.com/avar/git/tree/avar/cocci-the-repository-from-pending

Ævar Arnfjörð Bjarmason (17):
  cocci: remove dead rule from "the_repository.pending.cocci"
  cocci: fix incorrect & verbose "the_repository" rules
  cocci: sort "the_repository" rules by header
  cocci: add missing "the_repository" macros to "pending"
  cocci: apply the "cache.h" part of "the_repository.pending"
  cocci: apply the "commit-reach.h" part of "the_repository.pending"
  cocci: apply the "commit.h" part of "the_repository.pending"
  cocci: apply the "diff.h" part of "the_repository.pending"
  cocci: apply the "object-store.h" part of "the_repository.pending"
  cocci: apply the "pretty.h" part of "the_repository.pending"
  cocci: apply the "packfile.h" part of "the_repository.pending"
  cocci: apply the "promisor-remote.h" part of "the_repository.pending"
  cocci: apply the "refs.h" part of "the_repository.pending"
  cocci: apply the "rerere.h" part of "the_repository.pending"
  cocci: apply the "revision.h" part of "the_repository.pending"
  post-cocci: adjust comments for recent repo_* migration
  libs: use "struct repository *" argument, not "the_repository"

 add-interactive.c                             |   2 +-
 add-patch.c                                   |   2 +-
 apply.c                                       |  13 +-
 archive.c                                     |  12 +-
 bisect.c                                      |  11 +-
 blame.c                                       |  15 +-
 branch.c                                      |   7 +-
 builtin/am.c                                  |  23 +--
 builtin/bisect.c                              |  33 ++--
 builtin/blame.c                               |  15 +-
 builtin/branch.c                              |   9 +-
 builtin/cat-file.c                            |  25 +--
 builtin/checkout.c                            |  35 ++--
 builtin/clone.c                               |   6 +-
 builtin/commit-tree.c                         |   4 +-
 builtin/commit.c                              |  29 ++--
 builtin/describe.c                            |   9 +-
 builtin/diff.c                                |   3 +-
 builtin/difftool.c                            |   3 +-
 builtin/fast-export.c                         |  12 +-
 builtin/fast-import.c                         |  17 +-
 builtin/fetch.c                               |  21 +--
 builtin/fsck.c                                |   2 +-
 builtin/gc.c                                  |   8 +-
 builtin/grep.c                                |   6 +-
 builtin/index-pack.c                          |  11 +-
 builtin/log.c                                 |  30 ++--
 builtin/ls-files.c                            |   4 +-
 builtin/ls-tree.c                             |   9 +-
 builtin/merge-base.c                          |   9 +-
 builtin/merge-recursive.c                     |   6 +-
 builtin/merge-tree.c                          |  18 ++-
 builtin/merge.c                               |  23 +--
 builtin/mktag.c                               |   3 +-
 builtin/name-rev.c                            |  11 +-
 builtin/notes.c                               |  34 ++--
 builtin/pack-objects.c                        |  24 ++-
 builtin/prune.c                               |   2 +-
 builtin/pull.c                                |   4 +-
 builtin/range-diff.c                          |  12 +-
 builtin/read-tree.c                           |   2 +-
 builtin/rebase.c                              |  21 +--
 builtin/receive-pack.c                        |  14 +-
 builtin/remote.c                              |   2 +-
 builtin/repack.c                              |   2 +-
 builtin/replace.c                             |  20 +--
 builtin/reset.c                               |  22 +--
 builtin/rev-list.c                            |   2 +-
 builtin/rev-parse.c                           |  18 ++-
 builtin/rm.c                                  |   2 +-
 builtin/shortlog.c                            |  13 +-
 builtin/show-branch.c                         |  19 +--
 builtin/show-ref.c                            |   6 +-
 builtin/sparse-checkout.c                     |   2 +-
 builtin/stash.c                               |  26 +--
 builtin/submodule--helper.c                   |   6 +-
 builtin/tag.c                                 |  10 +-
 builtin/unpack-file.c                         |   4 +-
 builtin/unpack-objects.c                      |   5 +-
 builtin/update-ref.c                          |   8 +-
 builtin/verify-commit.c                       |   2 +-
 builtin/verify-tag.c                          |   2 +-
 builtin/worktree.c                            |   8 +-
 bulk-checkin.c                                |   2 +-
 bundle.c                                      |   5 +-
 cache-tree.c                                  |  16 +-
 cache.h                                       |  19 +--
 checkout.c                                    |   2 +-
 combine-diff.c                                |   8 +-
 commit-graph.c                                |   4 +-
 commit-reach.c                                |  21 +--
 commit-reach.h                                |   9 --
 commit.c                                      |  44 ++---
 commit.h                                      |  22 +--
 connected.c                                   |   4 +-
 contrib/coccinelle/the_repository.cocci       | 123 ++++++++++++++
 .../coccinelle/the_repository.pending.cocci   | 128 ---------------
 delta-islands.c                               |   5 +-
 diff-lib.c                                    |   2 +-
 diff.c                                        |   6 +-
 diff.h                                        |   5 +-
 diffcore-break.c                              |   2 +-
 diffcore-rename.c                             |   4 +-
 dir.c                                         |   2 +-
 entry.c                                       |   3 +-
 fetch-pack.c                                  |   8 +-
 fmt-merge-msg.c                               |  15 +-
 fsck.c                                        |   6 +-
 http-push.c                                   |  16 +-
 http-walker.c                                 |   4 +-
 list-objects-filter-options.c                 |   7 +-
 list-objects.c                                |  20 ++-
 log-tree.c                                    |  28 ++--
 mailmap.c                                     |   4 +-
 match-trees.c                                 |   4 +-
 merge-blobs.c                                 |   6 +-
 merge-ort.c                                   |   6 +-
 merge-recursive.c                             |   9 +-
 negotiator/default.c                          |   6 +-
 negotiator/skipping.c                         |   2 +-
 notes-cache.c                                 |   5 +-
 notes-merge.c                                 |  11 +-
 notes-utils.c                                 |   2 +-
 notes.c                                       |  18 ++-
 object-file.c                                 |   4 +-
 object-name.c                                 |  19 ++-
 object-store.h                                |  11 +-
 pack-bitmap-write.c                           |   3 +-
 packfile.c                                    |   2 +-
 packfile.h                                    |   1 -
 parse-options-cb.c                            |   8 +-
 pretty.c                                      |  10 +-
 pretty.h                                      |   4 -
 promisor-remote.h                             |  15 --
 range-diff.c                                  |  12 +-
 read-cache.c                                  |   9 +-
 rebase-interactive.c                          |   2 +-
 ref-filter.c                                  |   8 +-
 reflog.c                                      |   7 +-
 refs.c                                        |   2 +-
 refs.h                                        |   6 -
 remote.c                                      |  15 +-
 rerere.c                                      |   5 +-
 rerere.h                                      |   3 -
 reset.c                                       |   4 +-
 revision.c                                    |  27 ++--
 revision.h                                    |   3 -
 send-pack.c                                   |   6 +-
 sequencer.c                                   | 150 ++++++++++--------
 shallow.c                                     |  21 +--
 strbuf.h                                      |   6 +-
 submodule-config.c                            |   5 +-
 submodule.c                                   |   8 +-
 t/helper/test-fast-rebase.c                   |  19 ++-
 t/helper/test-match-trees.c                   |   4 +-
 t/helper/test-oidmap.c                        |   6 +-
 t/helper/test-reach.c                         |  12 +-
 t/helper/test-revision-walking.c              |   3 +-
 t/helper/test-submodule-config.c              |   2 +-
 tag.c                                         |   9 +-
 transport-helper.c                            |   2 +-
 transport.c                                   |   3 +-
 tree.c                                        |   5 +-
 unpack-trees.c                                |   2 +-
 upload-pack.c                                 |   8 +-
 walker.c                                      |   6 +-
 wt-status.c                                   |  21 +--
 xdiff-interface.c                             |   2 +-
 148 files changed, 958 insertions(+), 873 deletions(-)
 create mode 100644 contrib/coccinelle/the_repository.cocci
 delete mode 100644 contrib/coccinelle/the_repository.pending.cocci

-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 01/17] cocci: remove dead rule from "the_repository.pending.cocci"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-17 16:14   ` Eric Sunshine
  2023-03-19  5:53   ` Elijah Newren
  2023-03-17 15:35 ` [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
                   ` (17 subsequent siblings)
  18 siblings, 2 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

The "parse_commit_gently" macro went away in [1], so we don't need to
carry his for its migration.

1. ea3f7e598c8 (revision: use repository from rev_info when parsing
   commits, 2020-06-23)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 contrib/coccinelle/the_repository.pending.cocci | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 747d382ff5f..23b97536da5 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -34,14 +34,6 @@ expression G;
 + repo_parse_commit_internal(the_repository,
   E, F, G)
 
-@@
-expression E;
-expression F;
-@@
-- parse_commit_gently(
-+ repo_parse_commit_gently(the_repository,
-  E, F)
-
 @@
 expression E;
 @@
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-19  5:55   ` Elijah Newren
  2023-03-22 22:46   ` Glen Choo
  2023-03-17 15:35 ` [PATCH 03/17] cocci: sort "the_repository" rules by header Ævar Arnfjörð Bjarmason
                   ` (16 subsequent siblings)
  18 siblings, 2 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

When these rules started being added in [1] they didn't use a ";"
after the ")", and would thus catch uses of these macros within
expressions. But as of [2] the new additions were broken in that
they'd only match a subset of the users of these macros.

Rather than narrowly fixing that, let's have these use the much less
verbose pattern introduced in my recent [3]: There's no need to
exhaustively enumerate arguments if we use the "..." syntax. This
means that we can fold all of these different rules into one.

1. afd69dcc219 (object-store: prepare read_object_file to deal with
   any repo, 2018-11-13)
2. 21a9651ba3f (commit-reach: prepare get_merge_bases to handle any
   repo, 2018-11-13)
3. 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci,
   2022-11-19)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 .../coccinelle/the_repository.pending.cocci   | 160 +++++-------------
 1 file changed, 46 insertions(+), 114 deletions(-)

diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 23b97536da5..99e192736ee 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -3,118 +3,50 @@
 // our code base.
 
 @@
-expression E;
-expression F;
-expression G;
 @@
-- read_object_file(
-+ repo_read_object_file(the_repository,
-  E, F, G)
-
-@@
-expression E;
-@@
-- has_object_file(
-+ repo_has_object_file(the_repository,
-  E)
-
-@@
-expression E;
-@@
-- has_object_file_with_flags(
-+ repo_has_object_file_with_flags(the_repository,
-  E)
-
-@@
-expression E;
-expression F;
-expression G;
-@@
-- parse_commit_internal(
-+ repo_parse_commit_internal(the_repository,
-  E, F, G)
-
-@@
-expression E;
-@@
-- parse_commit(
-+ repo_parse_commit(the_repository,
-  E)
-
-@@
-expression E;
-expression F;
-@@
-- get_merge_bases(
-+ repo_get_merge_bases(the_repository,
-  E, F);
-
-@@
-expression E;
-expression F;
-expression G;
-@@
-- get_merge_bases_many(
-+ repo_get_merge_bases_many(the_repository,
-  E, F, G);
-
-@@
-expression E;
-expression F;
-expression G;
-@@
-- get_merge_bases_many_dirty(
-+ repo_get_merge_bases_many_dirty(the_repository,
-  E, F, G);
-
-@@
-expression E;
-expression F;
-@@
-- in_merge_bases(
-+ repo_in_merge_bases(the_repository,
-  E, F);
-
-@@
-expression E;
-expression F;
-expression G;
-@@
-- in_merge_bases_many(
-+ repo_in_merge_bases_many(the_repository,
-  E, F, G);
-
-@@
-expression E;
-expression F;
-@@
-- get_commit_buffer(
-+ repo_get_commit_buffer(the_repository,
-  E, F);
-
-@@
-expression E;
-expression F;
-@@
-- unuse_commit_buffer(
-+ repo_unuse_commit_buffer(the_repository,
-  E, F);
-
-@@
-expression E;
-expression F;
-expression G;
-@@
-- logmsg_reencode(
-+ repo_logmsg_reencode(the_repository,
-  E, F, G);
-
-@@
-expression E;
-expression F;
-expression G;
-expression H;
-@@
-- format_commit_message(
-+ repo_format_commit_message(the_repository,
-  E, F, G, H);
+(
+- read_object_file
++ repo_read_object_file
+|
+- has_object_file
++ repo_has_object_file
+|
+- has_object_file_with_flags
++ repo_has_object_file_with_flags
+|
+- parse_commit_internal
++ repo_parse_commit_internal
+|
+- parse_commit
++ repo_parse_commit
+|
+- get_merge_bases
++ repo_get_merge_bases
+|
+- get_merge_bases_many
++ repo_get_merge_bases_many
+|
+- get_merge_bases_many_dirty
++ repo_get_merge_bases_many_dirty
+|
+- in_merge_bases
++ repo_in_merge_bases
+|
+- in_merge_bases_many
++ repo_in_merge_bases_many
+|
+- get_commit_buffer
++ repo_get_commit_buffer
+|
+- unuse_commit_buffer
++ repo_unuse_commit_buffer
+|
+- logmsg_reencode
++ repo_logmsg_reencode
+|
+- format_commit_message
++ repo_format_commit_message
+)
+  (
++ the_repository,
+  ...)
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 03/17] cocci: sort "the_repository" rules by header
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-19  5:59   ` Elijah Newren
  2023-03-17 15:35 ` [PATCH 04/17] cocci: add missing "the_repository" macros to "pending" Ævar Arnfjörð Bjarmason
                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Sort the "the_repository.pending.cocci" file by which header the
macros are in, and add a comment to that effect in front of the
rules. This will make subsequent commits easier to follow, as we'll be
applying these rules on a header-by-header basis.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 .../coccinelle/the_repository.pending.cocci   | 34 +++++++++++--------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 99e192736ee..84b79dce480 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,21 +5,7 @@
 @@
 @@
 (
-- read_object_file
-+ repo_read_object_file
-|
-- has_object_file
-+ repo_has_object_file
-|
-- has_object_file_with_flags
-+ repo_has_object_file_with_flags
-|
-- parse_commit_internal
-+ repo_parse_commit_internal
-|
-- parse_commit
-+ repo_parse_commit
-|
+// commit-reach.h
 - get_merge_bases
 + repo_get_merge_bases
 |
@@ -34,6 +20,13 @@
 |
 - in_merge_bases_many
 + repo_in_merge_bases_many
+// commit.h
+|
+- parse_commit_internal
++ repo_parse_commit_internal
+|
+- parse_commit
++ repo_parse_commit
 |
 - get_commit_buffer
 + repo_get_commit_buffer
@@ -43,6 +36,17 @@
 |
 - logmsg_reencode
 + repo_logmsg_reencode
+// object-store.h
+|
+- read_object_file
++ repo_read_object_file
+|
+- has_object_file
++ repo_has_object_file
+|
+- has_object_file_with_flags
++ repo_has_object_file_with_flags
+// pretty.h
 |
 - format_commit_message
 + repo_format_commit_message
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 04/17] cocci: add missing "the_repository" macros to "pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (2 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 03/17] cocci: sort "the_repository" rules by header Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-19  6:04   ` Elijah Newren
  2023-03-17 15:35 ` [PATCH 05/17] cocci: apply the "cache.h" part of "the_repository.pending" Ævar Arnfjörð Bjarmason
                   ` (14 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

In the case of diff.h, rerere.h and revision.h the macros were added
in [1], [2] and [3] when "the_repository.pending.cocci" didn't
exist. None of the subsequently added migration rules covered
them. Let's add those missing rules.

In the case of macros in "cache.h", "commit.h", "packfile.h",
"promisor-remote.h" and "refs.h" those aren't guarded by
"NO_THE_REPOSITORY_COMPATIBILITY_MACROS", but they're also macros that
add "the_repository" as the first argument, so we should migrate away
from them.

1. 2abf3503854 (revision.c: remove implicit dependency on the_index,
   2018-09-21)
2. e6757652350 (diff.c: remove implicit dependency on the_index,
   2018-09-21)
3. 35843b1123e (rerere.c: remove implicit dependency on the_index,
   2018-09-21)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 .../coccinelle/the_repository.pending.cocci   | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 84b79dce480..8b3f2580e6b 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,7 +5,44 @@
 @@
 @@
 (
+// cache.h
+- get_oid
++ repo_get_oid
+|
+- get_oid_commit
++ repo_get_oid_commit
+|
+- get_oid_committish
++ repo_get_oid_committish
+|
+- get_oid_tree
++ repo_get_oid_tree
+|
+- get_oid_treeish
++ repo_get_oid_treeish
+|
+- get_oid_blob
++ repo_get_oid_blob
+|
+- get_oid_mb
++ repo_get_oid_mb
+|
+- find_unique_abbrev
++ repo_find_unique_abbrev
+|
+- find_unique_abbrev_r
++ repo_find_unique_abbrev_r
+|
+- for_each_abbrev
++ repo_for_each_abbrev
+|
+- interpret_branch_name
++ repo_interpret_branch_name
+|
+- peel_to_type
++ repo_peel_to_type
 // commit-reach.h
+|
 - get_merge_bases
 + repo_get_merge_bases
 |
@@ -36,6 +73,13 @@
 |
 - logmsg_reencode
 + repo_logmsg_reencode
+|
+- get_commit_tree
++ repo_get_commit_tree
+// diff.h
+|
+- diff_setup
++ repo_diff_setup
 // object-store.h
 |
 - read_object_file
@@ -50,6 +94,32 @@
 |
 - format_commit_message
 + repo_format_commit_message
+// packfile.h
+|
+- approximate_object_count
++ repo_approximate_object_count
+// promisor-remote.h
+|
+- promisor_remote_reinit
++ repo_promisor_remote_reinit
+|
+- promisor_remote_find
++ repo_promisor_remote_find
+|
+- has_promisor_remote
++ repo_has_promisor_remote
+// refs.h
+|
+- dwim_ref
++ repo_dwim_ref
+// rerere.h
+|
+- rerere
++ repo_rerere
+// revision.h
+|
+- init_revisions
++ repo_init_revisions
 )
   (
 + the_repository,
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 05/17] cocci: apply the "cache.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (3 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 04/17] cocci: add missing "the_repository" macros to "pending" Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-19  6:06   ` Elijah Newren
  2023-03-22 23:17   ` Glen Choo
  2023-03-17 15:35 ` [PATCH 06/17] cocci: apply the "commit-reach.h" " Ævar Arnfjörð Bjarmason
                   ` (13 subsequent siblings)
  18 siblings, 2 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"cache.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 add-patch.c                                   |  2 +-
 apply.c                                       |  4 +-
 archive.c                                     |  2 +-
 branch.c                                      |  2 +-
 builtin/am.c                                  | 16 +++---
 builtin/bisect.c                              | 19 +++----
 builtin/blame.c                               |  9 ++--
 builtin/branch.c                              |  2 +-
 builtin/checkout.c                            | 16 +++---
 builtin/commit-tree.c                         |  4 +-
 builtin/commit.c                              |  8 +--
 builtin/describe.c                            |  5 +-
 builtin/fast-import.c                         |  8 +--
 builtin/fetch.c                               |  2 +-
 builtin/fsck.c                                |  2 +-
 builtin/log.c                                 |  8 +--
 builtin/ls-files.c                            |  4 +-
 builtin/ls-tree.c                             |  9 ++--
 builtin/merge-base.c                          |  4 +-
 builtin/merge-recursive.c                     |  6 +--
 builtin/merge.c                               | 10 ++--
 builtin/name-rev.c                            |  7 +--
 builtin/notes.c                               | 22 ++++----
 builtin/prune.c                               |  2 +-
 builtin/pull.c                                |  4 +-
 builtin/range-diff.c                          | 12 ++---
 builtin/read-tree.c                           |  2 +-
 builtin/rebase.c                              | 12 +++--
 builtin/receive-pack.c                        | 10 ++--
 builtin/replace.c                             | 16 +++---
 builtin/reset.c                               | 19 +++----
 builtin/rev-list.c                            |  2 +-
 builtin/rev-parse.c                           | 12 +++--
 builtin/rm.c                                  |  2 +-
 builtin/show-branch.c                         | 12 ++---
 builtin/show-ref.c                            |  4 +-
 builtin/sparse-checkout.c                     |  2 +-
 builtin/stash.c                               | 13 ++---
 builtin/submodule--helper.c                   |  4 +-
 builtin/tag.c                                 |  6 +--
 builtin/unpack-file.c                         |  2 +-
 builtin/update-ref.c                          |  8 +--
 builtin/verify-commit.c                       |  2 +-
 builtin/verify-tag.c                          |  2 +-
 builtin/worktree.c                            |  8 +--
 cache.h                                       | 15 ------
 checkout.c                                    |  2 +-
 combine-diff.c                                |  6 +--
 commit.c                                      | 10 ++--
 contrib/coccinelle/the_repository.cocci       | 44 ++++++++++++++++
 .../coccinelle/the_repository.pending.cocci   | 37 --------------
 diff-lib.c                                    |  2 +-
 diff.c                                        |  4 +-
 fmt-merge-msg.c                               |  4 +-
 log-tree.c                                    | 15 +++---
 mailmap.c                                     |  2 +-
 notes-merge.c                                 |  2 +-
 notes.c                                       |  6 +--
 object-name.c                                 |  5 +-
 parse-options-cb.c                            |  8 +--
 range-diff.c                                  |  8 +--
 read-cache.c                                  |  2 +-
 rebase-interactive.c                          |  2 +-
 ref-filter.c                                  |  8 +--
 remote.c                                      |  6 +--
 reset.c                                       |  4 +-
 revision.c                                    | 11 ++--
 sequencer.c                                   | 51 ++++++++++---------
 submodule-config.c                            |  2 +-
 submodule.c                                   |  8 +--
 t/helper/test-fast-rebase.c                   | 10 ++--
 t/helper/test-match-trees.c                   |  4 +-
 t/helper/test-oidmap.c                        |  6 +--
 t/helper/test-reach.c                         |  2 +-
 t/helper/test-submodule-config.c              |  2 +-
 tag.c                                         |  4 +-
 transport-helper.c                            |  2 +-
 transport.c                                   |  3 +-
 wt-status.c                                   | 18 +++----
 79 files changed, 332 insertions(+), 310 deletions(-)
 create mode 100644 contrib/coccinelle/the_repository.cocci

diff --git a/add-patch.c b/add-patch.c
index a86a92e1646..3cbb9591945 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -414,7 +414,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 		strvec_push(&args,
 			    /* could be on an unborn branch */
 			    !strcmp("HEAD", s->revision) &&
-			    get_oid("HEAD", &oid) ?
+			    repo_get_oid(the_repository, "HEAD", &oid) ?
 			    empty_tree_oid_hex() : s->revision);
 	}
 	color_arg_index = args.nr;
diff --git a/apply.c b/apply.c
index 5cc5479c9c3..57f45cedd2b 100644
--- a/apply.c
+++ b/apply.c
@@ -3610,7 +3610,7 @@ static int try_threeway(struct apply_state *state,
 	/* Preimage the patch was prepared for */
 	if (patch->is_new)
 		write_object_file("", 0, OBJ_BLOB, &pre_oid);
-	else if (get_oid(patch->old_oid_prefix, &pre_oid) ||
+	else if (repo_get_oid(the_repository, patch->old_oid_prefix, &pre_oid) ||
 		 read_blob_object(&buf, &pre_oid, patch->old_mode))
 		return error(_("repository lacks the necessary blob to perform 3-way merge."));
 
@@ -4127,7 +4127,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
 			else
 				return error(_("sha1 information is lacking or "
 					       "useless for submodule %s"), name);
-		} else if (!get_oid_blob(patch->old_oid_prefix, &oid)) {
+		} else if (!repo_get_oid_blob(the_repository, patch->old_oid_prefix, &oid)) {
 			; /* ok */
 		} else if (!patch->lines_added && !patch->lines_deleted) {
 			/* mode-only change: update the current */
diff --git a/archive.c b/archive.c
index 9aeaf2bd87d..732e2100544 100644
--- a/archive.c
+++ b/archive.c
@@ -461,7 +461,7 @@ static void parse_treeish_arg(const char **argv,
 		dwim_ref(name, strlen(name), &oid, &ref, 0);
 	}
 
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		die(_("not a valid object name: %s"), name);
 
 	commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);
diff --git a/branch.c b/branch.c
index e5614b53b36..2efb5fbaa5f 100644
--- a/branch.c
+++ b/branch.c
@@ -531,7 +531,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
 		explicit_tracking = 1;
 
 	real_ref = NULL;
-	if (get_oid_mb(start_name, &oid)) {
+	if (repo_get_oid_mb(the_repository, start_name, &oid)) {
 		if (explicit_tracking) {
 			int code = die_message(_(upstream_missing), start_name);
 			advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
diff --git a/builtin/am.c b/builtin/am.c
index e0848ddadfe..c04038f1f3d 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1066,7 +1066,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
 	else
 		write_state_text(state, "applying", "");
 
-	if (!get_oid("HEAD", &curr_head)) {
+	if (!repo_get_oid(the_repository, "HEAD", &curr_head)) {
 		write_state_text(state, "abort-safety", oid_to_hex(&curr_head));
 		if (!state->rebasing)
 			update_ref("am", "ORIG_HEAD", &curr_head, NULL, 0,
@@ -1109,7 +1109,7 @@ static void am_next(struct am_state *state)
 	unlink(am_path(state, "original-commit"));
 	delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
 
-	if (!get_oid("HEAD", &head))
+	if (!repo_get_oid(the_repository, "HEAD", &head))
 		write_state_text(state, "abort-safety", oid_to_hex(&head));
 	else
 		write_state_text(state, "abort-safety", "");
@@ -1402,7 +1402,7 @@ static void write_index_patch(const struct am_state *state)
 	struct rev_info rev_info;
 	FILE *fp;
 
-	if (!get_oid("HEAD", &head)) {
+	if (!repo_get_oid(the_repository, "HEAD", &head)) {
 		struct commit *commit = lookup_commit_or_die(&head, "HEAD");
 		tree = get_commit_tree(commit);
 	} else
@@ -1556,7 +1556,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
 	struct commit *result;
 	char *their_tree_name;
 
-	if (get_oid("HEAD", &our_tree) < 0)
+	if (repo_get_oid(the_repository, "HEAD", &our_tree) < 0)
 		oidcpy(&our_tree, the_hash_algo->empty_tree);
 
 	if (build_fake_ancestor(state, index_path))
@@ -1646,7 +1646,7 @@ static void do_commit(const struct am_state *state)
 	if (write_index_as_tree(&tree, &the_index, get_index_file(), 0, NULL))
 		die(_("git write-tree failed to write a tree"));
 
-	if (!get_oid_commit("HEAD", &parent)) {
+	if (!repo_get_oid_commit(the_repository, "HEAD", &parent)) {
 		old_oid = &parent;
 		commit_list_insert(lookup_commit(the_repository, &parent),
 				   &parents);
@@ -2088,7 +2088,7 @@ static void am_skip(struct am_state *state)
 
 	am_rerere_clear();
 
-	if (get_oid("HEAD", &head))
+	if (repo_get_oid(the_repository, "HEAD", &head))
 		oidcpy(&head, the_hash_algo->empty_tree);
 
 	if (clean_index(&head, &head))
@@ -2130,7 +2130,7 @@ static int safe_to_abort(const struct am_state *state)
 		oidclr(&abort_safety);
 	strbuf_release(&sb);
 
-	if (get_oid("HEAD", &head))
+	if (repo_get_oid(the_repository, "HEAD", &head))
 		oidclr(&head);
 
 	if (oideq(&head, &abort_safety))
@@ -2163,7 +2163,7 @@ static void am_abort(struct am_state *state)
 	if (!has_curr_head)
 		oidcpy(&curr_head, the_hash_algo->empty_tree);
 
-	has_orig_head = !get_oid("ORIG_HEAD", &orig_head);
+	has_orig_head = !repo_get_oid(the_repository, "ORIG_HEAD", &orig_head);
 	if (!has_orig_head)
 		oidcpy(&orig_head, the_hash_algo->empty_tree);
 
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 73017402671..7d51eecab82 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -235,7 +235,7 @@ static int bisect_reset(const char *commit)
 	} else {
 		struct object_id oid;
 
-		if (get_oid_commit(commit, &oid))
+		if (repo_get_oid_commit(the_repository, commit, &oid))
 			return error(_("'%s' is not a valid commit"), commit);
 		strbuf_addstr(&branch, commit);
 	}
@@ -292,7 +292,7 @@ static int bisect_write(const char *state, const char *rev,
 		goto finish;
 	}
 
-	if (get_oid(rev, &oid)) {
+	if (repo_get_oid(the_repository, rev, &oid)) {
 		res = error(_("couldn't get the oid of the rev '%s'"), rev);
 		goto finish;
 	}
@@ -775,7 +775,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
 	 */
 	head = resolve_ref_unsafe("HEAD", 0, &head_oid, &flags);
 	if (!head)
-		if (get_oid("HEAD", &head_oid))
+		if (repo_get_oid(the_repository, "HEAD", &head_oid))
 			return error(_("bad HEAD - I need a HEAD"));
 
 	/*
@@ -801,11 +801,11 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
 		}
 	} else {
 		/* Get the rev from where we start. */
-		if (!get_oid(head, &head_oid) &&
+		if (!repo_get_oid(the_repository, head, &head_oid) &&
 		    !starts_with(head, "refs/heads/")) {
 			strbuf_reset(&start_head);
 			strbuf_addstr(&start_head, oid_to_hex(&head_oid));
-		} else if (!get_oid(head, &head_oid) &&
+		} else if (!repo_get_oid(the_repository, head, &head_oid) &&
 			   skip_prefix(head, "refs/heads/", &head)) {
 			strbuf_addstr(&start_head, head);
 		} else {
@@ -828,7 +828,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
 		write_file(git_path_bisect_first_parent(), "\n");
 
 	if (no_checkout) {
-		if (get_oid(start_head.buf, &oid) < 0) {
+		if (repo_get_oid(the_repository, start_head.buf, &oid) < 0) {
 			res = error(_("invalid ref: '%s'"), start_head.buf);
 			goto finish;
 		}
@@ -933,11 +933,12 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
 
 	if (argc == 0) {
 		const char *head = "BISECT_HEAD";
-		enum get_oid_result res_head = get_oid(head, &oid);
+		enum get_oid_result res_head = repo_get_oid(the_repository,
+							    head, &oid);
 
 		if (res_head == MISSING_OBJECT) {
 			head = "HEAD";
-			res_head = get_oid(head, &oid);
+			res_head = repo_get_oid(the_repository, head, &oid);
 		}
 
 		if (res_head)
@@ -953,7 +954,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
 	for (; argc; argc--, argv++) {
 		struct commit *commit;
 
-		if (get_oid(*argv, &oid)){
+		if (repo_get_oid(the_repository, *argv, &oid)){
 			error(_("Bad rev input: %s"), *argv);
 			oid_array_clear(&revs);
 			return BISECT_FAILED;
diff --git a/builtin/blame.c b/builtin/blame.c
index 71f925e456c..0155062de11 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -601,8 +601,9 @@ static int read_ancestry(const char *graft_file)
 
 static int update_auto_abbrev(int auto_abbrev, struct blame_origin *suspect)
 {
-	const char *uniq = find_unique_abbrev(&suspect->commit->object.oid,
-					      auto_abbrev);
+	const char *uniq = repo_find_unique_abbrev(the_repository,
+						   &suspect->commit->object.oid,
+						   auto_abbrev);
 	int len = strlen(uniq);
 	if (auto_abbrev < len)
 		return len;
@@ -802,7 +803,7 @@ static int is_a_rev(const char *name)
 {
 	struct object_id oid;
 
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return 0;
 	return OBJ_NONE < oid_object_info(the_repository, &oid, NULL);
 }
@@ -845,7 +846,7 @@ static void build_ignorelist(struct blame_scoreboard *sb,
 						    peel_to_commit_oid, sb);
 	}
 	for_each_string_list_item(i, ignore_rev_list) {
-		if (get_oid_committish(i->string, &oid) ||
+		if (repo_get_oid_committish(the_repository, i->string, &oid) ||
 		    peel_to_commit_oid(&oid, sb))
 			die(_("cannot find revision %s to ignore"), i->string);
 		oidset_insert(&sb->ignore_list, &oid);
diff --git a/builtin/branch.c b/builtin/branch.c
index f63fd45edb9..968ea03c059 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -280,7 +280,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
 		item = string_list_append(&refs_to_delete, name);
 		item->util = xstrdup((flags & REF_ISBROKEN) ? "broken"
 				    : (flags & REF_ISSYMREF) ? target
-				    : find_unique_abbrev(&oid, DEFAULT_ABBREV));
+				    : repo_find_unique_abbrev(the_repository, &oid, DEFAULT_ABBREV));
 
 	next:
 		free(target);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a5155cf55c1..6216bb6bba3 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -432,8 +432,8 @@ static int checkout_worktree(const struct checkout_opts *opts,
 					      "Updated %d paths from %s",
 					      nr_checkouts),
 				   nr_checkouts,
-				   find_unique_abbrev(&opts->source_tree->object.oid,
-						      DEFAULT_ABBREV));
+				   repo_find_unique_abbrev(the_repository, &opts->source_tree->object.oid,
+							   DEFAULT_ABBREV));
 		else if (!nr_unmerged || nr_checkouts)
 			fprintf_ln(stderr, Q_("Updated %d path from the index",
 					      "Updated %d paths from the index",
@@ -644,10 +644,12 @@ static void describe_detached_head(const char *msg, struct commit *commit)
 		pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
 	if (print_sha1_ellipsis()) {
 		fprintf(stderr, "%s %s... %s\n", msg,
-			find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
+			repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
+			sb.buf);
 	} else {
 		fprintf(stderr, "%s %s %s\n", msg,
-			find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
+			repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
+			sb.buf);
 	}
 	strbuf_release(&sb);
 }
@@ -1060,7 +1062,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
 			" git branch <new-branch-name> %s\n\n",
 			/* Give ngettext() the count */
 			lost),
-			find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
+			repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
 }
 
 /*
@@ -1322,7 +1324,7 @@ static int parse_branchname_arg(int argc, const char **argv,
 	if (!strcmp(arg, "-"))
 		arg = "@{-1}";
 
-	if (get_oid_mb(arg, rev)) {
+	if (repo_get_oid_mb(the_repository, arg, rev)) {
 		/*
 		 * Either case (3) or (4), with <something> not being
 		 * a commit, or an attempt to use case (1) with an
@@ -1748,7 +1750,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
 	} else if (!opts->accept_ref && opts->from_treeish) {
 		struct object_id rev;
 
-		if (get_oid_mb(opts->from_treeish, &rev))
+		if (repo_get_oid_mb(the_repository, opts->from_treeish, &rev))
 			die(_("could not resolve %s"), opts->from_treeish);
 
 		setup_new_branch_info_and_source_tree(new_branch_info,
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index cc8d584be2f..7941512c19f 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -53,7 +53,7 @@ static int parse_parent_arg_callback(const struct option *opt,
 
 	BUG_ON_OPT_NEG_NOARG(unset, arg);
 
-	if (get_oid_commit(arg, &oid))
+	if (repo_get_oid_commit(the_repository, arg, &oid))
 		die(_("not a valid object name %s"), arg);
 
 	assert_oid_type(&oid, OBJ_COMMIT);
@@ -131,7 +131,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 	if (argc != 1)
 		die(_("must give exactly one tree"));
 
-	if (get_oid_tree(argv[0], &tree_oid))
+	if (repo_get_oid_tree(the_repository, argv[0], &tree_oid))
 		die(_("not a valid object name %s"), argv[0]);
 
 	if (!buffer.len) {
diff --git a/builtin/commit.c b/builtin/commit.c
index 985a0445b78..80d1e31f25a 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -557,7 +557,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
 	s->index_file = index_file;
 	s->fp = fp;
 	s->nowarn = nowarn;
-	s->is_initial = get_oid(s->reference, &oid) ? 1 : 0;
+	s->is_initial = repo_get_oid(the_repository, s->reference, &oid) ? 1 : 0;
 	if (!s->is_initial)
 		oidcpy(&s->oid_commit, &oid);
 	s->status_format = status_format;
@@ -1000,7 +1000,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		if (amend)
 			parent = "HEAD^1";
 
-		if (get_oid(parent, &oid)) {
+		if (repo_get_oid(the_repository, parent, &oid)) {
 			int i, ita_nr = 0;
 
 			/* TODO: audit for interaction with sparse-index. */
@@ -1567,7 +1567,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
 	else
 		fd = -1;
 
-	s.is_initial = get_oid(s.reference, &oid) ? 1 : 0;
+	s.is_initial = repo_get_oid(the_repository, s.reference, &oid) ? 1 : 0;
 	if (!s.is_initial)
 		oidcpy(&s.oid_commit, &oid);
 
@@ -1714,7 +1714,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
 	s.colopts = 0;
 
-	if (get_oid("HEAD", &oid))
+	if (repo_get_oid(the_repository, "HEAD", &oid))
 		current_head = NULL;
 	else {
 		current_head = lookup_commit_or_die(&oid, "HEAD");
diff --git a/builtin/describe.c b/builtin/describe.c
index eea1e330c00..c85bf9c418b 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -298,7 +298,8 @@ static void append_name(struct commit_name *n, struct strbuf *dst)
 
 static void append_suffix(int depth, const struct object_id *oid, struct strbuf *dst)
 {
-	strbuf_addf(dst, "-%d-g%s", depth, find_unique_abbrev(oid, abbrev));
+	strbuf_addf(dst, "-%d-g%s", depth,
+		    repo_find_unique_abbrev(the_repository, oid, abbrev));
 }
 
 static void describe_commit(struct object_id *oid, struct strbuf *dst)
@@ -531,7 +532,7 @@ static void describe(const char *arg, int last_one)
 	if (debug)
 		fprintf(stderr, _("describe %s\n"), arg);
 
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		die(_("Not a valid object name %s"), arg);
 	cmit = lookup_commit_reference_gently(the_repository, &oid, 1);
 
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 7134683ab93..f533b768efb 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -2486,7 +2486,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
 		if (commit_oe->type != OBJ_COMMIT)
 			die("Mark :%" PRIuMAX " not a commit", commit_mark);
 		oidcpy(&commit_oid, &commit_oe->idx.oid);
-	} else if (!get_oid(p, &commit_oid)) {
+	} else if (!repo_get_oid(the_repository, p, &commit_oid)) {
 		unsigned long size;
 		char *buf = read_object_with_reference(the_repository,
 						       &commit_oid,
@@ -2599,7 +2599,7 @@ static int parse_objectish(struct branch *b, const char *objectish)
 			} else
 				parse_from_existing(b);
 		}
-	} else if (!get_oid(objectish, &b->oid)) {
+	} else if (!repo_get_oid(the_repository, objectish, &b->oid)) {
 		parse_from_existing(b);
 		if (is_null_oid(&b->oid))
 			b->delete = 1;
@@ -2654,7 +2654,7 @@ static struct hash_list *parse_merge(unsigned int *count)
 			if (oe->type != OBJ_COMMIT)
 				die("Mark :%" PRIuMAX " not a commit", idnum);
 			oidcpy(&n->oid, &oe->idx.oid);
-		} else if (!get_oid(from, &n->oid)) {
+		} else if (!repo_get_oid(the_repository, from, &n->oid)) {
 			unsigned long size;
 			char *buf = read_object_with_reference(the_repository,
 							       &n->oid,
@@ -2827,7 +2827,7 @@ static void parse_new_tag(const char *arg)
 		oe = find_mark(marks, from_mark);
 		type = oe->type;
 		oidcpy(&oid, &oe->idx.oid);
-	} else if (!get_oid(from, &oid)) {
+	} else if (!repo_get_oid(the_repository, from, &oid)) {
 		struct object_entry *oe = find_object(&oid);
 		if (!oe) {
 			type = oid_object_info(the_repository, &oid, NULL);
diff --git a/builtin/fetch.c b/builtin/fetch.c
index a09606b4726..80cf1d01583 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1487,7 +1487,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
 		int old_nr;
 		if (!has_glob_specials(s)) {
 			struct object_id oid;
-			if (get_oid(s, &oid))
+			if (repo_get_oid(the_repository, s, &oid))
 				die(_("%s is not a valid object"), s);
 			if (!has_object(the_repository, &oid, 0))
 				die(_("the object %s does not exist"), s);
diff --git a/builtin/fsck.c b/builtin/fsck.c
index d207bd909b4..2bf183a43be 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -923,7 +923,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 	for (i = 0; i < argc; i++) {
 		const char *arg = argv[i];
 		struct object_id oid;
-		if (!get_oid(arg, &oid)) {
+		if (!repo_get_oid(the_repository, arg, &oid)) {
 			struct object *obj = lookup_object(the_repository,
 							   &oid);
 
diff --git a/builtin/log.c b/builtin/log.c
index a70fba198f9..b4c38f6ad87 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1642,7 +1642,7 @@ static struct commit *get_base_commit(const char *base_commit,
 			struct commit *commit;
 			struct object_id oid;
 
-			if (get_oid(upstream, &oid)) {
+			if (repo_get_oid(the_repository, upstream, &oid)) {
 				if (die_on_failure)
 					die(_("failed to resolve '%s' as a valid ref"), upstream);
 				else
@@ -2396,7 +2396,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
 {
 	struct object_id oid;
-	if (get_oid(arg, &oid) == 0) {
+	if (repo_get_oid(the_repository, arg, &oid) == 0) {
 		struct commit *commit = lookup_commit_reference(the_repository,
 								&oid);
 		if (commit) {
@@ -2418,12 +2418,12 @@ static void print_commit(char sign, struct commit *commit, int verbose,
 {
 	if (!verbose) {
 		fprintf(file, "%c %s\n", sign,
-		       find_unique_abbrev(&commit->object.oid, abbrev));
+		       repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev));
 	} else {
 		struct strbuf buf = STRBUF_INIT;
 		pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
 		fprintf(file, "%c %s %s\n", sign,
-		       find_unique_abbrev(&commit->object.oid, abbrev),
+		       repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev),
 		       buf.buf);
 		strbuf_release(&buf);
 	}
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index a03b559ecaa..c10d51a969d 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -360,7 +360,7 @@ static void show_ru_info(struct index_state *istate)
 			if (!ui->mode[i])
 				continue;
 			printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
-			       find_unique_abbrev(&ui->oid[i], abbrev),
+			       repo_find_unique_abbrev(the_repository, &ui->oid[i], abbrev),
 			       i + 1);
 			write_name(path);
 		}
@@ -575,7 +575,7 @@ void overlay_tree_on_index(struct index_state *istate,
 	read_tree_fn_t fn = NULL;
 	int err;
 
-	if (get_oid(tree_name, &oid))
+	if (repo_get_oid(the_repository, tree_name, &oid))
 		die("tree-ish %s not found.", tree_name);
 	tree = parse_tree_indirect(&oid);
 	if (!tree)
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 8cc8c995df9..ebcc8fd6ff8 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -228,7 +228,7 @@ static int show_tree_default(const struct object_id *oid, struct strbuf *base,
 		return early;
 
 	printf("%06o %s %s\t", mode, type_name(object_type(mode)),
-	       find_unique_abbrev(oid, options->abbrev));
+	       repo_find_unique_abbrev(the_repository, oid, options->abbrev));
 	show_tree_common_default_long(options, base, pathname, base->len);
 	return recurse;
 }
@@ -259,7 +259,8 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,
 	}
 
 	printf("%06o %s %s %7s\t", mode, type_name(type),
-	       find_unique_abbrev(oid, options->abbrev), size_text);
+	       repo_find_unique_abbrev(the_repository, oid, options->abbrev),
+	       size_text);
 	show_tree_common_default_long(options, base, pathname, base->len);
 	return recurse;
 }
@@ -310,7 +311,7 @@ static int show_tree_object(const struct object_id *oid, struct strbuf *base,
 	if (early >= 0)
 		return early;
 
-	str = find_unique_abbrev(oid, options->abbrev);
+	str = repo_find_unique_abbrev(the_repository, oid, options->abbrev);
 	if (options->null_termination) {
 		fputs(str, stdout);
 		fputc('\0', stdout);
@@ -433,7 +434,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
 			ls_tree_usage, ls_tree_options);
 	if (argc < 1)
 		usage_with_options(ls_tree_usage, ls_tree_options);
-	if (get_oid(argv[0], &oid))
+	if (repo_get_oid(the_repository, argv[0], &oid))
 		die("Not a valid object name %s", argv[0]);
 
 	/*
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 6f3941f2a49..688d5c29b76 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -42,7 +42,7 @@ static struct commit *get_commit_reference(const char *arg)
 	struct object_id revkey;
 	struct commit *r;
 
-	if (get_oid(arg, &revkey))
+	if (repo_get_oid(the_repository, arg, &revkey))
 		die("Not a valid object name %s", arg);
 	r = lookup_commit_reference(the_repository, &revkey);
 	if (!r)
@@ -118,7 +118,7 @@ static int handle_fork_point(int argc, const char **argv)
 	const char *commitname;
 
 	commitname = (argc == 2) ? argv[1] : "HEAD";
-	if (get_oid(commitname, &oid))
+	if (repo_get_oid(the_repository, commitname, &oid))
 		die("Not a valid object name: '%s'", commitname);
 
 	derived = lookup_commit_reference(the_repository, &oid);
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index b9acbf5d342..a50b328d943 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -49,7 +49,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
 		}
 		if (bases_count < ARRAY_SIZE(bases)-1) {
 			struct object_id *oid = xmalloc(sizeof(struct object_id));
-			if (get_oid(argv[i], oid))
+			if (repo_get_oid(the_repository, argv[i], oid))
 				die(_("could not parse object '%s'"), argv[i]);
 			bases[bases_count++] = oid;
 		}
@@ -70,9 +70,9 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
 	o.branch1 = argv[++i];
 	o.branch2 = argv[++i];
 
-	if (get_oid(o.branch1, &h1))
+	if (repo_get_oid(the_repository, o.branch1, &h1))
 		die(_("could not resolve ref '%s'"), o.branch1);
-	if (get_oid(o.branch2, &h2))
+	if (repo_get_oid(the_repository, o.branch2, &h2))
 		die(_("could not resolve ref '%s'"), o.branch2);
 
 	o.branch1 = better1 = better_branch_name(o.branch1);
diff --git a/builtin/merge.c b/builtin/merge.c
index 0a3c10a0966..7331a0cd911 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -337,7 +337,7 @@ static int save_state(struct object_id *stash)
 	else if (!len)		/* no changes */
 		goto out;
 	strbuf_setlen(&buffer, buffer.len-1);
-	if (get_oid(buffer.buf, stash))
+	if (repo_get_oid(the_repository, buffer.buf, stash))
 		die(_("not a valid object: %s"), buffer.buf);
 	rc = 0;
 out:
@@ -1567,10 +1567,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 
 		if (verbosity >= 0) {
 			printf(_("Updating %s..%s\n"),
-			       find_unique_abbrev(&head_commit->object.oid,
-						  DEFAULT_ABBREV),
-			       find_unique_abbrev(&remoteheads->item->object.oid,
-						  DEFAULT_ABBREV));
+			       repo_find_unique_abbrev(the_repository, &head_commit->object.oid,
+						       DEFAULT_ABBREV),
+			       repo_find_unique_abbrev(the_repository, &remoteheads->item->object.oid,
+						       DEFAULT_ABBREV));
 		}
 		commit = remoteheads->item;
 		if (!commit) {
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 97959bfaf9e..35fd89f794d 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -493,7 +493,8 @@ static void show_name(const struct object *obj,
 	else if (allow_undefined)
 		printf("undefined\n");
 	else if (always)
-		printf("%s\n", find_unique_abbrev(oid, DEFAULT_ABBREV));
+		printf("%s\n",
+		       repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
 	else
 		die("cannot describe '%s'", oid_to_hex(oid));
 	strbuf_release(&buf);
@@ -527,7 +528,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)
 			counter = 0;
 
 			*(p+1) = 0;
-			if (!get_oid(p - (hexsz - 1), &oid)) {
+			if (!repo_get_oid(the_repository, p - (hexsz - 1), &oid)) {
 				struct object *o =
 					lookup_object(the_repository, &oid);
 				if (o)
@@ -604,7 +605,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
 		struct object *object;
 		struct commit *commit;
 
-		if (get_oid(*argv, &oid)) {
+		if (repo_get_oid(the_repository, *argv, &oid)) {
 			fprintf(stderr, "Could not get sha1 for %s. Skipping.\n",
 					*argv);
 			continue;
diff --git a/builtin/notes.c b/builtin/notes.c
index 80d9dfd25ca..d98460e5d61 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -257,7 +257,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
 	if (d->buf.len)
 		strbuf_addch(&d->buf, '\n');
 
-	if (get_oid(arg, &object))
+	if (repo_get_oid(the_repository, arg, &object))
 		die(_("failed to resolve '%s' as a valid ref."), arg);
 	if (!(buf = read_object_file(&object, &type, &len)))
 		die(_("failed to read object '%s'."), arg);
@@ -307,9 +307,9 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
 			die(_("malformed input line: '%s'."), buf.buf);
 		strbuf_rtrim(split[0]);
 		strbuf_rtrim(split[1]);
-		if (get_oid(split[0]->buf, &from_obj))
+		if (repo_get_oid(the_repository, split[0]->buf, &from_obj))
 			die(_("failed to resolve '%s' as a valid ref."), split[0]->buf);
-		if (get_oid(split[1]->buf, &to_obj))
+		if (repo_get_oid(the_repository, split[1]->buf, &to_obj))
 			die(_("failed to resolve '%s' as a valid ref."), split[1]->buf);
 
 		if (rewrite_cmd)
@@ -377,7 +377,7 @@ static int list(int argc, const char **argv, const char *prefix)
 
 	t = init_notes_check("list", 0);
 	if (argc) {
-		if (get_oid(argv[0], &object))
+		if (repo_get_oid(the_repository, argv[0], &object))
 			die(_("failed to resolve '%s' as a valid ref."), argv[0]);
 		note = get_note(t, &object);
 		if (note) {
@@ -432,7 +432,7 @@ static int add(int argc, const char **argv, const char *prefix)
 
 	object_ref = argc > 1 ? argv[1] : "HEAD";
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		die(_("failed to resolve '%s' as a valid ref."), object_ref);
 
 	t = init_notes_check("add", NOTES_INIT_WRITABLE);
@@ -520,12 +520,12 @@ static int copy(int argc, const char **argv, const char *prefix)
 		usage_with_options(git_notes_copy_usage, options);
 	}
 
-	if (get_oid(argv[0], &from_obj))
+	if (repo_get_oid(the_repository, argv[0], &from_obj))
 		die(_("failed to resolve '%s' as a valid ref."), argv[0]);
 
 	object_ref = 1 < argc ? argv[1] : "HEAD";
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		die(_("failed to resolve '%s' as a valid ref."), object_ref);
 
 	t = init_notes_check("copy", NOTES_INIT_WRITABLE);
@@ -604,7 +604,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)
 
 	object_ref = 1 < argc ? argv[1] : "HEAD";
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		die(_("failed to resolve '%s' as a valid ref."), object_ref);
 
 	t = init_notes_check(argv[0], NOTES_INIT_WRITABLE);
@@ -666,7 +666,7 @@ static int show(int argc, const char **argv, const char *prefix)
 
 	object_ref = argc ? argv[0] : "HEAD";
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		die(_("failed to resolve '%s' as a valid ref."), object_ref);
 
 	t = init_notes_check("show", 0);
@@ -716,7 +716,7 @@ static int merge_commit(struct notes_merge_options *o)
 	 * and target notes ref from .git/NOTES_MERGE_REF.
 	 */
 
-	if (get_oid("NOTES_MERGE_PARTIAL", &oid))
+	if (repo_get_oid(the_repository, "NOTES_MERGE_PARTIAL", &oid))
 		die(_("failed to read ref NOTES_MERGE_PARTIAL"));
 	else if (!(partial = lookup_commit_reference(the_repository, &oid)))
 		die(_("could not find commit from NOTES_MERGE_PARTIAL."));
@@ -895,7 +895,7 @@ static int remove_one_note(struct notes_tree *t, const char *name, unsigned flag
 {
 	int status;
 	struct object_id oid;
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return error(_("Failed to resolve '%s' as a valid ref."), name);
 	status = remove_note(t, oid.hash);
 	if (status)
diff --git a/builtin/prune.c b/builtin/prune.c
index 27192201086..93be90825dc 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -168,7 +168,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
 		struct object_id oid;
 		const char *name = *argv++;
 
-		if (!get_oid(name, &oid)) {
+		if (!repo_get_oid(the_repository, name, &oid)) {
 			struct object *object = parse_object_or_die(&oid,
 								    name);
 			add_pending_object(&revs, object, "");
diff --git a/builtin/pull.c b/builtin/pull.c
index 1ab4de0005d..880eebcdd65 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -1036,7 +1036,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
 	if (file_exists(git_path_merge_head(the_repository)))
 		die_conclude_merge();
 
-	if (get_oid("HEAD", &orig_head))
+	if (repo_get_oid(the_repository, "HEAD", &orig_head))
 		oidclr(&orig_head);
 
 	if (opt_rebase) {
@@ -1061,7 +1061,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
 	if (opt_dry_run)
 		return 0;
 
-	if (get_oid("HEAD", &curr_head))
+	if (repo_get_oid(the_repository, "HEAD", &curr_head))
 		oidclr(&curr_head);
 
 	if (!is_null_oid(&orig_head) && !is_null_oid(&curr_head) &&
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index aecfae12d3a..556ee84b6d3 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -65,20 +65,20 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
 
 	if (dash_dash == 3 ||
 	    (dash_dash < 0 && argc > 2 &&
-	     !get_oid_committish(argv[0], &oid) &&
-	     !get_oid_committish(argv[1], &oid) &&
-	     !get_oid_committish(argv[2], &oid))) {
+	     !repo_get_oid_committish(the_repository, argv[0], &oid) &&
+	     !repo_get_oid_committish(the_repository, argv[1], &oid) &&
+	     !repo_get_oid_committish(the_repository, argv[2], &oid))) {
 		if (dash_dash < 0)
 			; /* already validated arguments */
-		else if (get_oid_committish(argv[0], &oid))
+		else if (repo_get_oid_committish(the_repository, argv[0], &oid))
 			usage_msg_optf(_("not a revision: '%s'"),
 				       builtin_range_diff_usage, options,
 				       argv[0]);
-		else if (get_oid_committish(argv[1], &oid))
+		else if (repo_get_oid_committish(the_repository, argv[1], &oid))
 			usage_msg_optf(_("not a revision: '%s'"),
 				       builtin_range_diff_usage, options,
 				       argv[1]);
-		else if (get_oid_committish(argv[2], &oid))
+		else if (repo_get_oid_committish(the_repository, argv[2], &oid))
 			usage_msg_optf(_("not a revision: '%s'"),
 				       builtin_range_diff_usage, options,
 				       argv[2]);
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 3ce75417833..a1c6aa9641c 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -198,7 +198,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
 	for (i = 0; i < argc; i++) {
 		const char *arg = argv[i];
 
-		if (get_oid(arg, &oid))
+		if (repo_get_oid(the_repository, arg, &oid))
 			die("Not a valid object name %s", arg);
 		if (list_tree(&oid) < 0)
 			die("failed to unpack tree object %s", arg);
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 6635f10d529..d5358ca89d2 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -218,13 +218,15 @@ static int get_revision_ranges(struct commit *upstream, struct commit *onto,
 	*revisions = xstrfmt("%s...%s", oid_to_hex(&base_rev->object.oid),
 			     oid_to_hex(orig_head));
 
-	shorthead = find_unique_abbrev(orig_head, DEFAULT_ABBREV);
+	shorthead = repo_find_unique_abbrev(the_repository, orig_head,
+					    DEFAULT_ABBREV);
 
 	if (upstream) {
 		const char *shortrev;
 
-		shortrev = find_unique_abbrev(&base_rev->object.oid,
-					      DEFAULT_ABBREV);
+		shortrev = repo_find_unique_abbrev(the_repository,
+						   &base_rev->object.oid,
+						   DEFAULT_ABBREV);
 
 		*shortrevisions = xstrfmt("%s..%s", shortrev, shorthead);
 	} else
@@ -1261,7 +1263,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		int fd;
 
 		/* Sanity check */
-		if (get_oid("HEAD", &head))
+		if (repo_get_oid(the_repository, "HEAD", &head))
 			die(_("Cannot read HEAD"));
 
 		fd = repo_hold_locked_index(the_repository, &lock_file, 0);
@@ -1680,7 +1682,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	} else if (!options.onto_name)
 		options.onto_name = options.upstream_name;
 	if (strstr(options.onto_name, "...")) {
-		if (get_oid_mb(options.onto_name, &branch_base) < 0) {
+		if (repo_get_oid_mb(the_repository, options.onto_name, &branch_base) < 0) {
 			if (keep_base)
 				die(_("'%s': need exactly one merge base with branch"),
 				    options.upstream_name);
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index cd5c7a28eff..b5816624d25 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1347,7 +1347,7 @@ static int head_has_history(void)
 {
 	struct object_id oid;
 
-	return !get_oid("HEAD", &oid);
+	return !repo_get_oid(the_repository, "HEAD", &oid);
 }
 
 static const char *push_to_deploy(unsigned char *sha1,
@@ -1681,11 +1681,11 @@ static void check_aliased_update_internal(struct command *cmd,
 	rp_error("refusing inconsistent update between symref '%s' (%s..%s) and"
 		 " its target '%s' (%s..%s)",
 		 cmd->ref_name,
-		 find_unique_abbrev(&cmd->old_oid, DEFAULT_ABBREV),
-		 find_unique_abbrev(&cmd->new_oid, DEFAULT_ABBREV),
+		 repo_find_unique_abbrev(the_repository, &cmd->old_oid, DEFAULT_ABBREV),
+		 repo_find_unique_abbrev(the_repository, &cmd->new_oid, DEFAULT_ABBREV),
 		 dst_cmd->ref_name,
-		 find_unique_abbrev(&dst_cmd->old_oid, DEFAULT_ABBREV),
-		 find_unique_abbrev(&dst_cmd->new_oid, DEFAULT_ABBREV));
+		 repo_find_unique_abbrev(the_repository, &dst_cmd->old_oid, DEFAULT_ABBREV),
+		 repo_find_unique_abbrev(the_repository, &dst_cmd->new_oid, DEFAULT_ABBREV));
 
 	cmd->error_string = dst_cmd->error_string =
 		"inconsistent aliased update";
diff --git a/builtin/replace.c b/builtin/replace.c
index a29e911d309..33c6cdb79c8 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -54,7 +54,7 @@ static int show_reference(struct repository *r, const char *refname,
 			struct object_id object;
 			enum object_type obj_type, repl_type;
 
-			if (get_oid(refname, &object))
+			if (repo_get_oid(the_repository, refname, &object))
 				return error(_("failed to resolve '%s' as a valid ref"), refname);
 
 			obj_type = oid_object_info(r, &object, NULL);
@@ -112,7 +112,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)
 	base_len = ref.len;
 
 	for (p = argv; *p; p++) {
-		if (get_oid(*p, &oid)) {
+		if (repo_get_oid(the_repository, *p, &oid)) {
 			error("failed to resolve '%s' as a valid ref", *p);
 			had_error = 1;
 			continue;
@@ -206,10 +206,10 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
 {
 	struct object_id object, repl;
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		return error(_("failed to resolve '%s' as a valid ref"),
 			     object_ref);
-	if (get_oid(replace_ref, &repl))
+	if (repo_get_oid(the_repository, replace_ref, &repl))
 		return error(_("failed to resolve '%s' as a valid ref"),
 			     replace_ref);
 
@@ -320,7 +320,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
 	struct object_id old_oid, new_oid, prev;
 	struct strbuf ref = STRBUF_INIT;
 
-	if (get_oid(object_ref, &old_oid) < 0)
+	if (repo_get_oid(the_repository, object_ref, &old_oid) < 0)
 		return error(_("not a valid object name: '%s'"), object_ref);
 
 	type = oid_object_info(the_repository, &old_oid, NULL);
@@ -375,7 +375,7 @@ static int replace_parents(struct strbuf *buf, int argc, const char **argv)
 		struct object_id oid;
 		struct commit *commit;
 
-		if (get_oid(argv[i], &oid) < 0) {
+		if (repo_get_oid(the_repository, argv[i], &oid) < 0) {
 			strbuf_release(&new_parents);
 			return error(_("not a valid object name: '%s'"),
 				     argv[i]);
@@ -422,7 +422,7 @@ static int check_one_mergetag(struct commit *commit,
 	/* iterate over new parents */
 	for (i = 1; i < mergetag_data->argc; i++) {
 		struct object_id oid;
-		if (get_oid(mergetag_data->argv[i], &oid) < 0)
+		if (repo_get_oid(the_repository, mergetag_data->argv[i], &oid) < 0)
 			return error(_("not a valid object name: '%s'"),
 				     mergetag_data->argv[i]);
 		if (oideq(get_tagged_oid(tag), &oid))
@@ -452,7 +452,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
 	const char *buffer;
 	unsigned long size;
 
-	if (get_oid(old_ref, &old_oid) < 0)
+	if (repo_get_oid(the_repository, old_ref, &old_oid) < 0)
 		return error(_("not a valid object name: '%s'"), old_ref);
 	commit = lookup_commit_reference(the_repository, &old_oid);
 	if (!commit)
diff --git a/builtin/reset.c b/builtin/reset.c
index 0697fa89de2..75b447ffdc6 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -89,7 +89,7 @@ static int reset_index(const char *ref, const struct object_id *oid, int reset_t
 
 	if (reset_type == KEEP) {
 		struct object_id head_oid;
-		if (get_oid("HEAD", &head_oid))
+		if (repo_get_oid(the_repository, "HEAD", &head_oid))
 			return error(_("You do not have a valid HEAD."));
 		if (!fill_tree_descriptor(the_repository, desc + nr, &head_oid))
 			return error(_("Failed to find tree of HEAD."));
@@ -124,7 +124,7 @@ static void print_new_head_line(struct commit *commit)
 	struct strbuf buf = STRBUF_INIT;
 
 	printf(_("HEAD is now at %s"),
-		find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
+		repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
 
 	pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
 	if (buf.len > 0)
@@ -260,8 +260,8 @@ static void parse_args(struct pathspec *pathspec,
 		 * has to be unambiguous. If there is a single argument, it
 		 * can not be a tree
 		 */
-		else if ((!argv[1] && !get_oid_committish(argv[0], &unused)) ||
-			 (argv[1] && !get_oid_treeish(argv[0], &unused))) {
+		else if ((!argv[1] && !repo_get_oid_committish(the_repository, argv[0], &unused)) ||
+			 (argv[1] && !repo_get_oid_treeish(the_repository, argv[0], &unused))) {
 			/*
 			 * Ok, argv[0] looks like a commit/tree; it should not
 			 * be a filename.
@@ -288,9 +288,9 @@ static int reset_refs(const char *rev, const struct object_id *oid)
 	struct object_id *orig = NULL, oid_orig,
 		*old_orig = NULL, oid_old_orig;
 
-	if (!get_oid("ORIG_HEAD", &oid_old_orig))
+	if (!repo_get_oid(the_repository, "ORIG_HEAD", &oid_old_orig))
 		old_orig = &oid_old_orig;
-	if (!get_oid("HEAD", &oid_orig)) {
+	if (!repo_get_oid(the_repository, "HEAD", &oid_orig)) {
 		orig = &oid_orig;
 		set_reflog_message(&msg, "updating ORIG_HEAD", NULL);
 		update_ref(msg.buf, "ORIG_HEAD", orig, old_orig, 0,
@@ -365,13 +365,14 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 		die(_("the option '%s' requires '%s'"), "--pathspec-file-nul", "--pathspec-from-file");
 	}
 
-	unborn = !strcmp(rev, "HEAD") && get_oid("HEAD", &oid);
+	unborn = !strcmp(rev, "HEAD") && repo_get_oid(the_repository, "HEAD",
+						      &oid);
 	if (unborn) {
 		/* reset on unborn branch: treat as reset to empty tree */
 		oidcpy(&oid, the_hash_algo->empty_tree);
 	} else if (!pathspec.nr && !patch_mode) {
 		struct commit *commit;
-		if (get_oid_committish(rev, &oid))
+		if (repo_get_oid_committish(the_repository, rev, &oid))
 			die(_("Failed to resolve '%s' as a valid revision."), rev);
 		commit = lookup_commit_reference(the_repository, &oid);
 		if (!commit)
@@ -379,7 +380,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 		oidcpy(&oid, &commit->object.oid);
 	} else {
 		struct tree *tree;
-		if (get_oid_treeish(rev, &oid))
+		if (repo_get_oid_treeish(the_repository, rev, &oid))
 			die(_("Failed to resolve '%s' as a valid tree."), rev);
 		tree = parse_tree_indirect(&oid);
 		if (!tree)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index d42db0b0cc9..0f55eae22eb 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -134,7 +134,7 @@ static void show_commit(struct commit *commit, void *data)
 		if (!revs->graph)
 			fputs(get_revision_mark(revs, commit), stdout);
 		if (revs->abbrev_commit && revs->abbrev)
-			fputs(find_unique_abbrev(&commit->object.oid, revs->abbrev),
+			fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, revs->abbrev),
 			      stdout);
 		else
 			fputs(oid_to_hex(&commit->object.oid), stdout);
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index e67999e5ebc..eb53a303de6 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -162,7 +162,8 @@ static void show_rev(int type, const struct object_id *oid, const char *name)
 		}
 	}
 	else if (abbrev)
-		show_with_type(type, find_unique_abbrev(oid, abbrev));
+		show_with_type(type,
+			       repo_find_unique_abbrev(the_repository, oid, abbrev));
 	else
 		show_with_type(type, oid_to_hex(oid));
 }
@@ -187,7 +188,7 @@ static int show_default(void)
 		struct object_id oid;
 
 		def = NULL;
-		if (!get_oid(s, &oid)) {
+		if (!repo_get_oid(the_repository, s, &oid)) {
 			show_rev(NORMAL, &oid, s);
 			return 1;
 		}
@@ -279,7 +280,7 @@ static int try_difference(const char *arg)
 		return 0;
 	}
 
-	if (!get_oid_committish(start, &start_oid) && !get_oid_committish(end, &end_oid)) {
+	if (!repo_get_oid_committish(the_repository, start, &start_oid) && !repo_get_oid_committish(the_repository, end, &end_oid)) {
 		show_rev(NORMAL, &end_oid, end);
 		show_rev(symmetric ? NORMAL : REVERSED, &start_oid, start);
 		if (symmetric) {
@@ -337,7 +338,7 @@ static int try_parent_shorthands(const char *arg)
 		return 0;
 
 	*dotdot = 0;
-	if (get_oid_committish(arg, &oid) ||
+	if (repo_get_oid_committish(the_repository, arg, &oid) ||
 	    !(commit = lookup_commit_reference(the_repository, &oid))) {
 		*dotdot = '^';
 		return 0;
@@ -868,7 +869,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 				continue;
 			}
 			if (skip_prefix(arg, "--disambiguate=", &arg)) {
-				for_each_abbrev(arg, show_abbrev, NULL);
+				repo_for_each_abbrev(the_repository, arg,
+						     show_abbrev, NULL);
 				continue;
 			}
 			if (!strcmp(arg, "--bisect")) {
diff --git a/builtin/rm.c b/builtin/rm.c
index 8844f906557..25130f1b19e 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -370,7 +370,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 	 */
 	if (!force) {
 		struct object_id oid;
-		if (get_oid("HEAD", &oid))
+		if (repo_get_oid(the_repository, "HEAD", &oid))
 			oidclr(&oid);
 		if (check_local_mod(&oid, index_only))
 			exit(1);
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 358ac3e519a..9e3b8ed27e1 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -312,8 +312,8 @@ static void show_one_commit(struct commit *commit, int no_name)
 		}
 		else
 			printf("[%s] ",
-			       find_unique_abbrev(&commit->object.oid,
-						  DEFAULT_ABBREV));
+			       repo_find_unique_abbrev(the_repository, &commit->object.oid,
+						       DEFAULT_ABBREV));
 	}
 	puts(pretty_str);
 	strbuf_release(&pretty);
@@ -414,7 +414,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
 	/* If both heads/foo and tags/foo exists, get_sha1 would
 	 * get confused.
 	 */
-	if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
+	if (repo_get_oid(the_repository, refname + ofs, &tmp) || !oideq(&tmp, oid))
 		ofs = 5;
 	return append_ref(refname + ofs, oid, 0);
 }
@@ -429,7 +429,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,
 	/* If both heads/foo and tags/foo exists, get_sha1 would
 	 * get confused.
 	 */
-	if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
+	if (repo_get_oid(the_repository, refname + ofs, &tmp) || !oideq(&tmp, oid))
 		ofs = 5;
 	return append_ref(refname + ofs, oid, 0);
 }
@@ -533,7 +533,7 @@ static int show_independent(struct commit **rev,
 static void append_one_rev(const char *av)
 {
 	struct object_id revkey;
-	if (!get_oid(av, &revkey)) {
+	if (!repo_get_oid(the_repository, av, &revkey)) {
 		append_ref(av, &revkey, 0);
 		return;
 	}
@@ -836,7 +836,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 			die(Q_("cannot handle more than %d rev.",
 			       "cannot handle more than %d revs.",
 			       MAX_REVS), MAX_REVS);
-		if (get_oid(ref_name[num_rev], &revkey))
+		if (repo_get_oid(the_repository, ref_name[num_rev], &revkey))
 			die(_("'%s' is not a valid ref."), ref_name[num_rev]);
 		commit = lookup_commit_reference(the_repository, &revkey);
 		if (!commit)
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 3af6a53ee97..eb3ad1688ba 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -33,7 +33,7 @@ static void show_one(const char *refname, const struct object_id *oid)
 	if (quiet)
 		return;
 
-	hex = find_unique_abbrev(oid, abbrev);
+	hex = repo_find_unique_abbrev(the_repository, oid, abbrev);
 	if (hash_only)
 		printf("%s\n", hex);
 	else
@@ -43,7 +43,7 @@ static void show_one(const char *refname, const struct object_id *oid)
 		return;
 
 	if (!peel_iterated_oid(oid, &peeled)) {
-		hex = find_unique_abbrev(&peeled, abbrev);
+		hex = repo_find_unique_abbrev(the_repository, &peeled, abbrev);
 		printf("%s %s^{}\n", hex, refname);
 	}
 }
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index c3738154918..c5c8b7b89c7 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -471,7 +471,7 @@ static int sparse_checkout_init(int argc, const char **argv, const char *prefix)
 		return update_working_directory(NULL);
 	}
 
-	if (get_oid("HEAD", &oid)) {
+	if (repo_get_oid(the_repository, "HEAD", &oid)) {
 		FILE *fp;
 
 		/* assume we are in a fresh repo, but update the sparse-checkout file */
diff --git a/builtin/stash.c b/builtin/stash.c
index 3a4f9fd566d..ed1275829e7 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -201,7 +201,7 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
 
 	revision = info->revision.buf;
 
-	if (get_oid(revision, &info->w_commit))
+	if (repo_get_oid(the_repository, revision, &info->w_commit))
 		return error(_("%s is not a valid reference"), revision);
 
 	assert_stash_like(info, revision);
@@ -231,7 +231,7 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
 static int do_clear_stash(void)
 {
 	struct object_id obj;
-	if (get_oid(ref_stash, &obj))
+	if (repo_get_oid(the_repository, ref_stash, &obj))
 		return 0;
 
 	return delete_ref(NULL, ref_stash, &obj, 0);
@@ -1083,7 +1083,7 @@ static int check_changes_tracked_files(const struct pathspec *ps)
 	int ret = 0;
 
 	/* No initial commit. */
-	if (get_oid("HEAD", &dummy))
+	if (repo_get_oid(the_repository, "HEAD", &dummy))
 		return -1;
 
 	if (repo_read_index(the_repository) < 0)
@@ -1355,7 +1355,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
 		goto done;
 	}
 
-	if (get_oid("HEAD", &info->b_commit)) {
+	if (repo_get_oid(the_repository, "HEAD", &info->b_commit)) {
 		if (!quiet)
 			fprintf_ln(stderr, _("You do not have "
 					     "the initial commit yet"));
@@ -1373,8 +1373,9 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
 	branch_ref = resolve_ref_unsafe("HEAD", 0, NULL, &flags);
 	if (flags & REF_ISSYMREF)
 		skip_prefix(branch_ref, "refs/heads/", &branch_name);
-	head_short_sha1 = find_unique_abbrev(&head_commit->object.oid,
-					     DEFAULT_ABBREV);
+	head_short_sha1 = repo_find_unique_abbrev(the_repository,
+						  &head_commit->object.oid,
+						  DEFAULT_ABBREV);
 	strbuf_addf(&msg, "%s: %s ", branch_name, head_short_sha1);
 	pp_commit_easy(CMIT_FMT_ONELINE, head_commit, &msg);
 
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 4c173d8b37a..25c70f415f1 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1174,7 +1174,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
 	if (!summary_limit)
 		return 0;
 
-	if (!get_oid(argc ? argv[0] : "HEAD", &head_oid)) {
+	if (!repo_get_oid(the_repository, argc ? argv[0] : "HEAD", &head_oid)) {
 		if (argc) {
 			argv++;
 			argc--;
@@ -1187,7 +1187,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
 			argc--;
 		}
 	} else {
-		if (get_oid("HEAD", &head_oid))
+		if (repo_get_oid(the_repository, "HEAD", &head_oid))
 			die(_("could not fetch a revision for HEAD"));
 	}
 
diff --git a/builtin/tag.c b/builtin/tag.c
index d428c45dc8d..e6cbf6e5a8d 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -137,7 +137,7 @@ static int delete_tags(const char **argv)
 		if (!ref_exists(name))
 			printf(_("Deleted tag '%s' (was %s)\n"),
 				item->string + 10,
-				find_unique_abbrev(oid, DEFAULT_ABBREV));
+				repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
 
 		free(oid);
 	}
@@ -593,7 +593,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 	if (argc > 2)
 		die(_("too many arguments"));
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
 	if (strbuf_check_tag_ref(&ref, tag))
@@ -634,7 +634,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 	ref_transaction_free(transaction);
 	if (force && !is_null_oid(&prev) && !oideq(&prev, &object))
 		printf(_("Updated tag '%s' (was %s)\n"), tag,
-		       find_unique_abbrev(&prev, DEFAULT_ABBREV));
+		       repo_find_unique_abbrev(the_repository, &prev, DEFAULT_ABBREV));
 
 cleanup:
 	ref_sorting_release(sorting);
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index 88de32b7d7e..e0d5178acc5 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -29,7 +29,7 @@ int cmd_unpack_file(int argc, const char **argv, const char *prefix)
 
 	if (argc != 2 || !strcmp(argv[1], "-h"))
 		usage("git unpack-file <blob>");
-	if (get_oid(argv[1], &oid))
+	if (repo_get_oid(the_repository, argv[1], &oid))
 		die("Not a valid object name %s", argv[1]);
 
 	git_config(git_default_config, NULL);
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index a84e7b47a20..1ba0727ba77 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -116,7 +116,7 @@ static int parse_next_oid(const char **next, const char *end,
 		(*next)++;
 		*next = parse_arg(*next, &arg);
 		if (arg.len) {
-			if (get_oid(arg.buf, oid))
+			if (repo_get_oid(the_repository, arg.buf, oid))
 				goto invalid;
 		} else {
 			/* Without -z, an empty value means all zeros: */
@@ -134,7 +134,7 @@ static int parse_next_oid(const char **next, const char *end,
 		*next += arg.len;
 
 		if (arg.len) {
-			if (get_oid(arg.buf, oid))
+			if (repo_get_oid(the_repository, arg.buf, oid))
 				goto invalid;
 		} else if (flags & PARSE_SHA1_ALLOW_EMPTY) {
 			/* With -z, treat an empty value as all zeros: */
@@ -549,7 +549,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
 		refname = argv[0];
 		value = argv[1];
 		oldval = argv[2];
-		if (get_oid(value, &oid))
+		if (repo_get_oid(the_repository, value, &oid))
 			die("%s: not a valid SHA1", value);
 	}
 
@@ -560,7 +560,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
 			 * must not already exist:
 			 */
 			oidclr(&oldoid);
-		else if (get_oid(oldval, &oldoid))
+		else if (repo_get_oid(the_repository, oldval, &oldoid))
 			die("%s: not a valid old SHA1", oldval);
 	}
 
diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c
index 3ebad32b0f1..424b43083cb 100644
--- a/builtin/verify-commit.c
+++ b/builtin/verify-commit.c
@@ -39,7 +39,7 @@ static int verify_commit(const char *name, unsigned flags)
 	struct object_id oid;
 	struct object *obj;
 
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return error("commit '%s' not found.", name);
 
 	obj = parse_object(the_repository, &oid);
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 217566952d8..050fd292515 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -60,7 +60,7 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)
 		struct object_id oid;
 		const char *name = argv[i++];
 
-		if (get_oid(name, &oid)) {
+		if (repo_get_oid(the_repository, name, &oid)) {
 			had_error = !!error("tag '%s' not found.", name);
 			continue;
 		}
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 254283aa6f5..16fa30f01c8 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -552,7 +552,7 @@ static void print_preparing_worktree_line(int detach,
 		else
 			fprintf_ln(stderr, _("Preparing worktree (resetting branch '%s'; was at %s)"),
 				  new_branch,
-				  find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
+				  repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
 	} else if (new_branch) {
 		fprintf_ln(stderr, _("Preparing worktree (new branch '%s')"), new_branch);
 	} else {
@@ -566,7 +566,7 @@ static void print_preparing_worktree_line(int detach,
 			if (!commit)
 				die(_("invalid reference: %s"), branch);
 			fprintf_ln(stderr, _("Preparing worktree (detached HEAD %s)"),
-				  find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
+				  repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
 		}
 		strbuf_release(&s);
 	}
@@ -756,7 +756,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)
 		strbuf_addstr(&sb, "(bare)");
 	else {
 		strbuf_addf(&sb, "%-*s ", abbrev_len,
-				find_unique_abbrev(&wt->head_oid, DEFAULT_ABBREV));
+				repo_find_unique_abbrev(the_repository, &wt->head_oid, DEFAULT_ABBREV));
 		if (wt->is_detached)
 			strbuf_addstr(&sb, "(detached HEAD)");
 		else if (wt->head_ref) {
@@ -793,7 +793,7 @@ static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)
 
 		if (path_len > *maxlen)
 			*maxlen = path_len;
-		sha1_len = strlen(find_unique_abbrev(&wt[i]->head_oid, *abbrev));
+		sha1_len = strlen(repo_find_unique_abbrev(the_repository, &wt[i]->head_oid, *abbrev));
 		if (sha1_len > *abbrev)
 			*abbrev = sha1_len;
 	}
diff --git a/cache.h b/cache.h
index 12789903e88..d835ac8b4d2 100644
--- a/cache.h
+++ b/cache.h
@@ -1211,9 +1211,7 @@ void check_repository_format(struct repository_format *fmt);
  * reentrant, as it calls into other non-reentrant git code.
  */
 const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
-#define find_unique_abbrev(oid, len) repo_find_unique_abbrev(the_repository, oid, len)
 int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
-#define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
 
 /* set default permissions by passing mode arguments to open(2) */
 int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
@@ -1488,17 +1486,8 @@ enum get_oid_result get_oid_with_context(struct repository *repo, const char *st
 					 unsigned flags, struct object_id *oid,
 					 struct object_context *oc);
 
-#define get_oid(str, oid)		repo_get_oid(the_repository, str, oid)
-#define get_oid_commit(str, oid)	repo_get_oid_commit(the_repository, str, oid)
-#define get_oid_committish(str, oid)	repo_get_oid_committish(the_repository, str, oid)
-#define get_oid_tree(str, oid)		repo_get_oid_tree(the_repository, str, oid)
-#define get_oid_treeish(str, oid)	repo_get_oid_treeish(the_repository, str, oid)
-#define get_oid_blob(str, oid)		repo_get_oid_blob(the_repository, str, oid)
-#define get_oid_mb(str, oid) 		repo_get_oid_mb(the_repository, str, oid)
-
 typedef int each_abbrev_fn(const struct object_id *oid, void *);
 int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
-#define for_each_abbrev(prefix, fn, data) repo_for_each_abbrev(the_repository, prefix, fn, data)
 
 int set_disambiguate_hint_config(const char *var, const char *value);
 
@@ -1608,8 +1597,6 @@ int repo_interpret_branch_name(struct repository *r,
 			       const char *str, int len,
 			       struct strbuf *buf,
 			       const struct interpret_branch_name_options *options);
-#define interpret_branch_name(str, len, buf, options) \
-	repo_interpret_branch_name(the_repository, str, len, buf, options)
 
 int validate_headref(const char *ref);
 
@@ -1629,8 +1616,6 @@ void *read_object_with_reference(struct repository *r,
 struct object *repo_peel_to_type(struct repository *r,
 				 const char *name, int namelen,
 				 struct object *o, enum object_type);
-#define peel_to_type(name, namelen, obj, type) \
-	repo_peel_to_type(the_repository, name, namelen, obj, type)
 
 #define IDENT_STRICT	       1
 #define IDENT_NO_DATE	       2
diff --git a/checkout.c b/checkout.c
index 2e39dae684f..1247b882248 100644
--- a/checkout.c
+++ b/checkout.c
@@ -23,7 +23,7 @@ static int check_tracking_name(struct remote *remote, void *cb_data)
 	memset(&query, 0, sizeof(struct refspec_item));
 	query.src = cb->src_ref;
 	if (remote_find_tracking(remote, &query) ||
-	    get_oid(query.dst, cb->dst_oid)) {
+	    repo_get_oid(the_repository, query.dst, cb->dst_oid)) {
 		free(query.dst);
 		return 0;
 	}
diff --git a/combine-diff.c b/combine-diff.c
index 1a39b5dde09..d84ab878b72 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -948,11 +948,11 @@ static void show_combined_header(struct combine_diff_path *elem,
 			 "", elem->path, line_prefix, c_meta, c_reset);
 	printf("%s%sindex ", line_prefix, c_meta);
 	for (i = 0; i < num_parent; i++) {
-		abb = find_unique_abbrev(&elem->parent[i].oid,
-					 abbrev);
+		abb = repo_find_unique_abbrev(the_repository,
+					      &elem->parent[i].oid, abbrev);
 		printf("%s%s", i ? "," : "", abb);
 	}
-	abb = find_unique_abbrev(&elem->oid, abbrev);
+	abb = repo_find_unique_abbrev(the_repository, &elem->oid, abbrev);
 	printf("..%s%s\n", abb, c_reset);
 
 	if (mode_differs) {
diff --git a/commit.c b/commit.c
index e433c33bb01..06a7c728e80 100644
--- a/commit.c
+++ b/commit.c
@@ -80,7 +80,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
 	struct object_id oid;
 	struct commit *commit;
 
-	if (get_oid_committish(name, &oid))
+	if (repo_get_oid_committish(the_repository, name, &oid))
 		return NULL;
 	commit = lookup_commit_reference(the_repository, &oid);
 	if (parse_commit(commit))
@@ -1271,7 +1271,8 @@ void verify_merge_signature(struct commit *commit, int verbosity,
 
 	ret = check_commit_signature(commit, &signature_check);
 
-	find_unique_abbrev_r(hex, &commit->object.oid, DEFAULT_ABBREV);
+	repo_find_unique_abbrev_r(the_repository, hex, &commit->object.oid,
+				  DEFAULT_ABBREV);
 	switch (signature_check.result) {
 	case 'G':
 		if (ret || (check_trust && signature_check.trust_level < TRUST_MARGINAL))
@@ -1632,10 +1633,11 @@ struct commit *get_merge_parent(const char *name)
 	struct object *obj;
 	struct commit *commit;
 	struct object_id oid;
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return NULL;
 	obj = parse_object(the_repository, &oid);
-	commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
+	commit = (struct commit *)repo_peel_to_type(the_repository, name, 0,
+						    obj, OBJ_COMMIT);
 	if (commit && !merge_remote_util(commit))
 		set_merge_remote_desc(commit, name, obj);
 	return commit;
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
new file mode 100644
index 00000000000..dcdba314fc2
--- /dev/null
+++ b/contrib/coccinelle/the_repository.cocci
@@ -0,0 +1,44 @@
+// Fully migrated "the_repository" additions
+@@
+@@
+(
+// cache.h
+- get_oid
++ repo_get_oid
+|
+- get_oid_commit
++ repo_get_oid_commit
+|
+- get_oid_committish
++ repo_get_oid_committish
+|
+- get_oid_tree
++ repo_get_oid_tree
+|
+- get_oid_treeish
++ repo_get_oid_treeish
+|
+- get_oid_blob
++ repo_get_oid_blob
+|
+- get_oid_mb
++ repo_get_oid_mb
+|
+- find_unique_abbrev
++ repo_find_unique_abbrev
+|
+- find_unique_abbrev_r
++ repo_find_unique_abbrev_r
+|
+- for_each_abbrev
++ repo_for_each_abbrev
+|
+- interpret_branch_name
++ repo_interpret_branch_name
+|
+- peel_to_type
++ repo_peel_to_type
+)
+  (
++ the_repository,
+  ...)
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 8b3f2580e6b..2d200ab83e7 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,44 +5,7 @@
 @@
 @@
 (
-// cache.h
-- get_oid
-+ repo_get_oid
-|
-- get_oid_commit
-+ repo_get_oid_commit
-|
-- get_oid_committish
-+ repo_get_oid_committish
-|
-- get_oid_tree
-+ repo_get_oid_tree
-|
-- get_oid_treeish
-+ repo_get_oid_treeish
-|
-- get_oid_blob
-+ repo_get_oid_blob
-|
-- get_oid_mb
-+ repo_get_oid_mb
-|
-- find_unique_abbrev
-+ repo_find_unique_abbrev
-|
-- find_unique_abbrev_r
-+ repo_find_unique_abbrev_r
-|
-- for_each_abbrev
-+ repo_for_each_abbrev
-|
-- interpret_branch_name
-+ repo_interpret_branch_name
-|
-- peel_to_type
-+ repo_peel_to_type
 // commit-reach.h
-|
 - get_merge_bases
 + repo_get_merge_bases
 |
diff --git a/diff-lib.c b/diff-lib.c
index dec040c366c..24470b21612 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -581,7 +581,7 @@ void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb)
 	if (revs->pending.nr == 1) {
 		struct object_id oid;
 
-		if (get_oid("HEAD", &oid))
+		if (repo_get_oid(the_repository, "HEAD", &oid))
 			die(_("unable to get HEAD"));
 
 		mb_child[1] = lookup_commit_reference(the_repository, &oid);
diff --git a/diff.c b/diff.c
index 469e18aed20..3abeca9d46c 100644
--- a/diff.c
+++ b/diff.c
@@ -4351,7 +4351,7 @@ static int similarity_index(struct diff_filepair *p)
 static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)
 {
 	if (startup_info->have_repository)
-		return find_unique_abbrev(oid, abbrev);
+		return repo_find_unique_abbrev(the_repository, oid, abbrev);
 	else {
 		char *hex = oid_to_hex(oid);
 		if (abbrev < 0)
@@ -4988,7 +4988,7 @@ static int diff_opt_find_object(const struct option *option,
 	struct object_id oid;
 
 	BUG_ON_OPT_NEG(unset);
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		return error(_("unable to resolve '%s'"), arg);
 
 	if (!opt->objfind)
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index f48f44f9cd1..e8e2d4ea0d0 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -605,7 +605,9 @@ static void find_merge_parents(struct merge_parents *result,
 		 * util field yet.
 		 */
 		obj = parse_object(the_repository, &oid);
-		parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);
+		parent = (struct commit *)repo_peel_to_type(the_repository,
+							    NULL, 0, obj,
+							    OBJ_COMMIT);
 		if (!parent)
 			continue;
 		commit_list_insert(parent, &parents);
diff --git a/log-tree.c b/log-tree.c
index 1dd5fcbf7be..f36adb947e8 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -233,7 +233,8 @@ static void show_parents(struct commit *commit, int abbrev, FILE *file)
 	struct commit_list *p;
 	for (p = commit->parents; p ; p = p->next) {
 		struct commit *parent = p->item;
-		fprintf(file, " %s", find_unique_abbrev(&parent->object.oid, abbrev));
+		fprintf(file, " %s",
+			repo_find_unique_abbrev(the_repository, &parent->object.oid, abbrev));
 	}
 }
 
@@ -241,7 +242,8 @@ static void show_children(struct rev_info *opt, struct commit *commit, int abbre
 {
 	struct commit_list *p = lookup_decoration(&opt->children, &commit->object);
 	for ( ; p; p = p->next) {
-		fprintf(opt->diffopt.file, " %s", find_unique_abbrev(&p->item->object.oid, abbrev));
+		fprintf(opt->diffopt.file, " %s",
+			repo_find_unique_abbrev(the_repository, &p->item->object.oid, abbrev));
 	}
 }
 
@@ -644,7 +646,8 @@ void show_log(struct rev_info *opt)
 
 		if (!opt->graph)
 			put_revision_mark(opt, commit);
-		fputs(find_unique_abbrev(&commit->object.oid, abbrev_commit), opt->diffopt.file);
+		fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev_commit),
+		      opt->diffopt.file);
 		if (opt->print_parents)
 			show_parents(commit, abbrev_commit, opt->diffopt.file);
 		if (opt->children.name)
@@ -706,8 +709,8 @@ void show_log(struct rev_info *opt)
 
 		if (!opt->graph)
 			put_revision_mark(opt, commit);
-		fputs(find_unique_abbrev(&commit->object.oid,
-					 abbrev_commit),
+		fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid,
+					      abbrev_commit),
 		      opt->diffopt.file);
 		if (opt->print_parents)
 			show_parents(commit, abbrev_commit, opt->diffopt.file);
@@ -715,7 +718,7 @@ void show_log(struct rev_info *opt)
 			show_children(opt, commit, abbrev_commit);
 		if (parent)
 			fprintf(opt->diffopt.file, " (from %s)",
-			       find_unique_abbrev(&parent->object.oid, abbrev_commit));
+			       repo_find_unique_abbrev(the_repository, &parent->object.oid, abbrev_commit));
 		fputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file);
 		show_decorations(opt, commit);
 		if (opt->commit_format == CMIT_FMT_ONELINE) {
diff --git a/mailmap.c b/mailmap.c
index da2589b0822..ed8289aea58 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -213,7 +213,7 @@ static int read_mailmap_blob(struct string_list *map, const char *name)
 
 	if (!name)
 		return 0;
-	if (get_oid(name, &oid) < 0)
+	if (repo_get_oid(the_repository, name, &oid) < 0)
 		return 0;
 
 	buf = read_object_file(&oid, &type, &size);
diff --git a/notes-merge.c b/notes-merge.c
index b4cc594a790..d290c7478e2 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -566,7 +566,7 @@ int notes_merge(struct notes_merge_options *o,
 	trace_printf("\tlocal commit: %.7s\n", oid_to_hex(&local_oid));
 
 	/* Dereference o->remote_ref into remote_oid */
-	if (get_oid(o->remote_ref, &remote_oid)) {
+	if (repo_get_oid(the_repository, o->remote_ref, &remote_oid)) {
 		/*
 		 * Failed to get remote_oid. If o->remote_ref looks like an
 		 * unborn ref, perform the merge using an empty notes tree.
diff --git a/notes.c b/notes.c
index f2805d51bb1..750e18c4004 100644
--- a/notes.c
+++ b/notes.c
@@ -944,7 +944,7 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
 		for_each_glob_ref(string_list_add_one_ref, glob, list);
 	} else {
 		struct object_id oid;
-		if (get_oid(glob, &oid))
+		if (repo_get_oid(the_repository, glob, &oid))
 			warning("notes ref %s is invalid", glob);
 		if (!unsorted_string_list_has_string(list, glob))
 			string_list_append(list, glob);
@@ -1021,7 +1021,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
 	t->dirty = 0;
 
 	if (flags & NOTES_INIT_EMPTY || !notes_ref ||
-	    get_oid_treeish(notes_ref, &object_oid))
+	    repo_get_oid_treeish(the_repository, notes_ref, &object_oid))
 		return;
 	if (flags & NOTES_INIT_WRITABLE && read_ref(notes_ref, &object_oid))
 		die("Cannot use notes ref %s", notes_ref);
@@ -1348,7 +1348,7 @@ void expand_loose_notes_ref(struct strbuf *sb)
 {
 	struct object_id object;
 
-	if (get_oid(sb->buf, &object)) {
+	if (repo_get_oid(the_repository, sb->buf, &object)) {
 		/* fallback to expand_notes_ref */
 		expand_notes_ref(sb);
 	}
diff --git a/object-name.c b/object-name.c
index 2dd1a0f56e1..21e8f67489e 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1666,7 +1666,8 @@ void strbuf_branchname(struct strbuf *sb, const char *name, unsigned allowed)
 	struct interpret_branch_name_options options = {
 		.allowed = allowed
 	};
-	int used = interpret_branch_name(name, len, sb, &options);
+	int used = repo_interpret_branch_name(the_repository, name, len, sb,
+					      &options);
 
 	if (used < 0)
 		used = 0;
@@ -1719,7 +1720,7 @@ int get_oidf(struct object_id *oid, const char *fmt, ...)
 	strbuf_vaddf(&sb, fmt, ap);
 	va_end(ap);
 
-	ret = get_oid(sb.buf, oid);
+	ret = repo_get_oid(the_repository, sb.buf, oid);
 	strbuf_release(&sb);
 
 	return ret;
diff --git a/parse-options-cb.c b/parse-options-cb.c
index d346dbe2100..0f7b40d0c08 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -91,7 +91,7 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset)
 
 	if (!arg)
 		return -1;
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		return error("malformed object name %s", arg);
 	commit = lookup_commit_reference(the_repository, &oid);
 	if (!commit)
@@ -110,7 +110,7 @@ int parse_opt_commit(const struct option *opt, const char *arg, int unset)
 
 	if (!arg)
 		return -1;
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		return error("malformed object name %s", arg);
 	commit = lookup_commit_reference(the_repository, &oid);
 	if (!commit)
@@ -129,7 +129,7 @@ int parse_opt_object_name(const struct option *opt, const char *arg, int unset)
 	}
 	if (!arg)
 		return -1;
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		return error(_("malformed object name '%s'"), arg);
 	oid_array_append(opt->value, &oid);
 	return 0;
@@ -146,7 +146,7 @@ int parse_opt_object_id(const struct option *opt, const char *arg, int unset)
 	}
 	if (!arg)
 		return -1;
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		return error(_("malformed object name '%s'"), arg);
 	*target = oid;
 	return 0;
diff --git a/range-diff.c b/range-diff.c
index 4bd65ab7496..5bcf966f6c5 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -94,7 +94,7 @@ static int read_patches(const char *range, struct string_list *list,
 				strbuf_reset(&buf);
 			}
 			CALLOC_ARRAY(util, 1);
-			if (get_oid(p, &util->oid)) {
+			if (repo_get_oid(the_repository, p, &util->oid)) {
 				error(_("could not parse commit '%s'"), p);
 				FREE_AND_NULL(util);
 				string_list_clear(list, 1);
@@ -390,7 +390,7 @@ static void output_pair_header(struct diff_options *diffopt,
 
 	if (!dashes->len)
 		strbuf_addchars(dashes, '-',
-				strlen(find_unique_abbrev(oid, abbrev)));
+				strlen(repo_find_unique_abbrev(the_repository, oid, abbrev)));
 
 	if (!b_util) {
 		color = color_old;
@@ -412,7 +412,7 @@ static void output_pair_header(struct diff_options *diffopt,
 		strbuf_addf(buf, "%*s:  %s ", patch_no_width, "-", dashes->buf);
 	else
 		strbuf_addf(buf, "%*d:  %s ", patch_no_width, a_util->i + 1,
-			    find_unique_abbrev(&a_util->oid, abbrev));
+			    repo_find_unique_abbrev(the_repository, &a_util->oid, abbrev));
 
 	if (status == '!')
 		strbuf_addf(buf, "%s%s", color_reset, color);
@@ -424,7 +424,7 @@ static void output_pair_header(struct diff_options *diffopt,
 		strbuf_addf(buf, " %*s:  %s", patch_no_width, "-", dashes->buf);
 	else
 		strbuf_addf(buf, " %*d:  %s", patch_no_width, b_util->i + 1,
-			    find_unique_abbrev(&b_util->oid, abbrev));
+			    repo_find_unique_abbrev(the_repository, &b_util->oid, abbrev));
 
 	commit = lookup_commit_reference(the_repository, oid);
 	if (commit) {
diff --git a/read-cache.c b/read-cache.c
index 35e5657877c..d6c69164d0f 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2628,7 +2628,7 @@ int repo_index_has_changes(struct repository *repo,
 
 	if (tree)
 		cmp = tree->object.oid;
-	if (tree || !get_oid_tree("HEAD", &cmp)) {
+	if (tree || !repo_get_oid_tree(the_repository, "HEAD", &cmp)) {
 		struct diff_options opt;
 
 		repo_diff_setup(repo, &opt);
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 7407c593191..c151db0ad2f 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -187,7 +187,7 @@ int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo)
 		struct commit *commit = item->commit;
 		if (commit && !*commit_seen_at(&commit_seen, commit)) {
 			strbuf_addf(&missing, " - %s %.*s\n",
-				    find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV),
+				    repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
 				    item->arg_len,
 				    todo_item_get_arg(old_todo, item));
 			*commit_seen_at(&commit_seen, commit) = 1;
diff --git a/ref-filter.c b/ref-filter.c
index f8203c6b052..c6cd131e70b 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1075,9 +1075,11 @@ static const char *do_grab_oid(const char *field, const struct object_id *oid,
 	case O_FULL:
 		return oid_to_hex(oid);
 	case O_LENGTH:
-		return find_unique_abbrev(oid, atom->u.oid.length);
+		return repo_find_unique_abbrev(the_repository, oid,
+					       atom->u.oid.length);
 	case O_SHORT:
-		return find_unique_abbrev(oid, DEFAULT_ABBREV);
+		return repo_find_unique_abbrev(the_repository, oid,
+					       DEFAULT_ABBREV);
 	default:
 		BUG("unknown %%(%s) option", field);
 	}
@@ -2765,7 +2767,7 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
 
 	BUG_ON_OPT_NEG(unset);
 
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		die(_("malformed object name %s"), arg);
 
 	merge_commit = lookup_commit_reference_gently(the_repository, &oid, 0);
diff --git a/remote.c b/remote.c
index 60869beebe7..ff9b0238318 100644
--- a/remote.c
+++ b/remote.c
@@ -1163,7 +1163,7 @@ static int try_explicit_object_name(const char *name,
 		return 0;
 	}
 
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return -1;
 
 	if (match) {
@@ -1251,7 +1251,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,
 	if (!advice_enabled(ADVICE_PUSH_UNQUALIFIED_REF_NAME))
 		return;
 
-	if (get_oid(matched_src_name, &oid))
+	if (repo_get_oid(the_repository, matched_src_name, &oid))
 		BUG("'%s' is not a valid object, "
 		    "match_explicit_lhs() should catch this!",
 		    matched_src_name);
@@ -2505,7 +2505,7 @@ static int parse_push_cas_option(struct push_cas_option *cas, const char *arg, i
 		entry->use_tracking = 1;
 	else if (!colon[1])
 		oidclr(&entry->expect);
-	else if (get_oid(colon + 1, &entry->expect))
+	else if (repo_get_oid(the_repository, colon + 1, &entry->expect))
 		return error(_("cannot parse expected object name '%s'"),
 			     colon + 1);
 	return 0;
diff --git a/reset.c b/reset.c
index 5ded23611f3..3a9c6dfdd0a 100644
--- a/reset.c
+++ b/reset.c
@@ -38,7 +38,7 @@ static int update_refs(const struct reset_head_opts *opts,
 	prefix_len = msg.len;
 
 	if (update_orig_head) {
-		if (!get_oid("ORIG_HEAD", &oid_old_orig))
+		if (!repo_get_oid(the_repository, "ORIG_HEAD", &oid_old_orig))
 			old_orig = &oid_old_orig;
 		if (head) {
 			if (!reflog_orig_head) {
@@ -106,7 +106,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
 		goto leave_reset_head;
 	}
 
-	if (!get_oid("HEAD", &head_oid)) {
+	if (!repo_get_oid(the_repository, "HEAD", &head_oid)) {
 		head = &head_oid;
 	} else if (!oid || !reset_hard) {
 		ret = error(_("could not determine HEAD revision"));
diff --git a/revision.c b/revision.c
index 21f5f572c22..0f775ee2e90 100644
--- a/revision.c
+++ b/revision.c
@@ -324,7 +324,8 @@ static void add_pending_object_with_path(struct rev_info *revs,
 	if (revs->reflog_info && obj->type == OBJ_COMMIT) {
 		struct strbuf buf = STRBUF_INIT;
 		size_t namelen = strlen(name);
-		int len = interpret_branch_name(name, namelen, &buf, &options);
+		int len = repo_interpret_branch_name(the_repository, name,
+						     namelen, &buf, &options);
 
 		if (0 < len && len < namelen && buf.len)
 			strbuf_addstr(&buf, name + len);
@@ -354,7 +355,7 @@ void add_head_to_pending(struct rev_info *revs)
 {
 	struct object_id oid;
 	struct object *obj;
-	if (get_oid("HEAD", &oid))
+	if (repo_get_oid(the_repository, "HEAD", &oid))
 		return;
 	obj = parse_object(revs->repo, &oid);
 	if (!obj)
@@ -1867,7 +1868,7 @@ static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,
 		flags ^= UNINTERESTING | BOTTOM;
 		arg++;
 	}
-	if (get_oid_committish(arg, &oid))
+	if (repo_get_oid_committish(the_repository, arg, &oid))
 		return 0;
 	while (1) {
 		it = get_reference(revs, arg, &oid, 0);
@@ -1948,10 +1949,10 @@ static void prepare_show_merge(struct rev_info *revs)
 	int i, prune_num = 1; /* counting terminating NULL */
 	struct index_state *istate = revs->repo->index;
 
-	if (get_oid("HEAD", &oid))
+	if (repo_get_oid(the_repository, "HEAD", &oid))
 		die("--merge without HEAD?");
 	head = lookup_commit_or_die(&oid, "HEAD");
-	if (get_oid("MERGE_HEAD", &oid))
+	if (repo_get_oid(the_repository, "MERGE_HEAD", &oid))
 		die("--merge without MERGE_HEAD?");
 	other = lookup_commit_or_die(&oid, "MERGE_HEAD");
 	add_pending_object(revs, &head->object, "HEAD");
diff --git a/sequencer.c b/sequencer.c
index 1c96a75b1e9..818932a630a 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -419,7 +419,8 @@ struct commit_message {
 
 static const char *short_commit_name(struct commit *commit)
 {
-	return find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV);
+	return repo_find_unique_abbrev(the_repository, &commit->object.oid,
+				       DEFAULT_ABBREV);
 }
 
 static int get_message(struct commit *commit, struct commit_message *out)
@@ -561,7 +562,7 @@ static void update_abort_safety_file(void)
 	if (!file_exists(git_path_seq_dir()))
 		return;
 
-	if (!get_oid("HEAD", &head))
+	if (!repo_get_oid(the_repository, "HEAD", &head))
 		write_file(git_path_abort_safety_file(), "%s", oid_to_hex(&head));
 	else
 		write_file(git_path_abort_safety_file(), "%s", "");
@@ -1406,7 +1407,7 @@ static int parse_head(struct repository *r, struct commit **head)
 	struct commit *current_head;
 	struct object_id oid;
 
-	if (get_oid("HEAD", &oid)) {
+	if (repo_get_oid(the_repository, "HEAD", &oid)) {
 		current_head = NULL;
 	} else {
 		current_head = lookup_commit_reference(r, &oid);
@@ -1997,7 +1998,7 @@ static int update_squash_messages(struct repository *r,
 		struct commit *head_commit;
 		const char *head_message, *body;
 
-		if (get_oid("HEAD", &head))
+		if (repo_get_oid(the_repository, "HEAD", &head))
 			return error(_("need a HEAD to fixup"));
 		if (!(head_commit = lookup_commit_reference(r, &head)))
 			return error(_("could not read HEAD"));
@@ -2067,7 +2068,7 @@ static void flush_rewritten_pending(void)
 	FILE *out;
 
 	if (strbuf_read_file(&buf, rebase_path_rewritten_pending(), (GIT_MAX_HEXSZ + 1) * 2) > 0 &&
-	    !get_oid("HEAD", &newoid) &&
+	    !repo_get_oid(the_repository, "HEAD", &newoid) &&
 	    (out = fopen_or_warn(rebase_path_rewritten_list(), "a"))) {
 		char *bol = buf.buf, *eol;
 
@@ -2152,7 +2153,7 @@ static int do_pick_commit(struct repository *r,
 		if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL))
 			return error(_("your index file is unmerged."));
 	} else {
-		unborn = get_oid("HEAD", &head);
+		unborn = repo_get_oid(the_repository, "HEAD", &head);
 		/* Do we want to generate a root commit? */
 		if (is_pick_or_similar(command) && opts->have_squash_onto &&
 		    oideq(&head, &opts->squash_onto)) {
@@ -2606,7 +2607,7 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
 	end_of_object_name = (char *) bol + strcspn(bol, " \t\n");
 	saved = *end_of_object_name;
 	*end_of_object_name = '\0';
-	status = get_oid(bol, &commit_oid);
+	status = repo_get_oid(the_repository, bol, &commit_oid);
 	if (status < 0)
 		error(_("could not parse '%s'"), bol); /* return later */
 	*end_of_object_name = saved;
@@ -3022,7 +3023,7 @@ static int read_populate_opts(struct replay_opts *opts)
 		}
 
 		if (read_oneliner(&buf, rebase_path_squash_onto(), 0)) {
-			if (get_oid_committish(buf.buf, &opts->squash_onto) < 0) {
+			if (repo_get_oid_committish(the_repository, buf.buf, &opts->squash_onto) < 0) {
 				ret = error(_("unusable squash-onto"));
 				goto done_rebase_i;
 			}
@@ -3223,7 +3224,7 @@ static int rollback_is_safe(void)
 	else
 		die_errno(_("could not read '%s'"), git_path_abort_safety_file());
 
-	if (get_oid("HEAD", &actual_head))
+	if (repo_get_oid(the_repository, "HEAD", &actual_head))
 		oidclr(&actual_head);
 
 	return oideq(&actual_head, &expected_head);
@@ -3534,7 +3535,7 @@ static int intend_to_amend(void)
 	struct object_id head;
 	char *p;
 
-	if (get_oid("HEAD", &head))
+	if (repo_get_oid(the_repository, "HEAD", &head))
 		return error(_("cannot read HEAD"));
 
 	p = oid_to_hex(&head);
@@ -3700,7 +3701,7 @@ static int do_label(struct repository *r, const char *name, int len)
 	if (!transaction) {
 		error("%s", err.buf);
 		ret = -1;
-	} else if (get_oid("HEAD", &head_oid)) {
+	} else if (repo_get_oid(the_repository, "HEAD", &head_oid)) {
 		error(_("could not read HEAD"));
 		ret = -1;
 	} else if (ref_transaction_update(transaction, ref_name.buf, &head_oid,
@@ -4456,7 +4457,7 @@ void create_autostash(struct repository *r, const char *path)
 		if (capture_command(&stash, &buf, GIT_MAX_HEXSZ))
 			die(_("Cannot autostash"));
 		strbuf_trim_trailing_newline(&buf);
-		if (get_oid(buf.buf, &oid))
+		if (repo_get_oid(the_repository, buf.buf, &oid))
 			die(_("Unexpected stash response: '%s'"),
 			    buf.buf);
 		strbuf_reset(&buf);
@@ -4581,7 +4582,7 @@ static int stopped_at_head(struct repository *r)
 	struct commit *commit;
 	struct commit_message message;
 
-	if (get_oid("HEAD", &head) ||
+	if (repo_get_oid(the_repository, "HEAD", &head) ||
 	    !(commit = lookup_commit(r, &head)) ||
 	    parse_commit(commit) || get_message(commit, &message))
 		fprintf(stderr, _("Stopped at HEAD\n"));
@@ -4731,7 +4732,7 @@ static int pick_commits(struct repository *r,
 				 * otherwise we do not.
 				 */
 				if (item->command == TODO_REWORD &&
-				    !get_oid("HEAD", &oid) &&
+				    !repo_get_oid(the_repository, "HEAD", &oid) &&
 				    (oideq(&item->commit->object.oid, &oid) ||
 				     (opts->have_squash_onto &&
 				      oideq(&opts->squash_onto, &oid))))
@@ -4820,7 +4821,7 @@ static int pick_commits(struct repository *r,
 			struct object_id head, orig;
 			int res;
 
-			if (get_oid("HEAD", &head)) {
+			if (repo_get_oid(the_repository, "HEAD", &head)) {
 				res = error(_("cannot read HEAD"));
 cleanup_head_ref:
 				strbuf_release(&head_ref);
@@ -4867,8 +4868,8 @@ static int pick_commits(struct repository *r,
 			log_tree_opt.disable_stdin = 1;
 
 			if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
-			    !get_oid(buf.buf, &orig) &&
-			    !get_oid("HEAD", &head)) {
+			    !repo_get_oid(the_repository, buf.buf, &orig) &&
+			    !repo_get_oid(the_repository, "HEAD", &head)) {
 				diff_tree_oid(&orig, &head, "",
 					      &log_tree_opt.diffopt);
 				log_tree_diff_flush(&log_tree_opt);
@@ -4960,7 +4961,7 @@ static int commit_staged_changes(struct repository *r,
 		struct strbuf rev = STRBUF_INIT;
 		struct object_id head, to_amend;
 
-		if (get_oid("HEAD", &head))
+		if (repo_get_oid(the_repository, "HEAD", &head))
 			return error(_("cannot amend non-existing commit"));
 		if (!read_oneliner(&rev, rebase_path_amend(), 0))
 			return error(_("invalid file: '%s'"), rebase_path_amend());
@@ -5185,7 +5186,7 @@ int sequencer_pick_revisions(struct repository *r,
 		if (!strlen(name))
 			continue;
 
-		if (!get_oid(name, &oid)) {
+		if (!repo_get_oid(the_repository, name, &oid)) {
 			if (!lookup_commit_reference_gently(r, &oid, 1)) {
 				enum object_type type = oid_object_info(r,
 									&oid,
@@ -5228,7 +5229,7 @@ int sequencer_pick_revisions(struct repository *r,
 	if (walk_revs_populate_todo(&todo_list, opts) ||
 			create_seq_dir(r) < 0)
 		return -1;
-	if (get_oid("HEAD", &oid) && (opts->action == REPLAY_REVERT))
+	if (repo_get_oid(the_repository, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
 		return error(_("can't revert as initial commit"));
 	if (save_head(oid_to_hex(&oid)))
 		return -1;
@@ -5360,7 +5361,8 @@ static const char *label_oid(struct object_id *oid, const char *label,
 		strbuf_grow(&state->buf, GIT_MAX_HEXSZ);
 		label = p = state->buf.buf;
 
-		find_unique_abbrev_r(p, oid, default_abbrev);
+		repo_find_unique_abbrev_r(the_repository, p, oid,
+					  default_abbrev);
 
 		/*
 		 * We may need to extend the abbreviated hash so that there is
@@ -6093,7 +6095,8 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
 	struct object_id oid = onto->object.oid;
 	int res;
 
-	find_unique_abbrev_r(shortonto, &oid, DEFAULT_ABBREV);
+	repo_find_unique_abbrev_r(the_repository, shortonto, &oid,
+				  DEFAULT_ABBREV);
 
 	if (buf->len == 0) {
 		struct todo_item *item = append_new_todo(todo_list);
@@ -6369,8 +6372,8 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
 		if (file_exists(git_path_seq_dir()))
 			*whence = FROM_CHERRY_PICK_MULTI;
 		if (file_exists(rebase_path()) &&
-		    !get_oid("REBASE_HEAD", &rebase_head) &&
-		    !get_oid("CHERRY_PICK_HEAD", &cherry_pick_head) &&
+		    !repo_get_oid(the_repository, "REBASE_HEAD", &rebase_head) &&
+		    !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
 		    oideq(&rebase_head, &cherry_pick_head))
 			*whence = FROM_REBASE_PICK;
 		else
diff --git a/submodule-config.c b/submodule-config.c
index 4dc61b3a78a..336732ed785 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -535,7 +535,7 @@ static int gitmodule_oid_from_commit(const struct object_id *treeish_name,
 	}
 
 	strbuf_addf(rev, "%s:.gitmodules", oid_to_hex(treeish_name));
-	if (get_oid(rev->buf, gitmodules_oid) >= 0)
+	if (repo_get_oid(the_repository, rev->buf, gitmodules_oid) >= 0)
 		ret = 1;
 
 	return ret;
diff --git a/submodule.c b/submodule.c
index 3a0dfc417c0..5936553464a 100644
--- a/submodule.c
+++ b/submodule.c
@@ -65,7 +65,7 @@ int is_writing_gitmodules_ok(void)
 {
 	struct object_id oid;
 	return file_exists(GITMODULES_FILE) ||
-		(get_oid(GITMODULES_INDEX, &oid) < 0 && get_oid(GITMODULES_HEAD, &oid) < 0);
+		(repo_get_oid(the_repository, GITMODULES_INDEX, &oid) < 0 && repo_get_oid(the_repository, GITMODULES_HEAD, &oid) < 0);
 }
 
 /*
@@ -1625,7 +1625,7 @@ get_fetch_task_from_changed(struct submodule_parallel_fetch *spf,
 		if (!task->repo) {
 			strbuf_addf(err, _("Could not access submodule '%s' at commit %s\n"),
 				    cs_data->path,
-				    find_unique_abbrev(cs_data->super_oid, DEFAULT_ABBREV));
+				    repo_find_unique_abbrev(the_repository, cs_data->super_oid, DEFAULT_ABBREV));
 
 			fetch_task_release(task);
 			free(task);
@@ -1636,8 +1636,8 @@ get_fetch_task_from_changed(struct submodule_parallel_fetch *spf,
 			strbuf_addf(err,
 				    _("Fetching submodule %s%s at commit %s\n"),
 				    spf->prefix, task->sub->path,
-				    find_unique_abbrev(cs_data->super_oid,
-						       DEFAULT_ABBREV));
+				    repo_find_unique_abbrev(the_repository, cs_data->super_oid,
+							    DEFAULT_ABBREV));
 
 		spf->changed_count++;
 		/*
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index efc82dd80c5..5d1284328d0 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -25,7 +25,8 @@
 
 static const char *short_commit_name(struct commit *commit)
 {
-	return find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV);
+	return repo_find_unique_abbrev(the_repository, &commit->object.oid,
+				       DEFAULT_ABBREV);
 }
 
 static struct commit *peel_committish(const char *name)
@@ -33,10 +34,11 @@ static struct commit *peel_committish(const char *name)
 	struct object *obj;
 	struct object_id oid;
 
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return NULL;
 	obj = parse_object(the_repository, &oid);
-	return (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
+	return (struct commit *)repo_peel_to_type(the_repository, name, 0, obj,
+						  OBJ_COMMIT);
 }
 
 static char *get_author(const char *message)
@@ -119,7 +121,7 @@ int cmd__fast_rebase(int argc, const char **argv)
 	strbuf_addf(&branch_name, "refs/heads/%s", argv[4]);
 
 	/* Sanity check */
-	if (get_oid("HEAD", &head))
+	if (repo_get_oid(the_repository, "HEAD", &head))
 		die(_("Cannot read HEAD"));
 	assert(oideq(&onto->object.oid, &head));
 
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 4079fdee067..daadf3827aa 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -9,9 +9,9 @@ int cmd__match_trees(int ac, const char **av)
 
 	setup_git_directory();
 
-	if (get_oid(av[1], &hash1))
+	if (repo_get_oid(the_repository, av[1], &hash1))
 		die("cannot parse %s as an object name", av[1]);
-	if (get_oid(av[2], &hash2))
+	if (repo_get_oid(the_repository, av[2], &hash2))
 		die("cannot parse %s as an object name", av[2]);
 	one = parse_tree_indirect(&hash1);
 	if (!one)
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index 0acf99931ee..7b194edde2b 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -49,7 +49,7 @@ int cmd__oidmap(int argc, const char **argv)
 
 		if (!strcmp("put", cmd) && p1 && p2) {
 
-			if (get_oid(p1, &oid)) {
+			if (repo_get_oid(the_repository, p1, &oid)) {
 				printf("Unknown oid: %s\n", p1);
 				continue;
 			}
@@ -67,7 +67,7 @@ int cmd__oidmap(int argc, const char **argv)
 
 		} else if (!strcmp("get", cmd) && p1) {
 
-			if (get_oid(p1, &oid)) {
+			if (repo_get_oid(the_repository, p1, &oid)) {
 				printf("Unknown oid: %s\n", p1);
 				continue;
 			}
@@ -80,7 +80,7 @@ int cmd__oidmap(int argc, const char **argv)
 
 		} else if (!strcmp("remove", cmd) && p1) {
 
-			if (get_oid(p1, &oid)) {
+			if (repo_get_oid(the_repository, p1, &oid)) {
 				printf("Unknown oid: %s\n", p1);
 				continue;
 			}
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index 2f65c7f6a55..00f0f29a6a6 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -57,7 +57,7 @@ int cmd__reach(int ac, const char **av)
 		if (buf.len < 3)
 			continue;
 
-		if (get_oid_committish(buf.buf + 2, &oid))
+		if (repo_get_oid_committish(the_repository, buf.buf + 2, &oid))
 			die("failed to resolve %s", buf.buf + 2);
 
 		orig = parse_object(r, &oid);
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 22a41c40926..91c82d4159d 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -42,7 +42,7 @@ int cmd__submodule_config(int argc, const char **argv)
 
 		if (commit[0] == '\0')
 			oidclr(&commit_oid);
-		else if (get_oid(commit, &commit_oid) < 0)
+		else if (repo_get_oid(the_repository, commit, &commit_oid) < 0)
 			die_usage(argc, argv, "Commit not found.");
 
 		if (lookup_name) {
diff --git a/tag.c b/tag.c
index dfbcd7fcc24..dfc900e62e0 100644
--- a/tag.c
+++ b/tag.c
@@ -51,7 +51,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
 		return error("%s: cannot verify a non-tag object of type %s.",
 				name_to_report ?
 				name_to_report :
-				find_unique_abbrev(oid, DEFAULT_ABBREV),
+				repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
 				type_name(type));
 
 	buf = read_object_file(oid, &type, &size);
@@ -59,7 +59,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
 		return error("%s: unable to read file.",
 				name_to_report ?
 				name_to_report :
-				find_unique_abbrev(oid, DEFAULT_ABBREV));
+				repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
 
 	ret = run_gpg_verify(buf, size, flags);
 
diff --git a/transport-helper.c b/transport-helper.c
index 3ea7c2bb5ad..2a1b4497caa 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1081,7 +1081,7 @@ static int push_refs_with_export(struct transport *transport,
 		struct object_id oid;
 
 		private = apply_refspecs(&data->rs, ref->name);
-		if (private && !get_oid(private, &oid)) {
+		if (private && !repo_get_oid(the_repository, private, &oid)) {
 			strbuf_addf(&buf, "^%s", private);
 			string_list_append_nodup(&revlist_args,
 						 strbuf_detach(&buf, NULL));
diff --git a/transport.c b/transport.c
index 77a61a9d7bb..7488622e77d 100644
--- a/transport.c
+++ b/transport.c
@@ -776,7 +776,8 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count,
 static int measure_abbrev(const struct object_id *oid, int sofar)
 {
 	char hex[GIT_MAX_HEXSZ + 1];
-	int w = find_unique_abbrev_r(hex, oid, DEFAULT_ABBREV);
+	int w = repo_find_unique_abbrev_r(the_repository, hex, oid,
+					  DEFAULT_ABBREV);
 
 	return (w < sofar) ? sofar : w;
 }
diff --git a/wt-status.c b/wt-status.c
index 3162241a570..c55c51b1924 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1337,7 +1337,7 @@ static void abbrev_oid_in_line(struct strbuf *line)
 		 * it after abbreviation.
 		 */
 		strbuf_trim(split[1]);
-		if (!get_oid(split[1]->buf, &oid)) {
+		if (!repo_get_oid(the_repository, split[1]->buf, &oid)) {
 			strbuf_reset(split[1]);
 			strbuf_add_unique_abbrev(split[1], &oid,
 						 DEFAULT_ABBREV);
@@ -1503,8 +1503,8 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
 	else
 		status_printf_ln(s, color,
 			_("You are currently cherry-picking commit %s."),
-			find_unique_abbrev(&s->state.cherry_pick_head_oid,
-					   DEFAULT_ABBREV));
+			repo_find_unique_abbrev(the_repository, &s->state.cherry_pick_head_oid,
+						DEFAULT_ABBREV));
 
 	if (s->hints) {
 		if (has_unmerged(s))
@@ -1533,8 +1533,8 @@ static void show_revert_in_progress(struct wt_status *s,
 	else
 		status_printf_ln(s, color,
 			_("You are currently reverting commit %s."),
-			find_unique_abbrev(&s->state.revert_head_oid,
-					   DEFAULT_ABBREV));
+			repo_find_unique_abbrev(the_repository, &s->state.revert_head_oid,
+						DEFAULT_ABBREV));
 	if (s->hints) {
 		if (has_unmerged(s))
 			status_printf_ln(s, color,
@@ -1676,9 +1676,9 @@ static void wt_status_get_detached_from(struct repository *r,
 		state->detached_from = xstrdup(from);
 	} else
 		state->detached_from =
-			xstrdup(find_unique_abbrev(&cb.noid, DEFAULT_ABBREV));
+			xstrdup(repo_find_unique_abbrev(the_repository, &cb.noid, DEFAULT_ABBREV));
 	oidcpy(&state->detached_oid, &cb.noid);
-	state->detached_at = !get_oid("HEAD", &oid) &&
+	state->detached_at = !repo_get_oid(the_repository, "HEAD", &oid) &&
 			     oideq(&oid, &state->detached_oid);
 
 	free(ref);
@@ -1769,13 +1769,13 @@ void wt_status_get_state(struct repository *r,
 	} else if (wt_status_check_rebase(NULL, state)) {
 		;		/* all set */
 	} else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
-		   !get_oid("CHERRY_PICK_HEAD", &oid)) {
+		   !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &oid)) {
 		state->cherry_pick_in_progress = 1;
 		oidcpy(&state->cherry_pick_head_oid, &oid);
 	}
 	wt_status_check_bisect(NULL, state);
 	if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") &&
-	    !get_oid("REVERT_HEAD", &oid)) {
+	    !repo_get_oid(the_repository, "REVERT_HEAD", &oid)) {
 		state->revert_in_progress = 1;
 		oidcpy(&state->revert_head_oid, &oid);
 	}
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 06/17] cocci: apply the "commit-reach.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (4 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 05/17] cocci: apply the "cache.h" part of "the_repository.pending" Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 07/17] cocci: apply the "commit.h" " Ævar Arnfjörð Bjarmason
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"commit-reach.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 bisect.c                                        |  3 ++-
 builtin/branch.c                                |  5 +++--
 builtin/fast-import.c                           |  2 +-
 builtin/fetch.c                                 |  3 ++-
 builtin/log.c                                   | 10 +++++++---
 builtin/merge-base.c                            |  5 +++--
 builtin/merge-tree.c                            |  3 ++-
 builtin/merge.c                                 |  7 +++++--
 builtin/rebase.c                                |  5 +++--
 builtin/receive-pack.c                          |  2 +-
 builtin/rev-parse.c                             |  2 +-
 commit-reach.c                                  |  3 ++-
 commit-reach.h                                  |  9 ---------
 commit.c                                        |  3 ++-
 contrib/coccinelle/the_repository.cocci         | 16 ++++++++++++++++
 contrib/coccinelle/the_repository.pending.cocci | 16 ----------------
 http-push.c                                     |  2 +-
 log-tree.c                                      |  2 +-
 merge-ort.c                                     |  2 +-
 merge-recursive.c                               |  2 +-
 notes-merge.c                                   |  2 +-
 remote.c                                        |  2 +-
 revision.c                                      |  4 ++--
 sequencer.c                                     |  3 ++-
 shallow.c                                       |  9 +++++----
 t/helper/test-reach.c                           | 10 +++++++---
 26 files changed, 72 insertions(+), 60 deletions(-)

diff --git a/bisect.c b/bisect.c
index ef5ee5a6436..3088516e174 100644
--- a/bisect.c
+++ b/bisect.c
@@ -846,7 +846,8 @@ static enum bisect_error check_merge_bases(int rev_nr, struct commit **rev, int
 	enum bisect_error res = BISECT_OK;
 	struct commit_list *result;
 
-	result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
+	result = repo_get_merge_bases_many(the_repository, rev[0], rev_nr - 1,
+					   rev + 1);
 
 	for (; result; result = result->next) {
 		const struct object_id *mb = &result->item->object.oid;
diff --git a/builtin/branch.c b/builtin/branch.c
index 968ea03c059..bbcfb34b3c6 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -150,7 +150,8 @@ static int branch_merged(int kind, const char *name,
 	if (!reference_rev)
 		reference_rev = head_rev;
 
-	merged = reference_rev ? in_merge_bases(rev, reference_rev) : 0;
+	merged = reference_rev ? repo_in_merge_bases(the_repository, rev,
+						     reference_rev) : 0;
 
 	/*
 	 * After the safety valve is fully redefined to "check with
@@ -160,7 +161,7 @@ static int branch_merged(int kind, const char *name,
 	 * a gentle reminder is in order.
 	 */
 	if ((head_rev != reference_rev) &&
-	    (head_rev ? in_merge_bases(rev, head_rev) : 0) != merged) {
+	    (head_rev ? repo_in_merge_bases(the_repository, rev, head_rev) : 0) != merged) {
 		if (merged)
 			warning(_("deleting branch '%s' that has been merged to\n"
 				"         '%s', but not yet merged to HEAD."),
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index f533b768efb..2098c0c5a37 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -1625,7 +1625,7 @@ static int update_branch(struct branch *b)
 		if (!old_cmit || !new_cmit)
 			return error("Branch %s is missing commits.", b->name);
 
-		if (!in_merge_bases(old_cmit, new_cmit)) {
+		if (!repo_in_merge_bases(the_repository, old_cmit, new_cmit)) {
 			warning("Not updating %s"
 				" (new tip %s does not contain %s)",
 				b->name, oid_to_hex(&b->oid),
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 80cf1d01583..db8815032fc 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -965,7 +965,8 @@ static int update_local_ref(struct ref *ref,
 
 	if (fetch_show_forced_updates) {
 		uint64_t t_before = getnanotime();
-		fast_forward = in_merge_bases(current, updated);
+		fast_forward = repo_in_merge_bases(the_repository, current,
+						   updated);
 		forced_updates_ms += (getnanotime() - t_before) / 1000000;
 	} else {
 		fast_forward = 1;
diff --git a/builtin/log.c b/builtin/log.c
index b4c38f6ad87..5604b4b5f05 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1649,7 +1649,9 @@ static struct commit *get_base_commit(const char *base_commit,
 					return NULL;
 			}
 			commit = lookup_commit_or_die(&oid, "upstream base");
-			base_list = get_merge_bases_many(commit, total, list);
+			base_list = repo_get_merge_bases_many(the_repository,
+							      commit, total,
+							      list);
 			/* There should be one and only one merge base. */
 			if (!base_list || base_list->next) {
 				if (die_on_failure) {
@@ -1683,7 +1685,9 @@ static struct commit *get_base_commit(const char *base_commit,
 	while (rev_nr > 1) {
 		for (i = 0; i < rev_nr / 2; i++) {
 			struct commit_list *merge_base;
-			merge_base = get_merge_bases(rev[2 * i], rev[2 * i + 1]);
+			merge_base = repo_get_merge_bases(the_repository,
+							  rev[2 * i],
+							  rev[2 * i + 1]);
 			if (!merge_base || merge_base->next) {
 				if (die_on_failure) {
 					die(_("failed to find exact merge base"));
@@ -1701,7 +1705,7 @@ static struct commit *get_base_commit(const char *base_commit,
 		rev_nr = DIV_ROUND_UP(rev_nr, 2);
 	}
 
-	if (!in_merge_bases(base, rev[0])) {
+	if (!repo_in_merge_bases(the_repository, base, rev[0])) {
 		if (die_on_failure) {
 			die(_("base commit should be the ancestor of revision list"));
 		} else {
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 688d5c29b76..64d29136d16 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -13,7 +13,8 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
 {
 	struct commit_list *result, *r;
 
-	result = get_merge_bases_many_dirty(rev[0], rev_nr - 1, rev + 1);
+	result = repo_get_merge_bases_many_dirty(the_repository, rev[0],
+						 rev_nr - 1, rev + 1);
 
 	if (!result)
 		return 1;
@@ -105,7 +106,7 @@ static int handle_is_ancestor(int argc, const char **argv)
 		die("--is-ancestor takes exactly two commits");
 	one = get_commit_reference(argv[0]);
 	two = get_commit_reference(argv[1]);
-	if (in_merge_bases(one, two))
+	if (repo_in_merge_bases(the_repository, one, two))
 		return 0;
 	else
 		return 1;
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 828dc81c426..4e4a9d6ba17 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -452,7 +452,8 @@ static int real_merge(struct merge_tree_options *o,
 		 * Get the merge bases, in reverse order; see comment above
 		 * merge_incore_recursive in merge-ort.h
 		 */
-		merge_bases = get_merge_bases(parent1, parent2);
+		merge_bases = repo_get_merge_bases(the_repository, parent1,
+						   parent2);
 		if (!merge_bases && !o->allow_unrelated_histories)
 			die(_("refusing to merge unrelated histories"));
 		merge_bases = reverse_commit_list(merge_bases);
diff --git a/builtin/merge.c b/builtin/merge.c
index 7331a0cd911..c5a9321806d 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1531,7 +1531,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 	if (!remoteheads)
 		; /* already up-to-date */
 	else if (!remoteheads->next)
-		common = get_merge_bases(head_commit, remoteheads->item);
+		common = repo_get_merge_bases(the_repository, head_commit,
+					      remoteheads->item);
 	else {
 		struct commit_list *list = remoteheads;
 		commit_list_insert(head_commit, &list);
@@ -1649,7 +1650,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 			 * merge_bases again, otherwise "git merge HEAD^
 			 * HEAD^^" would be missed.
 			 */
-			common_one = get_merge_bases(head_commit, j->item);
+			common_one = repo_get_merge_bases(the_repository,
+							  head_commit,
+							  j->item);
 			if (!oideq(&common_one->item->object.oid, &j->item->object.oid)) {
 				up_to_date = 0;
 				break;
diff --git a/builtin/rebase.c b/builtin/rebase.c
index d5358ca89d2..5fd7bfb4860 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -882,7 +882,7 @@ static int can_fast_forward(struct commit *onto, struct commit *upstream,
 	if (!upstream)
 		goto done;
 
-	merge_bases = get_merge_bases(upstream, head);
+	merge_bases = repo_get_merge_bases(the_repository, upstream, head);
 	if (!merge_bases || merge_bases->next)
 		goto done;
 
@@ -901,7 +901,8 @@ static void fill_branch_base(struct rebase_options *options,
 {
 	struct commit_list *merge_bases = NULL;
 
-	merge_bases = get_merge_bases(options->onto, options->orig_head);
+	merge_bases = repo_get_merge_bases(the_repository, options->onto,
+					   options->orig_head);
 	if (!merge_bases || merge_bases->next)
 		oidcpy(branch_base, null_oid());
 	else
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index b5816624d25..6d4fc1368a4 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1548,7 +1548,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
 		}
 		old_commit = (struct commit *)old_object;
 		new_commit = (struct commit *)new_object;
-		if (!in_merge_bases(old_commit, new_commit)) {
+		if (!repo_in_merge_bases(the_repository, old_commit, new_commit)) {
 			rp_error("denying non-fast-forward %s"
 				 " (you should pull first)", name);
 			ret = "non-fast-forward";
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index eb53a303de6..5685cf0ea7d 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -292,7 +292,7 @@ static int try_difference(const char *arg)
 				*dotdot = '.';
 				return 0;
 			}
-			exclude = get_merge_bases(a, b);
+			exclude = repo_get_merge_bases(the_repository, a, b);
 			while (exclude) {
 				struct commit *commit = pop_commit(&exclude);
 				show_rev(REVERSED, &commit->object.oid, NULL);
diff --git a/commit-reach.c b/commit-reach.c
index 2e33c599a82..a4b9eda723f 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -162,7 +162,8 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)
 
 		for (j = ret; j; j = j->next) {
 			struct commit_list *bases;
-			bases = get_merge_bases(i->item, j->item);
+			bases = repo_get_merge_bases(the_repository, i->item,
+						     j->item);
 			if (!new_commits)
 				new_commits = bases;
 			else
diff --git a/commit-reach.h b/commit-reach.h
index 148b56fea50..94a96e03299 100644
--- a/commit-reach.h
+++ b/commit-reach.h
@@ -19,11 +19,6 @@ struct commit_list *repo_get_merge_bases_many(struct repository *r,
 struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,
 						    struct commit *one, int n,
 						    struct commit **twos);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define get_merge_bases(r1, r2)           repo_get_merge_bases(the_repository, r1, r2)
-#define get_merge_bases_many(one, n, two) repo_get_merge_bases_many(the_repository, one, n, two)
-#define get_merge_bases_many_dirty(one, n, twos) repo_get_merge_bases_many_dirty(the_repository, one, n, twos)
-#endif
 
 struct commit_list *get_octopus_merge_bases(struct commit_list *in);
 
@@ -36,10 +31,6 @@ int repo_in_merge_bases(struct repository *r,
 int repo_in_merge_bases_many(struct repository *r,
 			     struct commit *commit,
 			     int nr_reference, struct commit **reference);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define in_merge_bases(c1, c2) repo_in_merge_bases(the_repository, c1, c2)
-#define in_merge_bases_many(c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs)
-#endif
 
 /*
  * Takes a list of commits and returns a new list where those
diff --git a/commit.c b/commit.c
index 06a7c728e80..62682f55643 100644
--- a/commit.c
+++ b/commit.c
@@ -1014,7 +1014,8 @@ struct commit *get_fork_point(const char *refname, struct commit *commit)
 	for (i = 0; i < revs.nr; i++)
 		revs.commit[i]->object.flags &= ~TMP_MARK;
 
-	bases = get_merge_bases_many(commit, revs.nr, revs.commit);
+	bases = repo_get_merge_bases_many(the_repository, commit, revs.nr,
+					  revs.commit);
 
 	/*
 	 * There should be one and only one merge base, when we found
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index dcdba314fc2..1ab63f0196b 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -38,6 +38,22 @@
 |
 - peel_to_type
 + repo_peel_to_type
+// commit-reach.h
+|
+- get_merge_bases
++ repo_get_merge_bases
+|
+- get_merge_bases_many
++ repo_get_merge_bases_many
+|
+- get_merge_bases_many_dirty
++ repo_get_merge_bases_many_dirty
+|
+- in_merge_bases
++ repo_in_merge_bases
+|
+- in_merge_bases_many
++ repo_in_merge_bases_many
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 2d200ab83e7..e9209fc0cc4 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,23 +5,7 @@
 @@
 @@
 (
-// commit-reach.h
-- get_merge_bases
-+ repo_get_merge_bases
-|
-- get_merge_bases_many
-+ repo_get_merge_bases_many
-|
-- get_merge_bases_many_dirty
-+ repo_get_merge_bases_many_dirty
-|
-- in_merge_bases
-+ repo_in_merge_bases
-|
-- in_merge_bases_many
-+ repo_in_merge_bases_many
 // commit.h
-|
 - parse_commit_internal
 + repo_parse_commit_internal
 |
diff --git a/http-push.c b/http-push.c
index 7f71316456c..ceab00bd901 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1570,7 +1570,7 @@ static int verify_merge_base(struct object_id *head_oid, struct ref *remote)
 	struct commit *branch = lookup_commit_or_die(&remote->old_oid,
 						     remote->name);
 
-	return in_merge_bases(branch, head);
+	return repo_in_merge_bases(the_repository, branch, head);
 }
 
 static int delete_remote_branch(const char *pattern, int force)
diff --git a/log-tree.c b/log-tree.c
index f36adb947e8..4bebb86ecac 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -993,7 +993,7 @@ static int do_remerge_diff(struct rev_info *opt,
 	/* Parse the relevant commits and get the merge bases */
 	parse_commit_or_die(parent1);
 	parse_commit_or_die(parent2);
-	bases = get_merge_bases(parent1, parent2);
+	bases = repo_get_merge_bases(the_repository, parent1, parent2);
 
 	/* Re-merge the parents */
 	merge_incore_recursive(&o, bases, parent1, parent2, &res);
diff --git a/merge-ort.c b/merge-ort.c
index d1611ca400a..e9f8bd15982 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -5017,7 +5017,7 @@ static void merge_ort_internal(struct merge_options *opt,
 	struct strbuf merge_base_abbrev = STRBUF_INIT;
 
 	if (!merge_bases) {
-		merge_bases = get_merge_bases(h1, h2);
+		merge_bases = repo_get_merge_bases(the_repository, h1, h2);
 		/* See merge-ort.h:merge_incore_recursive() declaration NOTE */
 		merge_bases = reverse_commit_list(merge_bases);
 	}
diff --git a/merge-recursive.c b/merge-recursive.c
index ae469f8cc81..9771ef540c4 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3592,7 +3592,7 @@ static int merge_recursive_internal(struct merge_options *opt,
 	}
 
 	if (!merge_bases) {
-		merge_bases = get_merge_bases(h1, h2);
+		merge_bases = repo_get_merge_bases(the_repository, h1, h2);
 		merge_bases = reverse_commit_list(merge_bases);
 	}
 
diff --git a/notes-merge.c b/notes-merge.c
index d290c7478e2..fca9422a294 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -600,7 +600,7 @@ int notes_merge(struct notes_merge_options *o,
 	assert(local && remote);
 
 	/* Find merge bases */
-	bases = get_merge_bases(local, remote);
+	bases = repo_get_merge_bases(the_repository, local, remote);
 	if (!bases) {
 		base_oid = null_oid();
 		base_tree_oid = the_hash_algo->empty_tree;
diff --git a/remote.c b/remote.c
index ff9b0238318..71b1ae2db05 100644
--- a/remote.c
+++ b/remote.c
@@ -2662,7 +2662,7 @@ static int is_reachable_in_reflog(const char *local, const struct ref *remote)
 		if (MERGE_BASES_BATCH_SIZE < size)
 			size = MERGE_BASES_BATCH_SIZE;
 
-		if ((ret = in_merge_bases_many(commit, size, chunk)))
+		if ((ret = repo_in_merge_bases_many(the_repository, commit, size, chunk)))
 			break;
 	}
 
diff --git a/revision.c b/revision.c
index 0f775ee2e90..c2b7b2f1073 100644
--- a/revision.c
+++ b/revision.c
@@ -1957,7 +1957,7 @@ static void prepare_show_merge(struct rev_info *revs)
 	other = lookup_commit_or_die(&oid, "MERGE_HEAD");
 	add_pending_object(revs, &head->object, "HEAD");
 	add_pending_object(revs, &other->object, "MERGE_HEAD");
-	bases = get_merge_bases(head, other);
+	bases = repo_get_merge_bases(the_repository, head, other);
 	add_rev_cmdline_list(revs, bases, REV_CMD_MERGE_BASE, UNINTERESTING | BOTTOM);
 	add_pending_commit_list(revs, bases, UNINTERESTING | BOTTOM);
 	free_commit_list(bases);
@@ -2052,7 +2052,7 @@ static int handle_dotdot_1(const char *arg, char *dotdot,
 		if (!a || !b)
 			return dotdot_missing(arg, dotdot, revs, symmetric);
 
-		exclude = get_merge_bases(a, b);
+		exclude = repo_get_merge_bases(the_repository, a, b);
 		add_rev_cmdline_list(revs, exclude, REV_CMD_MERGE_BASE,
 				     flags_exclude);
 		add_pending_commit_list(revs, exclude, flags_exclude);
diff --git a/sequencer.c b/sequencer.c
index 818932a630a..d97923883ff 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4102,7 +4102,8 @@ static int do_merge(struct repository *r,
 	}
 
 	merge_commit = to_merge->item;
-	bases = get_merge_bases(head_commit, merge_commit);
+	bases = repo_get_merge_bases(the_repository, head_commit,
+				     merge_commit);
 	if (bases && oideq(&merge_commit->object.oid,
 			   &bases->item->object.oid)) {
 		ret = 0;
diff --git a/shallow.c b/shallow.c
index 17f9bcdb5f3..0fcdfd7d35a 100644
--- a/shallow.c
+++ b/shallow.c
@@ -791,7 +791,7 @@ static void post_assign_shallow(struct shallow_info *info,
 		for (j = 0; j < bitmap_nr; j++)
 			if (bitmap[0][j] &&
 			    /* Step 7, reachability test at commit level */
-			    !in_merge_bases_many(c, ca.nr, ca.commits)) {
+			    !repo_in_merge_bases_many(the_repository, c, ca.nr, ca.commits)) {
 				update_refstatus(ref_status, info->ref->nr, *bitmap);
 				dst++;
 				break;
@@ -819,9 +819,10 @@ int delayed_reachability_test(struct shallow_info *si, int c)
 			si->nr_commits = ca.nr;
 		}
 
-		si->reachable[c] = in_merge_bases_many(commit,
-						       si->nr_commits,
-						       si->commits);
+		si->reachable[c] = repo_in_merge_bases_many(the_repository,
+							    commit,
+							    si->nr_commits,
+							    si->commits);
 		si->need_reachability_test[c] = 0;
 	}
 	return si->reachable[c];
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index 00f0f29a6a6..b6d197722f0 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -106,13 +106,17 @@ int cmd__reach(int ac, const char **av)
 	if (!strcmp(av[1], "ref_newer"))
 		printf("%s(A,B):%d\n", av[1], ref_newer(&oid_A, &oid_B));
 	else if (!strcmp(av[1], "in_merge_bases"))
-		printf("%s(A,B):%d\n", av[1], in_merge_bases(A, B));
+		printf("%s(A,B):%d\n", av[1],
+		       repo_in_merge_bases(the_repository, A, B));
 	else if (!strcmp(av[1], "in_merge_bases_many"))
-		printf("%s(A,X):%d\n", av[1], in_merge_bases_many(A, X_nr, X_array));
+		printf("%s(A,X):%d\n", av[1],
+		       repo_in_merge_bases_many(the_repository, A, X_nr, X_array));
 	else if (!strcmp(av[1], "is_descendant_of"))
 		printf("%s(A,X):%d\n", av[1], repo_is_descendant_of(r, A, X));
 	else if (!strcmp(av[1], "get_merge_bases_many")) {
-		struct commit_list *list = get_merge_bases_many(A, X_nr, X_array);
+		struct commit_list *list = repo_get_merge_bases_many(the_repository,
+								     A, X_nr,
+								     X_array);
 		printf("%s(A,X):\n", av[1]);
 		print_sorted_commit_ids(list);
 	} else if (!strcmp(av[1], "reduce_heads")) {
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 07/17] cocci: apply the "commit.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (5 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 06/17] cocci: apply the "commit-reach.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 08/17] cocci: apply the "diff.h" " Ævar Arnfjörð Bjarmason
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"commit.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 blame.c                                       |  4 +-
 builtin/am.c                                  |  7 +-
 builtin/blame.c                               |  6 +-
 builtin/checkout.c                            | 13 +--
 builtin/commit.c                              |  8 +-
 builtin/describe.c                            |  4 +-
 builtin/diff.c                                |  3 +-
 builtin/fast-export.c                         |  4 +-
 builtin/gc.c                                  |  4 +-
 builtin/log.c                                 |  5 +-
 builtin/merge-tree.c                          |  6 +-
 builtin/merge.c                               |  3 +-
 builtin/name-rev.c                            |  4 +-
 builtin/notes.c                               |  2 +-
 builtin/rebase.c                              |  2 +-
 builtin/replace.c                             |  4 +-
 builtin/shortlog.c                            |  5 +-
 builtin/show-branch.c                         |  4 +-
 commit-graph.c                                |  2 +-
 commit-reach.c                                | 16 ++--
 commit.c                                      | 25 +++---
 commit.h                                      | 18 ----
 contrib/coccinelle/the_repository.cocci       | 19 +++++
 .../coccinelle/the_repository.pending.cocci   | 19 -----
 delta-islands.c                               |  5 +-
 fmt-merge-msg.c                               |  5 +-
 fsck.c                                        |  4 +-
 http-push.c                                   |  3 +-
 list-objects.c                                | 18 ++--
 merge-recursive.c                             |  2 +-
 negotiator/default.c                          |  6 +-
 negotiator/skipping.c                         |  2 +-
 notes-merge.c                                 |  5 +-
 notes-utils.c                                 |  2 +-
 object-name.c                                 |  8 +-
 pack-bitmap-write.c                           |  3 +-
 pretty.c                                      |  5 +-
 reflog.c                                      |  2 +-
 revision.c                                    | 12 +--
 sequencer.c                                   | 82 +++++++++++--------
 shallow.c                                     |  4 +-
 t/helper/test-fast-rebase.c                   |  9 +-
 tree.c                                        |  2 +-
 walker.c                                      |  4 +-
 44 files changed, 196 insertions(+), 174 deletions(-)

diff --git a/blame.c b/blame.c
index 8bfeaa1c63a..af2b67c0847 100644
--- a/blame.c
+++ b/blame.c
@@ -2429,7 +2429,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
 
 			if (sg_origin[i])
 				continue;
-			if (parse_commit(p))
+			if (repo_parse_commit(the_repository, p))
 				continue;
 			porigin = find(sb->repo, p, origin, sb->bloom_data);
 			if (!porigin)
@@ -2592,7 +2592,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)
 		 * so hold onto it in the meantime.
 		 */
 		blame_origin_incref(suspect);
-		parse_commit(commit);
+		repo_parse_commit(the_repository, commit);
 		if (sb->reverse ||
 		    (!(commit->object.flags & UNINTERESTING) &&
 		     !(revs->max_age != -1 && commit->date < revs->max_age)))
diff --git a/builtin/am.c b/builtin/am.c
index c04038f1f3d..456884852e9 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1329,7 +1329,8 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
 	size_t ident_len;
 	struct ident_split id;
 
-	buffer = logmsg_reencode(commit, NULL, get_commit_output_encoding());
+	buffer = repo_logmsg_reencode(the_repository, commit, NULL,
+				      get_commit_output_encoding());
 
 	ident_line = find_commit_header(buffer, "author", &ident_len);
 	if (!ident_line)
@@ -1361,7 +1362,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
 		die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid));
 	state->msg = xstrdup(msg + 2);
 	state->msg_len = strlen(state->msg);
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
 /**
@@ -1404,7 +1405,7 @@ static void write_index_patch(const struct am_state *state)
 
 	if (!repo_get_oid(the_repository, "HEAD", &head)) {
 		struct commit *commit = lookup_commit_or_die(&head, "HEAD");
-		tree = get_commit_tree(commit);
+		tree = repo_get_commit_tree(the_repository, commit);
 	} else
 		tree = lookup_tree(the_repository,
 				   the_repository->hash_algo->empty_tree);
diff --git a/builtin/blame.c b/builtin/blame.c
index 0155062de11..91e04f57cc0 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -199,13 +199,13 @@ static void get_commit_info(struct commit *commit,
 	const char *message;
 
 	encoding = get_log_output_encoding();
-	message = logmsg_reencode(commit, NULL, encoding);
+	message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
 	get_ac_line(message, "\nauthor ",
 		    &ret->author, &ret->author_mail,
 		    &ret->author_time, &ret->author_tz);
 
 	if (!detailed) {
-		unuse_commit_buffer(commit, message);
+		repo_unuse_commit_buffer(the_repository, commit, message);
 		return;
 	}
 
@@ -219,7 +219,7 @@ static void get_commit_info(struct commit *commit,
 	else
 		strbuf_addf(&ret->summary, "(%s)", oid_to_hex(&commit->object.oid));
 
-	unuse_commit_buffer(commit, message);
+	repo_unuse_commit_buffer(the_repository, commit, message);
 }
 
 /*
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 6216bb6bba3..1d1f33e33e7 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -640,7 +640,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)
 {
 	struct strbuf sb = STRBUF_INIT;
 
-	if (!parse_commit(commit))
+	if (!repo_parse_commit(the_repository, commit))
 		pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
 	if (print_sha1_ellipsis()) {
 		fprintf(stderr, "%s %s... %s\n", msg,
@@ -755,7 +755,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
 			BUG("'switch --orphan' should never accept a commit as starting point");
 		new_tree = parse_tree_indirect(the_hash_algo->empty_tree);
 	} else
-		new_tree = get_commit_tree(new_branch_info->commit);
+		new_tree = repo_get_commit_tree(the_repository,
+						new_branch_info->commit);
 	if (opts->discard_changes) {
 		ret = reset_tree(new_tree, opts, 1, writeout_error, new_branch_info);
 		if (ret)
@@ -817,7 +818,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
 			 */
 			if (!old_branch_info->commit)
 				return 1;
-			old_tree = get_commit_tree(old_branch_info->commit);
+			old_tree = repo_get_commit_tree(the_repository,
+							old_branch_info->commit);
 
 			if (repo_index_has_changes(the_repository, old_tree, &sb))
 				die(_("cannot continue with staged changes in "
@@ -1006,7 +1008,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
 	strbuf_addstr(sb, "  ");
 	strbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);
 	strbuf_addch(sb, ' ');
-	if (!parse_commit(commit))
+	if (!repo_parse_commit(the_repository, commit))
 		pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
 	strbuf_addch(sb, '\n');
 }
@@ -1206,7 +1208,8 @@ static void setup_new_branch_info_and_source_tree(
 		*source_tree = parse_tree_indirect(rev);
 	} else {
 		parse_commit_or_die(new_branch_info->commit);
-		*source_tree = get_commit_tree(new_branch_info->commit);
+		*source_tree = repo_get_commit_tree(the_repository,
+						    new_branch_info->commit);
 	}
 }
 
diff --git a/builtin/commit.c b/builtin/commit.c
index 80d1e31f25a..bda6afc4bd6 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -712,7 +712,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
 {
 	const char *buffer, *subject, *fmt;
 
-	buffer = get_commit_buffer(commit, NULL);
+	buffer = repo_get_commit_buffer(the_repository, commit, NULL);
 	find_commit_subject(buffer, &subject);
 	/*
 	 * If we amend the 'amend!' commit then we don't want to
@@ -720,7 +720,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
 	 */
 	fmt = starts_with(subject, "amend!") ? "%b" : "%B";
 	format_commit_message(commit, fmt, sb, ctx);
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
 static int prepare_to_commit(const char *index_file, const char *prefix,
@@ -1183,7 +1183,7 @@ static const char *read_commit_message(const char *name)
 	if (!commit)
 		die(_("could not lookup commit %s"), name);
 	out_enc = get_commit_output_encoding();
-	return logmsg_reencode(commit, NULL, out_enc);
+	return repo_logmsg_reencode(the_repository, commit, NULL, out_enc);
 }
 
 /*
@@ -1718,7 +1718,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		current_head = NULL;
 	else {
 		current_head = lookup_commit_or_die(&oid, "HEAD");
-		if (parse_commit(current_head))
+		if (repo_parse_commit(the_repository, current_head))
 			die(_("could not parse HEAD commit"));
 	}
 	verbose = -1; /* unspecified */
diff --git a/builtin/describe.c b/builtin/describe.c
index c85bf9c418b..e880a86f37b 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -261,7 +261,7 @@ static unsigned long finish_depth_computation(
 			best->depth++;
 		while (parents) {
 			struct commit *p = parents->item;
-			parse_commit(p);
+			repo_parse_commit(the_repository, p);
 			if (!(p->object.flags & SEEN))
 				commit_list_insert_by_date(p, list);
 			p->object.flags |= c->object.flags;
@@ -404,7 +404,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
 		}
 		while (parents) {
 			struct commit *p = parents->item;
-			parse_commit(p);
+			repo_parse_commit(the_repository, p);
 			if (!(p->object.flags & SEEN))
 				commit_list_insert_by_date(p, &list);
 			p->object.flags |= c->object.flags;
diff --git a/builtin/diff.c b/builtin/diff.c
index 26f1e532c66..1091c377af7 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -548,7 +548,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 		if (!obj)
 			die(_("invalid object '%s' given."), name);
 		if (obj->type == OBJ_COMMIT)
-			obj = &get_commit_tree(((struct commit *)obj))->object;
+			obj = &repo_get_commit_tree(the_repository,
+						    ((struct commit *)obj))->object;
 
 		if (obj->type == OBJ_TREE) {
 			if (sdiff.skip && bitmap_get(sdiff.skip, i))
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 39a890fc005..5fe7c02970e 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -618,7 +618,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
 	rev->diffopt.output_format = DIFF_FORMAT_CALLBACK;
 
 	parse_commit_or_die(commit);
-	commit_buffer = get_commit_buffer(commit, NULL);
+	commit_buffer = repo_get_commit_buffer(the_repository, commit, NULL);
 	author = strstr(commit_buffer, "\nauthor ");
 	if (!author)
 		die("could not find author in commit %s",
@@ -699,7 +699,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
 			  ? strlen(message) : 0),
 	       reencoded ? reencoded : message ? message : "");
 	free(reencoded);
-	unuse_commit_buffer(commit, commit_buffer);
+	repo_unuse_commit_buffer(the_repository, commit, commit_buffer);
 
 	for (i = 0, p = commit->parents; p; p = p->next) {
 		struct object *obj = &p->item->object;
diff --git a/builtin/gc.c b/builtin/gc.c
index 02455fdcd73..e60decbc56c 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -820,7 +820,7 @@ static int dfs_on_ref(const char *refname UNUSED,
 	commit = lookup_commit(the_repository, oid);
 	if (!commit)
 		return 0;
-	if (parse_commit(commit) ||
+	if (repo_parse_commit(the_repository, commit) ||
 	    commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH)
 		return 0;
 
@@ -837,7 +837,7 @@ static int dfs_on_ref(const char *refname UNUSED,
 		commit = pop_commit(&stack);
 
 		for (parent = commit->parents; parent; parent = parent->next) {
-			if (parse_commit(parent->item) ||
+			if (repo_parse_commit(the_repository, parent->item) ||
 			    commit_graph_position(parent->item) != COMMIT_NOT_FROM_GRAPH ||
 			    parent->item->object.flags & SEEN)
 				continue;
diff --git a/builtin/log.c b/builtin/log.c
index 5604b4b5f05..f249aca049a 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1314,10 +1314,11 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
 	log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte, 0);
 
 	for (i = 0; !need_8bit_cte && i < nr; i++) {
-		const char *buf = get_commit_buffer(list[i], NULL);
+		const char *buf = repo_get_commit_buffer(the_repository,
+							 list[i], NULL);
 		if (has_non_ascii(buf))
 			need_8bit_cte = 1;
-		unuse_commit_buffer(list[i], buf);
+		repo_unuse_commit_buffer(the_repository, list[i], buf);
 	}
 
 	if (!branch_name)
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 4e4a9d6ba17..c0acbc6a546 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -443,9 +443,9 @@ static int real_merge(struct merge_tree_options *o,
 			die(_("could not lookup commit %s"), merge_base);
 
 		opt.ancestor = merge_base;
-		base_tree = get_commit_tree(base_commit);
-		parent1_tree = get_commit_tree(parent1);
-		parent2_tree = get_commit_tree(parent2);
+		base_tree = repo_get_commit_tree(the_repository, base_commit);
+		parent1_tree = repo_get_commit_tree(the_repository, parent1);
+		parent2_tree = repo_get_commit_tree(the_repository, parent2);
 		merge_incore_nonrecursive(&opt, base_tree, parent1_tree, parent2_tree, &result);
 	} else {
 		/*
diff --git a/builtin/merge.c b/builtin/merge.c
index c5a9321806d..197e152aba9 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1611,7 +1611,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 			 * Must first ensure that index matches HEAD before
 			 * attempting a trivial merge.
 			 */
-			struct tree *head_tree = get_commit_tree(head_commit);
+			struct tree *head_tree = repo_get_commit_tree(the_repository,
+								      head_commit);
 			struct strbuf sb = STRBUF_INIT;
 
 			if (repo_index_has_changes(the_repository, head_tree,
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 35fd89f794d..ad1de023088 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -181,7 +181,7 @@ static void name_rev(struct commit *start_commit,
 	size_t parents_to_queue_nr, parents_to_queue_alloc = 0;
 	struct rev_name *start_name;
 
-	parse_commit(start_commit);
+	repo_parse_commit(the_repository, start_commit);
 	if (commit_is_before_cutoff(start_commit))
 		return;
 
@@ -211,7 +211,7 @@ static void name_rev(struct commit *start_commit,
 			struct rev_name *parent_name;
 			int generation, distance;
 
-			parse_commit(parent);
+			repo_parse_commit(the_repository, parent);
 			if (commit_is_before_cutoff(parent))
 				continue;
 
diff --git a/builtin/notes.c b/builtin/notes.c
index d98460e5d61..b497eae520e 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -720,7 +720,7 @@ static int merge_commit(struct notes_merge_options *o)
 		die(_("failed to read ref NOTES_MERGE_PARTIAL"));
 	else if (!(partial = lookup_commit_reference(the_repository, &oid)))
 		die(_("could not find commit from NOTES_MERGE_PARTIAL."));
-	else if (parse_commit(partial))
+	else if (repo_parse_commit(the_repository, partial))
 		die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
 
 	if (partial->parents)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 5fd7bfb4860..eba48bffaad 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -853,7 +853,7 @@ static int checkout_up_to_date(struct rebase_options *options)
 static int is_linear_history(struct commit *from, struct commit *to)
 {
 	while (to && to != from) {
-		parse_commit(to);
+		repo_parse_commit(the_repository, to);
 		if (!to->parents)
 			return 1;
 		if (to->parents->next)
diff --git a/builtin/replace.c b/builtin/replace.c
index 33c6cdb79c8..85f0b79c924 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -458,9 +458,9 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
 	if (!commit)
 		return error(_("could not parse %s"), old_ref);
 
-	buffer = get_commit_buffer(commit, &size);
+	buffer = repo_get_commit_buffer(the_repository, commit, &size);
 	strbuf_add(&buf, buffer, size);
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 
 	if (replace_parents(&buf, argc - 1, &argv[1]) < 0) {
 		strbuf_release(&buf);
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 27a87167e19..8afd1ad865e 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -179,7 +179,8 @@ static void insert_records_from_trailers(struct shortlog *log,
 	 * Using format_commit_message("%B") would be simpler here, but
 	 * this saves us copying the message.
 	 */
-	commit_buffer = logmsg_reencode(commit, NULL, ctx->output_encoding);
+	commit_buffer = repo_logmsg_reencode(the_repository, commit, NULL,
+					     ctx->output_encoding);
 	body = strstr(commit_buffer, "\n\n");
 	if (!body)
 		return;
@@ -202,7 +203,7 @@ static void insert_records_from_trailers(struct shortlog *log,
 	trailer_iterator_release(&iter);
 
 	strbuf_release(&ident);
-	unuse_commit_buffer(commit, commit_buffer);
+	repo_unuse_commit_buffer(the_repository, commit, commit_buffer);
 }
 
 static int shortlog_needs_dedup(const struct shortlog *log)
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 9e3b8ed27e1..d60e536a53b 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -240,7 +240,7 @@ static void join_revs(struct commit_list **list_p,
 			parents = parents->next;
 			if ((this_flag & flags) == flags)
 				continue;
-			parse_commit(p);
+			repo_parse_commit(the_repository, p);
 			if (mark_seen(p, seen_p) && !still_interesting)
 				extra--;
 			p->object.flags |= flags;
@@ -842,7 +842,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 		if (!commit)
 			die(_("cannot find commit %s (%s)"),
 			    ref_name[num_rev], oid_to_hex(&revkey));
-		parse_commit(commit);
+		repo_parse_commit(the_repository, commit);
 		mark_seen(commit, &seen);
 
 		/* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,
diff --git a/commit-graph.c b/commit-graph.c
index c11b59f28b3..8273085aa60 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2549,7 +2549,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
 
 		graph_commit = lookup_commit(r, &cur_oid);
 		odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
-		if (parse_commit_internal(odb_commit, 0, 0)) {
+		if (repo_parse_commit_internal(the_repository, odb_commit, 0, 0)) {
 			graph_report(_("failed to parse commit %s from object database for commit-graph"),
 				     oid_to_hex(&cur_oid));
 			continue;
diff --git a/commit-reach.c b/commit-reach.c
index a4b9eda723f..c88faf7e7b2 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -585,7 +585,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
 		return 0;
 	new_commit = (struct commit *) o;
 
-	if (parse_commit(new_commit) < 0)
+	if (repo_parse_commit(the_repository, new_commit) < 0)
 		return 0;
 
 	commit_list_insert(old_commit, &old_commit_list);
@@ -749,7 +749,7 @@ int can_all_from_reach_with_flag(struct object_array *from,
 		}
 
 		list[nr_commits] = (struct commit *)from_one;
-		if (parse_commit(list[nr_commits]) ||
+		if (repo_parse_commit(the_repository, list[nr_commits]) ||
 		    commit_graph_generation(list[nr_commits]) < min_generation) {
 			result = 0;
 			goto cleanup;
@@ -784,7 +784,7 @@ int can_all_from_reach_with_flag(struct object_array *from,
 				if (!(parent->item->object.flags & assign_flag)) {
 					parent->item->object.flags |= assign_flag;
 
-					if (parse_commit(parent->item) ||
+					if (repo_parse_commit(the_repository, parent->item) ||
 					    parent->item->date < min_commit_date ||
 					    commit_graph_generation(parent->item) < min_generation)
 						continue;
@@ -826,7 +826,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
 	while (from_iter) {
 		add_object_array(&from_iter->item->object, NULL, &from_objs);
 
-		if (!parse_commit(from_iter->item)) {
+		if (!repo_parse_commit(the_repository, from_iter->item)) {
 			timestamp_t generation;
 			if (from_iter->item->date < min_commit_date)
 				min_commit_date = from_iter->item->date;
@@ -840,7 +840,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
 	}
 
 	while (to_iter) {
-		if (!parse_commit(to_iter->item)) {
+		if (!repo_parse_commit(the_repository, to_iter->item)) {
 			timestamp_t generation;
 			if (to_iter->item->date < min_commit_date)
 				min_commit_date = to_iter->item->date;
@@ -890,7 +890,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
 		timestamp_t generation;
 		struct commit *c = *item;
 
-		parse_commit(c);
+		repo_parse_commit(the_repository, c);
 		generation = commit_graph_generation(c);
 		if (generation < min_generation)
 			min_generation = generation;
@@ -905,7 +905,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
 		struct commit *c = *item;
 		if (!(c->object.flags & PARENT2)) {
 			c->object.flags |= PARENT2;
-			parse_commit(c);
+			repo_parse_commit(the_repository, c);
 
 			prio_queue_put(&queue, *item);
 		}
@@ -924,7 +924,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
 		for (parents = current->parents; parents; parents = parents->next) {
 			struct commit *p = parents->item;
 
-			parse_commit(p);
+			repo_parse_commit(the_repository, p);
 
 			if (commit_graph_generation(p) < min_generation)
 				continue;
diff --git a/commit.c b/commit.c
index 62682f55643..6036376d05a 100644
--- a/commit.c
+++ b/commit.c
@@ -83,7 +83,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
 	if (repo_get_oid_committish(the_repository, name, &oid))
 		return NULL;
 	commit = lookup_commit_reference(the_repository, &oid);
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		return NULL;
 	return commit;
 }
@@ -382,7 +382,7 @@ struct tree *repo_get_commit_tree(struct repository *r,
 
 struct object_id *get_commit_tree_oid(const struct commit *commit)
 {
-	struct tree *tree = get_commit_tree(commit);
+	struct tree *tree = repo_get_commit_tree(the_repository, commit);
 	return tree ? &tree->object.oid : NULL;
 }
 
@@ -555,7 +555,7 @@ int repo_parse_commit_gently(struct repository *r,
 
 void parse_commit_or_die(struct commit *item)
 {
-	if (parse_commit(item))
+	if (repo_parse_commit(the_repository, item))
 		die("unable to parse commit %s",
 		    item ? oid_to_hex(&item->object.oid) : "(null)");
 }
@@ -688,7 +688,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
 
 	while (parents) {
 		struct commit *commit = parents->item;
-		if (!parse_commit(commit) && !(commit->object.flags & mark)) {
+		if (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) {
 			commit->object.flags |= mark;
 			commit_list_insert_by_date(commit, list);
 		}
@@ -762,7 +762,8 @@ define_commit_slab(author_date_slab, timestamp_t);
 void record_author_date(struct author_date_slab *author_date,
 			struct commit *commit)
 {
-	const char *buffer = get_commit_buffer(commit, NULL);
+	const char *buffer = repo_get_commit_buffer(the_repository, commit,
+						    NULL);
 	struct ident_split ident;
 	const char *ident_line;
 	size_t ident_len;
@@ -782,7 +783,7 @@ void record_author_date(struct author_date_slab *author_date,
 	*(author_date_slab_at(author_date, commit)) = date;
 
 fail_exit:
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
 int compare_commits_by_author_date(const void *a_, const void *b_,
@@ -963,7 +964,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
 	commit = lookup_commit(the_repository, oid);
 	if (!commit ||
 	    (commit->object.flags & TMP_MARK) ||
-	    parse_commit(commit))
+	    repo_parse_commit(the_repository, commit))
 		return;
 
 	ALLOC_GROW(revs->commit, revs->nr + 1, revs->alloc);
@@ -1096,10 +1097,11 @@ int parse_signed_commit(const struct commit *commit,
 			const struct git_hash_algo *algop)
 {
 	unsigned long size;
-	const char *buffer = get_commit_buffer(commit, &size);
+	const char *buffer = repo_get_commit_buffer(the_repository, commit,
+						    &size);
 	int ret = parse_buffer_signed_by_header(buffer, size, payload, signature, algop);
 
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 	return ret;
 }
 
@@ -1318,9 +1320,10 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,
 {
 	struct commit_extra_header *extra = NULL;
 	unsigned long size;
-	const char *buffer = get_commit_buffer(commit, &size);
+	const char *buffer = repo_get_commit_buffer(the_repository, commit,
+						    &size);
 	extra = read_commit_extra_header_lines(buffer, size, exclude);
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 	return extra;
 }
 
diff --git a/commit.h b/commit.h
index cc2c5da7bdb..e98ee6e698e 100644
--- a/commit.h
+++ b/commit.h
@@ -109,11 +109,6 @@ static inline int repo_parse_commit_no_graph(struct repository *r,
 	return repo_parse_commit_internal(r, commit, 0, 0);
 }
 
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use)
-#define parse_commit(item) repo_parse_commit(the_repository, item)
-#endif
-
 void parse_commit_or_die(struct commit *item);
 
 struct buffer_slab;
@@ -140,9 +135,6 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,
 const void *repo_get_commit_buffer(struct repository *r,
 				   const struct commit *,
 				   unsigned long *size);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s)
-#endif
 
 /*
  * Tell the commit subsystem that we are done with a particular commit buffer.
@@ -153,9 +145,6 @@ const void *repo_get_commit_buffer(struct repository *r,
 void repo_unuse_commit_buffer(struct repository *r,
 			      const struct commit *,
 			      const void *buffer);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b)
-#endif
 
 /*
  * Free any cached object buffer associated with the commit.
@@ -163,7 +152,6 @@ void repo_unuse_commit_buffer(struct repository *r,
 void free_commit_buffer(struct parsed_object_pool *pool, struct commit *);
 
 struct tree *repo_get_commit_tree(struct repository *, const struct commit *);
-#define get_commit_tree(c) repo_get_commit_tree(the_repository, c)
 struct object_id *get_commit_tree_oid(const struct commit *);
 
 /*
@@ -206,16 +194,10 @@ void free_commit_list(struct commit_list *list);
 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 
 int has_non_ascii(const char *text);
-const char *logmsg_reencode(const struct commit *commit,
-			    char **commit_encoding,
-			    const char *output_encoding);
 const char *repo_logmsg_reencode(struct repository *r,
 				 const struct commit *commit,
 				 char **commit_encoding,
 				 const char *output_encoding);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define logmsg_reencode(c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out)
-#endif
 
 const char *skip_blank_lines(const char *msg);
 
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index 1ab63f0196b..0cdf3f46304 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -54,6 +54,25 @@
 |
 - in_merge_bases_many
 + repo_in_merge_bases_many
+// commit.h
+|
+- parse_commit_internal
++ repo_parse_commit_internal
+|
+- parse_commit
++ repo_parse_commit
+|
+- get_commit_buffer
++ repo_get_commit_buffer
+|
+- unuse_commit_buffer
++ repo_unuse_commit_buffer
+|
+- logmsg_reencode
++ repo_logmsg_reencode
+|
+- get_commit_tree
++ repo_get_commit_tree
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index e9209fc0cc4..bf19e6a2487 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,26 +5,7 @@
 @@
 @@
 (
-// commit.h
-- parse_commit_internal
-+ repo_parse_commit_internal
-|
-- parse_commit
-+ repo_parse_commit
-|
-- get_commit_buffer
-+ repo_get_commit_buffer
-|
-- unuse_commit_buffer
-+ repo_unuse_commit_buffer
-|
-- logmsg_reencode
-+ repo_logmsg_reencode
-|
-- get_commit_tree
-+ repo_get_commit_tree
 // diff.h
-|
 - diff_setup
 + repo_diff_setup
 // object-store.h
diff --git a/delta-islands.c b/delta-islands.c
index afdec0a878d..05448851ad3 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -506,8 +506,9 @@ void propagate_island_marks(struct commit *commit)
 		struct commit_list *p;
 		struct island_bitmap *root_marks = kh_value(island_marks, pos);
 
-		parse_commit(commit);
-		set_island_marks(&get_commit_tree(commit)->object, root_marks);
+		repo_parse_commit(the_repository, commit);
+		set_island_marks(&repo_get_commit_tree(the_repository, commit)->object,
+				 root_marks);
 		for (p = commit->parents; p; p = p->next)
 			set_island_marks(&p->item->object, root_marks);
 	}
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index e8e2d4ea0d0..a5de91ba22c 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -271,9 +271,10 @@ static void record_person_from_buf(int which, struct string_list *people,
 static void record_person(int which, struct string_list *people,
 			  struct commit *commit)
 {
-	const char *buffer = get_commit_buffer(commit, NULL);
+	const char *buffer = repo_get_commit_buffer(the_repository, commit,
+						    NULL);
 	record_person_from_buf(which, people, buffer);
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
 static int cmp_string_list_util_as_integral(const void *a_, const void *b_)
diff --git a/fsck.c b/fsck.c
index 2b18717ee80..807a84971a2 100644
--- a/fsck.c
+++ b/fsck.c
@@ -353,7 +353,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
 	int result;
 	const char *name;
 
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		return -1;
 
 	name = fsck_get_object_name(options, &commit->object.oid);
@@ -361,7 +361,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
 		fsck_put_object_name(options, get_commit_tree_oid(commit),
 				     "%s:", name);
 
-	result = options->walk((struct object *)get_commit_tree(commit),
+	result = options->walk((struct object *) repo_get_commit_tree(the_repository, commit),
 			       OBJ_TREE, data, options);
 	if (result < 0)
 		return result;
diff --git a/http-push.c b/http-push.c
index ceab00bd901..45d5cc0972f 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1331,7 +1331,8 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
 	int count = 0;
 
 	while ((commit = get_revision(revs)) != NULL) {
-		p = process_tree(get_commit_tree(commit), p);
+		p = process_tree(repo_get_commit_tree(the_repository, commit),
+				 p);
 		commit->object.flags |= LOCAL;
 		if (!(commit->object.flags & UNINTERESTING))
 			count += add_send_request(&commit->object, lock);
diff --git a/list-objects.c b/list-objects.c
index 7528fe1db2c..5550b3aafeb 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -227,7 +227,8 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
 		struct commit *parent = parents->item;
 		if (!(parent->object.flags & UNINTERESTING))
 			continue;
-		mark_tree_uninteresting(revs->repo, get_commit_tree(parent));
+		mark_tree_uninteresting(revs->repo,
+					repo_get_commit_tree(the_repository, parent));
 		if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
 			parent->object.flags |= SHOWN;
 			show_edge(parent);
@@ -244,7 +245,8 @@ static void add_edge_parents(struct commit *commit,
 
 	for (parents = commit->parents; parents; parents = parents->next) {
 		struct commit *parent = parents->item;
-		struct tree *tree = get_commit_tree(parent);
+		struct tree *tree = repo_get_commit_tree(the_repository,
+							 parent);
 
 		if (!tree)
 			continue;
@@ -275,7 +277,8 @@ void mark_edges_uninteresting(struct rev_info *revs,
 
 		for (list = revs->commits; list; list = list->next) {
 			struct commit *commit = list->item;
-			struct tree *tree = get_commit_tree(commit);
+			struct tree *tree = repo_get_commit_tree(the_repository,
+								 commit);
 
 			if (commit->object.flags & UNINTERESTING)
 				tree->object.flags |= UNINTERESTING;
@@ -291,7 +294,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
 			struct commit *commit = list->item;
 			if (commit->object.flags & UNINTERESTING) {
 				mark_tree_uninteresting(revs->repo,
-							get_commit_tree(commit));
+							repo_get_commit_tree(the_repository, commit));
 				if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
 					commit->object.flags |= SHOWN;
 					show_edge(commit);
@@ -309,7 +312,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
 			if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
 				continue;
 			mark_tree_uninteresting(revs->repo,
-						get_commit_tree(commit));
+						repo_get_commit_tree(the_repository, commit));
 			if (!(obj->flags & SHOWN)) {
 				obj->flags |= SHOWN;
 				show_edge(commit);
@@ -376,8 +379,9 @@ static void do_traverse(struct traversal_context *ctx)
 		 */
 		if (!ctx->revs->tree_objects)
 			; /* do not bother loading tree */
-		else if (get_commit_tree(commit)) {
-			struct tree *tree = get_commit_tree(commit);
+		else if (repo_get_commit_tree(the_repository, commit)) {
+			struct tree *tree = repo_get_commit_tree(the_repository,
+								 commit);
 			tree->object.flags |= NOT_USER_GIVEN;
 			add_pending_tree(ctx->revs, tree);
 		} else if (commit->object.parsed) {
diff --git a/merge-recursive.c b/merge-recursive.c
index 9771ef540c4..75fa0ef3183 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3797,7 +3797,7 @@ static struct commit *get_ref(struct repository *repo,
 		return make_virtual_commit(repo, (struct tree*)object, name);
 	if (object->type != OBJ_COMMIT)
 		return NULL;
-	if (parse_commit((struct commit *)object))
+	if (repo_parse_commit(the_repository, (struct commit *)object))
 		return NULL;
 	return (struct commit *)object;
 }
diff --git a/negotiator/default.c b/negotiator/default.c
index b7e79feaf04..658d9dd6b95 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -25,7 +25,7 @@ static void rev_list_push(struct negotiation_state *ns,
 	if (!(commit->object.flags & mark)) {
 		commit->object.flags |= mark;
 
-		if (parse_commit(commit))
+		if (repo_parse_commit(the_repository, commit))
 			return;
 
 		prio_queue_put(&ns->rev_list, commit);
@@ -69,7 +69,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit,
 			if (!ancestors_only && !(o->flags & POPPED))
 				ns->non_common_revs--;
 			if (!o->parsed && !dont_parse)
-				if (parse_commit(commit))
+				if (repo_parse_commit(the_repository, commit))
 					return;
 
 			for (parents = commit->parents;
@@ -96,7 +96,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns)
 			return NULL;
 
 		commit = prio_queue_get(&ns->rev_list);
-		parse_commit(commit);
+		repo_parse_commit(the_repository, commit);
 		parents = commit->parents;
 
 		commit->object.flags |= POPPED;
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index 0f5ac48e876..594639b25a0 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -183,7 +183,7 @@ static const struct object_id *get_rev(struct data *data)
 		if (!(commit->object.flags & COMMON) && !entry->ttl)
 			to_send = commit;
 
-		parse_commit(commit);
+		repo_parse_commit(the_repository, commit);
 		for (p = commit->parents; p; p = p->next)
 			parent_pushed |= push_parent(data, entry, p->item);
 
diff --git a/notes-merge.c b/notes-merge.c
index fca9422a294..df1a16ac66c 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -678,7 +678,8 @@ int notes_merge_commit(struct notes_merge_options *o,
 	DIR *dir;
 	struct dirent *e;
 	struct strbuf path = STRBUF_INIT;
-	const char *buffer = get_commit_buffer(partial_commit, NULL);
+	const char *buffer = repo_get_commit_buffer(the_repository,
+						    partial_commit, NULL);
 	const char *msg = strstr(buffer, "\n\n");
 	int baselen;
 
@@ -725,7 +726,7 @@ int notes_merge_commit(struct notes_merge_options *o,
 
 	create_notes_commit(o->repo, partial_tree, partial_commit->parents, msg,
 			    strlen(msg), result_oid);
-	unuse_commit_buffer(partial_commit, buffer);
+	repo_unuse_commit_buffer(the_repository, partial_commit, buffer);
 	if (o->verbosity >= 4)
 		printf("Finalized notes merge commit: %s\n",
 			oid_to_hex(result_oid));
diff --git a/notes-utils.c b/notes-utils.c
index d7d18e30f5a..0550cfded86 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -23,7 +23,7 @@ void create_notes_commit(struct repository *r,
 		struct object_id parent_oid;
 		if (!read_ref(t->ref, &parent_oid)) {
 			struct commit *parent = lookup_commit(r, &parent_oid);
-			if (parse_commit(parent))
+			if (repo_parse_commit(the_repository, parent))
 				die("Failed to find/parse commit %s", t->ref);
 			commit_list_insert(parent, &parents);
 		}
diff --git a/object-name.c b/object-name.c
index 21e8f67489e..2926f26251f 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1036,7 +1036,7 @@ static enum get_oid_result get_parent(struct repository *r,
 	if (ret)
 		return ret;
 	commit = lookup_commit_reference(r, &oid);
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		return MISSING_OBJECT;
 	if (!idx) {
 		oidcpy(result, &commit->object.oid);
@@ -1070,7 +1070,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r,
 		return MISSING_OBJECT;
 
 	while (generation--) {
-		if (parse_commit(commit) || !commit->parents)
+		if (repo_parse_commit(the_repository, commit) || !commit->parents)
 			return MISSING_OBJECT;
 		commit = commit->parents->item;
 	}
@@ -1361,10 +1361,10 @@ static int get_oid_oneline(struct repository *r,
 		commit = pop_most_recent_commit(&list, ONELINE_SEEN);
 		if (!parse_object(r, &commit->object.oid))
 			continue;
-		buf = get_commit_buffer(commit, NULL);
+		buf = repo_get_commit_buffer(the_repository, commit, NULL);
 		p = strstr(buf, "\n\n");
 		matches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));
-		unuse_commit_buffer(commit, buf);
+		repo_unuse_commit_buffer(the_repository, commit, buf);
 
 		if (matches) {
 			oidcpy(oid, &commit->object.oid);
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index cfa67a510fd..84b61328931 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -425,7 +425,8 @@ static int fill_bitmap_commit(struct bb_commit *ent,
 		if (!found)
 			return -1;
 		bitmap_set(ent->bitmap, pos);
-		prio_queue_put(tree_queue, get_commit_tree(c));
+		prio_queue_put(tree_queue,
+			       repo_get_commit_tree(the_repository, c));
 
 		for (p = c->parents; p; p = p->next) {
 			pos = find_object_pos(&p->item->object.oid, &found);
diff --git a/pretty.c b/pretty.c
index 1e1e21878c8..7e1614f67fe 100644
--- a/pretty.c
+++ b/pretty.c
@@ -2204,7 +2204,8 @@ void pretty_print_commit(struct pretty_print_context *pp,
 	}
 
 	encoding = get_log_output_encoding();
-	msg = reencoded = logmsg_reencode(commit, NULL, encoding);
+	msg = reencoded = repo_logmsg_reencode(the_repository, commit, NULL,
+					       encoding);
 
 	if (pp->fmt == CMIT_FMT_ONELINE || cmit_fmt_is_mail(pp->fmt))
 		indent = 0;
@@ -2261,7 +2262,7 @@ void pretty_print_commit(struct pretty_print_context *pp,
 	if (cmit_fmt_is_mail(pp->fmt) && sb->len <= beginning_of_body)
 		strbuf_addch(sb, '\n');
 
-	unuse_commit_buffer(commit, reencoded);
+	repo_unuse_commit_buffer(the_repository, commit, reencoded);
 }
 
 void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
diff --git a/reflog.c b/reflog.c
index 04630f56ec6..6e8362e7a2f 100644
--- a/reflog.c
+++ b/reflog.c
@@ -186,7 +186,7 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb)
 		struct commit *commit = pop_commit(&pending);
 		if (commit->object.flags & REACHABLE)
 			continue;
-		if (parse_commit(commit))
+		if (repo_parse_commit(the_repository, commit))
 			continue;
 		commit->object.flags |= REACHABLE;
 		if (commit->date < expire_limit) {
diff --git a/revision.c b/revision.c
index c2b7b2f1073..79e78b6f7e9 100644
--- a/revision.c
+++ b/revision.c
@@ -778,8 +778,8 @@ static int check_maybe_different_in_bloom_filter(struct rev_info *revs,
 static int rev_compare_tree(struct rev_info *revs,
 			    struct commit *parent, struct commit *commit, int nth_parent)
 {
-	struct tree *t1 = get_commit_tree(parent);
-	struct tree *t2 = get_commit_tree(commit);
+	struct tree *t1 = repo_get_commit_tree(the_repository, parent);
+	struct tree *t2 = repo_get_commit_tree(the_repository, commit);
 	int bloom_ret = 1;
 
 	if (!t1)
@@ -825,7 +825,7 @@ static int rev_compare_tree(struct rev_info *revs,
 
 static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
 {
-	struct tree *t1 = get_commit_tree(commit);
+	struct tree *t1 = repo_get_commit_tree(the_repository, commit);
 
 	if (!t1)
 		return 0;
@@ -963,7 +963,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
 	if (!revs->prune)
 		return;
 
-	if (!get_commit_tree(commit))
+	if (!repo_get_commit_tree(the_repository, commit))
 		return;
 
 	if (!commit->parents) {
@@ -3878,7 +3878,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
 	 * in it.
 	 */
 	encoding = get_log_output_encoding();
-	message = logmsg_reencode(commit, NULL, encoding);
+	message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
 
 	/* Copy the commit to temporary if we are using "fake" headers */
 	if (buf.len)
@@ -3914,7 +3914,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
 		retval = grep_buffer(&opt->grep_filter,
 				     (char *)message, strlen(message));
 	strbuf_release(&buf);
-	unuse_commit_buffer(commit, message);
+	repo_unuse_commit_buffer(the_repository, commit, message);
 	return retval;
 }
 
diff --git a/sequencer.c b/sequencer.c
index d97923883ff..592b3d2875a 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -428,7 +428,8 @@ static int get_message(struct commit *commit, struct commit_message *out)
 	const char *abbrev, *subject;
 	int subject_len;
 
-	out->message = logmsg_reencode(commit, NULL, get_commit_output_encoding());
+	out->message = repo_logmsg_reencode(the_repository, commit, NULL,
+					    get_commit_output_encoding());
 	abbrev = short_commit_name(commit);
 
 	subject_len = find_commit_subject(out->message, &subject);
@@ -445,7 +446,7 @@ static void free_message(struct commit *commit, struct commit_message *msg)
 	free(msg->parent_label);
 	free(msg->label);
 	free(msg->subject);
-	unuse_commit_buffer(commit, msg->message);
+	repo_unuse_commit_buffer(the_repository, commit, msg->message);
 }
 
 static void print_advice(struct repository *r, int show_hint,
@@ -693,8 +694,8 @@ static int do_recursive_merge(struct repository *r,
 	o.show_rename_progress = 1;
 
 	head_tree = parse_tree_indirect(head);
-	next_tree = next ? get_commit_tree(next) : empty_tree(r);
-	base_tree = base ? get_commit_tree(base) : empty_tree(r);
+	next_tree = next ? repo_get_commit_tree(the_repository, next) : empty_tree(r);
+	base_tree = base ? repo_get_commit_tree(the_repository, base) : empty_tree(r);
 
 	for (i = 0; i < opts->xopts_nr; i++)
 		parse_merge_opt(&o, opts->xopts[i]);
@@ -772,7 +773,7 @@ static int is_index_unchanged(struct repository *r)
 	 * the commit is invalid, parse_commit() will complain.  So
 	 * there is nothing for us to say here.  Just return failure.
 	 */
-	if (parse_commit(head_commit))
+	if (repo_parse_commit(the_repository, head_commit))
 		return -1;
 
 	if (!(cache_tree_oid = get_cache_tree_oid(istate)))
@@ -1337,7 +1338,7 @@ void print_commit_summary(struct repository *r,
 	commit = lookup_commit(r, oid);
 	if (!commit)
 		die(_("couldn't look up newly created commit"));
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		die(_("could not parse newly created commit"));
 
 	strbuf_addstr(&format, "format:%h] %s");
@@ -1417,7 +1418,7 @@ static int parse_head(struct repository *r, struct commit **head)
 			warning(_("HEAD %s is not a commit!"),
 				oid_to_hex(&oid));
 		}
-		if (parse_commit(current_head))
+		if (repo_parse_commit(the_repository, current_head))
 			return error(_("could not parse HEAD commit"));
 	}
 	*head = current_head;
@@ -1460,8 +1461,9 @@ static int try_to_commit(struct repository *r,
 	if (flags & AMEND_MSG) {
 		const char *exclude_gpgsig[] = { "gpgsig", "gpgsig-sha256", NULL };
 		const char *out_enc = get_commit_output_encoding();
-		const char *message = logmsg_reencode(current_head, NULL,
-						      out_enc);
+		const char *message = repo_logmsg_reencode(the_repository,
+							   current_head, NULL,
+							   out_enc);
 
 		if (!msg) {
 			const char *orig_message = NULL;
@@ -1472,7 +1474,8 @@ static int try_to_commit(struct repository *r,
 			hook_commit = "HEAD";
 		}
 		author = amend_author = get_author(message);
-		unuse_commit_buffer(current_head, message);
+		repo_unuse_commit_buffer(the_repository, current_head,
+					 message);
 		if (!author) {
 			res = error(_("unable to parse commit author"));
 			goto out;
@@ -1669,12 +1672,12 @@ static int is_original_commit_empty(struct commit *commit)
 {
 	const struct object_id *ptree_oid;
 
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		return error(_("could not parse commit %s"),
 			     oid_to_hex(&commit->object.oid));
 	if (commit->parents) {
 		struct commit *parent = commit->parents->item;
-		if (parse_commit(parent))
+		if (repo_parse_commit(the_repository, parent))
 			return error(_("could not parse parent commit %s"),
 				oid_to_hex(&parent->object.oid));
 		ptree_oid = get_commit_tree_oid(parent);
@@ -2002,13 +2005,14 @@ static int update_squash_messages(struct repository *r,
 			return error(_("need a HEAD to fixup"));
 		if (!(head_commit = lookup_commit_reference(r, &head)))
 			return error(_("could not read HEAD"));
-		if (!(head_message = logmsg_reencode(head_commit, NULL, encoding)))
+		if (!(head_message = repo_logmsg_reencode(the_repository, head_commit, NULL, encoding)))
 			return error(_("could not read HEAD's commit message"));
 
 		find_commit_subject(head_message, &body);
 		if (command == TODO_FIXUP && !flag && write_message(body, strlen(body),
 							rebase_path_fixup_msg(), 0) < 0) {
-			unuse_commit_buffer(head_commit, head_message);
+			repo_unuse_commit_buffer(the_repository, head_commit,
+						 head_message);
 			return error(_("cannot write '%s'"), rebase_path_fixup_msg());
 		}
 		strbuf_addf(&buf, "%c ", comment_line_char);
@@ -2023,10 +2027,11 @@ static int update_squash_messages(struct repository *r,
 		else
 			strbuf_addstr(&buf, body);
 
-		unuse_commit_buffer(head_commit, head_message);
+		repo_unuse_commit_buffer(the_repository, head_commit,
+					 head_message);
 	}
 
-	if (!(message = logmsg_reencode(commit, NULL, encoding)))
+	if (!(message = repo_logmsg_reencode(the_repository, commit, NULL, encoding)))
 		return error(_("could not read commit message of %s"),
 			     oid_to_hex(&commit->object.oid));
 	find_commit_subject(message, &body);
@@ -2041,7 +2046,7 @@ static int update_squash_messages(struct repository *r,
 		strbuf_add_commented_lines(&buf, body, strlen(body));
 	} else
 		return error(_("unknown command: %d"), command);
-	unuse_commit_buffer(commit, message);
+	repo_unuse_commit_buffer(the_repository, commit, message);
 
 	if (!res)
 		res = write_message(buf.buf, buf.len, rebase_path_squash_msg(),
@@ -2215,7 +2220,7 @@ static int do_pick_commit(struct repository *r,
 		msg_file = NULL;
 		goto fast_forward_edit;
 	}
-	if (parent && parse_commit(parent) < 0)
+	if (parent && repo_parse_commit(the_repository, parent) < 0)
 		/* TRANSLATORS: The first %s will be a "todo" command like
 		   "revert" or "pick", the second %s a SHA1. */
 		return error(_("%s: cannot parse parent commit %s"),
@@ -3123,7 +3128,9 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
 
 	while ((commit = get_revision(opts->revs))) {
 		struct todo_item *item = append_new_todo(todo_list);
-		const char *commit_buffer = logmsg_reencode(commit, NULL, encoding);
+		const char *commit_buffer = repo_logmsg_reencode(the_repository,
+								 commit, NULL,
+								 encoding);
 		const char *subject;
 		int subject_len;
 
@@ -3135,7 +3142,8 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
 		subject_len = find_commit_subject(commit_buffer, &subject);
 		strbuf_addf(&todo_list->buf, "%s %s %.*s\n", command_string,
 			short_commit_name(commit), subject_len, subject);
-		unuse_commit_buffer(commit, commit_buffer);
+		repo_unuse_commit_buffer(the_repository, commit,
+					 commit_buffer);
 	}
 
 	if (!todo_list->nr)
@@ -3519,10 +3527,13 @@ static int make_patch(struct repository *r,
 	strbuf_addf(&buf, "%s/message", get_dir(opts));
 	if (!file_exists(buf.buf)) {
 		const char *encoding = get_commit_output_encoding();
-		const char *commit_buffer = logmsg_reencode(commit, NULL, encoding);
+		const char *commit_buffer = repo_logmsg_reencode(the_repository,
+								 commit, NULL,
+								 encoding);
 		find_commit_subject(commit_buffer, &subject);
 		res |= write_message(subject, strlen(subject), buf.buf, 1);
-		unuse_commit_buffer(commit, commit_buffer);
+		repo_unuse_commit_buffer(the_repository, commit,
+					 commit_buffer);
 	}
 	strbuf_release(&buf);
 	release_revisions(&log_tree_opt);
@@ -3989,7 +4000,9 @@ static int do_merge(struct repository *r,
 
 	if (commit) {
 		const char *encoding = get_commit_output_encoding();
-		const char *message = logmsg_reencode(commit, NULL, encoding);
+		const char *message = repo_logmsg_reencode(the_repository,
+							   commit, NULL,
+							   encoding);
 		const char *body;
 		int len;
 
@@ -4002,7 +4015,7 @@ static int do_merge(struct repository *r,
 		find_commit_subject(message, &body);
 		len = strlen(body);
 		ret = write_message(body, len, git_path_merge_msg(r), 0);
-		unuse_commit_buffer(commit, message);
+		repo_unuse_commit_buffer(the_repository, commit, message);
 		if (ret) {
 			error_errno(_("could not write '%s'"),
 				    git_path_merge_msg(r));
@@ -4585,7 +4598,7 @@ static int stopped_at_head(struct repository *r)
 
 	if (repo_get_oid(the_repository, "HEAD", &head) ||
 	    !(commit = lookup_commit(r, &head)) ||
-	    parse_commit(commit) || get_message(commit, &message))
+	    repo_parse_commit(the_repository, commit) || get_message(commit, &message))
 		fprintf(stderr, _("Stopped at HEAD\n"));
 	else {
 		fprintf(stderr, _("Stopped at %s\n"), message.label);
@@ -5042,13 +5055,15 @@ static int commit_staged_changes(struct repository *r,
 				const char *encoding = get_commit_output_encoding();
 
 				if (parse_head(r, &commit) ||
-				    !(p = logmsg_reencode(commit, NULL, encoding)) ||
+				    !(p = repo_logmsg_reencode(the_repository, commit, NULL, encoding)) ||
 				    write_message(p, strlen(p), path, 0)) {
-					unuse_commit_buffer(commit, p);
+					repo_unuse_commit_buffer(the_repository,
+								 commit, p);
 					return error(_("could not write file: "
 						       "'%s'"), path);
 				}
-				unuse_commit_buffer(commit, p);
+				repo_unuse_commit_buffer(the_repository,
+							 commit, p);
 			}
 		}
 
@@ -5925,7 +5940,7 @@ static int skip_unnecessary_picks(struct repository *r,
 			continue;
 		if (item->command != TODO_PICK)
 			break;
-		if (parse_commit(item->commit)) {
+		if (repo_parse_commit(the_repository, item->commit)) {
 			return error(_("could not parse commit '%s'"),
 				oid_to_hex(&item->commit->object.oid));
 		}
@@ -6258,12 +6273,15 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
 			return error(_("the script was already rearranged."));
 		}
 
-		parse_commit(item->commit);
-		commit_buffer = logmsg_reencode(item->commit, NULL, "UTF-8");
+		repo_parse_commit(the_repository, item->commit);
+		commit_buffer = repo_logmsg_reencode(the_repository,
+						     item->commit, NULL,
+						     "UTF-8");
 		find_commit_subject(commit_buffer, &subject);
 		format_subject(&buf, subject, " ");
 		subject = subjects[i] = strbuf_detach(&buf, &subject_len);
-		unuse_commit_buffer(item->commit, commit_buffer);
+		repo_unuse_commit_buffer(the_repository, item->commit,
+					 commit_buffer);
 		if (skip_fixupish(subject, &p)) {
 			struct commit *commit2;
 
diff --git a/shallow.c b/shallow.c
index 0fcdfd7d35a..1a2b159fd4e 100644
--- a/shallow.c
+++ b/shallow.c
@@ -247,7 +247,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
 		struct commit *c = p->item;
 		struct commit_list *parent;
 
-		if (parse_commit(c))
+		if (repo_parse_commit(the_repository, c))
 			die("unable to parse commit %s",
 			    oid_to_hex(&c->object.oid));
 
@@ -583,7 +583,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
 		if (c->object.flags & BOTTOM)
 			continue;
 
-		if (parse_commit(c))
+		if (repo_parse_commit(the_repository, c))
 			die("unable to parse commit %s",
 			    oid_to_hex(&c->object.oid));
 
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index 5d1284328d0..214612846ab 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -65,7 +65,8 @@ static struct commit *create_commit(struct tree *tree,
 	struct commit_extra_header *extra;
 	struct strbuf msg = STRBUF_INIT;
 	const char *out_enc = get_commit_output_encoding();
-	const char *message = logmsg_reencode(based_on, NULL, out_enc);
+	const char *message = repo_logmsg_reencode(the_repository, based_on,
+						   NULL, out_enc);
 	const char *orig_message = NULL;
 	const char *exclude_gpgsig[] = { "gpgsig", NULL };
 
@@ -156,7 +157,7 @@ int cmd__fast_rebase(int argc, const char **argv)
 	memset(&result, 0, sizeof(result));
 	merge_opt.show_rename_progress = 1;
 	merge_opt.branch1 = "HEAD";
-	head_tree = get_commit_tree(onto);
+	head_tree = repo_get_commit_tree(the_repository, onto);
 	result.tree = head_tree;
 	last_commit = onto;
 	while ((commit = get_revision(&revs))) {
@@ -167,8 +168,8 @@ int cmd__fast_rebase(int argc, const char **argv)
 		assert(commit->parents && !commit->parents->next);
 		base = commit->parents->item;
 
-		next_tree = get_commit_tree(commit);
-		base_tree = get_commit_tree(base);
+		next_tree = repo_get_commit_tree(the_repository, commit);
+		base_tree = repo_get_commit_tree(the_repository, base);
 
 		merge_opt.branch2 = short_commit_name(commit);
 		merge_opt.ancestor = xstrfmt("parent of %s", merge_opt.branch2);
diff --git a/tree.c b/tree.c
index 410e3b477e5..f0742f4167b 100644
--- a/tree.c
+++ b/tree.c
@@ -58,7 +58,7 @@ int read_tree_at(struct repository *r,
 				    oid_to_hex(&entry.oid),
 				    base->buf, entry.path);
 
-			if (parse_commit(commit))
+			if (repo_parse_commit(the_repository, commit))
 				die("Invalid commit %s in submodule path %s%s",
 				    oid_to_hex(&entry.oid),
 				    base->buf, entry.path);
diff --git a/walker.c b/walker.c
index 99d0e0eae04..98d65a559b4 100644
--- a/walker.c
+++ b/walker.c
@@ -79,7 +79,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
 {
 	struct commit_list *parents;
 
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		return -1;
 
 	while (complete && complete->item->date >= commit->date) {
@@ -93,7 +93,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
 
 	walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));
 
-	if (process(walker, &get_commit_tree(commit)->object))
+	if (process(walker, &repo_get_commit_tree(the_repository, commit)->object))
 		return -1;
 
 	for (parents = commit->parents; parents; parents = parents->next) {
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 08/17] cocci: apply the "diff.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (6 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 07/17] cocci: apply the "commit.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 09/17] cocci: apply the "object-store.h" " Ævar Arnfjörð Bjarmason
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"diff.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/log.c                                   | 2 +-
 builtin/rebase.c                                | 2 +-
 builtin/stash.c                                 | 2 +-
 contrib/coccinelle/the_repository.cocci         | 4 ++++
 contrib/coccinelle/the_repository.pending.cocci | 4 ----
 diff.h                                          | 3 ---
 log-tree.c                                      | 2 +-
 range-diff.c                                    | 2 +-
 8 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index f249aca049a..b76a1c82d8f 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1371,7 +1371,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
 			.other_arg = &other_arg
 		};
 
-		diff_setup(&opts);
+		repo_diff_setup(the_repository, &opts);
 		opts.file = rev->diffopt.file;
 		opts.use_color = rev->diffopt.use_color;
 		diff_setup_done(&opts);
diff --git a/builtin/rebase.c b/builtin/rebase.c
index eba48bffaad..76cce94373e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1786,7 +1786,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		}
 
 		/* We want color (if set), but no pager */
-		diff_setup(&opts);
+		repo_diff_setup(the_repository, &opts);
 		opts.stat_width = -1; /* use full terminal width */
 		opts.stat_graph_width = -1; /* respect statGraphWidth config */
 		opts.output_format |=
diff --git a/builtin/stash.c b/builtin/stash.c
index ed1275829e7..6c062e52048 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -427,7 +427,7 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)
 	 * to the index before a merge was run) and the current index
 	 * (reflecting the changes brought in by the merge).
 	 */
-	diff_setup(&diff_opts);
+	repo_diff_setup(the_repository, &diff_opts);
 	diff_opts.flags.recursive = 1;
 	diff_opts.detect_rename = 0;
 	diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index 0cdf3f46304..3c0bd8781e7 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -73,6 +73,10 @@
 |
 - get_commit_tree
 + repo_get_commit_tree
+// diff.h
+|
+- diff_setup
++ repo_diff_setup
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index bf19e6a2487..00461ee86b3 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// diff.h
-- diff_setup
-+ repo_diff_setup
 // object-store.h
-|
 - read_object_file
 + repo_read_object_file
 |
diff --git a/diff.h b/diff.h
index 8d770b1d579..8b510eb579d 100644
--- a/diff.h
+++ b/diff.h
@@ -535,9 +535,6 @@ int git_diff_basic_config(const char *var, const char *value, void *cb);
 int git_diff_heuristic_config(const char *var, const char *value, void *cb);
 void init_diff_ui_defaults(void);
 int git_diff_ui_config(const char *var, const char *value, void *cb);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define diff_setup(diffopts) repo_diff_setup(the_repository, diffopts)
-#endif
 void repo_diff_setup(struct repository *, struct diff_options *);
 struct option *add_diff_options(const struct option *, struct diff_options *);
 int diff_opt_parse(struct diff_options *, const char **, int, const char *);
diff --git a/log-tree.c b/log-tree.c
index 4bebb86ecac..1bd4d6ab008 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -849,7 +849,7 @@ void show_log(struct rev_info *opt)
 		 * Pass minimum required diff-options to range-diff; others
 		 * can be added later if deemed desirable.
 		 */
-		diff_setup(&opts);
+		repo_diff_setup(the_repository, &opts);
 		opts.file = opt->diffopt.file;
 		opts.use_color = opt->diffopt.use_color;
 		diff_setup_done(&opts);
diff --git a/range-diff.c b/range-diff.c
index 5bcf966f6c5..15d0bc35a87 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -485,7 +485,7 @@ static void output(struct string_list *a, struct string_list *b,
 	if (range_diff_opts->diffopt)
 		memcpy(&opts, range_diff_opts->diffopt, sizeof(opts));
 	else
-		diff_setup(&opts);
+		repo_diff_setup(the_repository, &opts);
 
 	opts.no_free = 1;
 	if (!opts.output_format)
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 09/17] cocci: apply the "object-store.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (7 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 08/17] cocci: apply the "diff.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 10/17] cocci: apply the "pretty.h" " Ævar Arnfjörð Bjarmason
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"object-store.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 apply.c                                       |  9 +++++---
 archive.c                                     |  2 +-
 bisect.c                                      |  5 ++--
 blame.c                                       | 11 +++++----
 builtin/cat-file.c                            | 23 +++++++++++--------
 builtin/clone.c                               |  6 ++---
 builtin/difftool.c                            |  3 ++-
 builtin/fast-export.c                         |  5 ++--
 builtin/fast-import.c                         |  7 +++---
 builtin/fetch.c                               | 12 +++++-----
 builtin/grep.c                                |  6 +++--
 builtin/index-pack.c                          |  9 +++++---
 builtin/log.c                                 |  2 +-
 builtin/merge-tree.c                          |  9 +++++---
 builtin/mktag.c                               |  3 ++-
 builtin/notes.c                               |  7 +++---
 builtin/pack-objects.c                        | 22 ++++++++++++------
 builtin/receive-pack.c                        |  2 +-
 builtin/remote.c                              |  2 +-
 builtin/show-ref.c                            |  2 +-
 builtin/tag.c                                 |  4 ++--
 builtin/unpack-file.c                         |  2 +-
 builtin/unpack-objects.c                      |  5 ++--
 bulk-checkin.c                                |  2 +-
 bundle.c                                      |  2 +-
 cache-tree.c                                  |  8 +++----
 combine-diff.c                                |  2 +-
 commit.c                                      |  3 ++-
 contrib/coccinelle/the_repository.cocci       | 10 ++++++++
 .../coccinelle/the_repository.pending.cocci   | 10 --------
 dir.c                                         |  2 +-
 entry.c                                       |  3 ++-
 fetch-pack.c                                  |  8 +++----
 fmt-merge-msg.c                               |  3 ++-
 fsck.c                                        |  2 +-
 http-push.c                                   | 11 +++++----
 http-walker.c                                 |  4 ++--
 list-objects.c                                |  2 +-
 mailmap.c                                     |  2 +-
 match-trees.c                                 |  4 ++--
 merge-blobs.c                                 |  6 +++--
 merge-ort.c                                   |  2 +-
 merge-recursive.c                             |  5 ++--
 notes-cache.c                                 |  2 +-
 notes-merge.c                                 |  2 +-
 notes.c                                       | 12 ++++++----
 object-file.c                                 |  2 +-
 object-store.h                                |  7 ------
 read-cache.c                                  |  5 ++--
 reflog.c                                      |  5 ++--
 remote.c                                      |  2 +-
 rerere.c                                      |  5 ++--
 send-pack.c                                   |  6 ++---
 shallow.c                                     |  6 ++---
 submodule-config.c                            |  3 ++-
 tag.c                                         |  5 ++--
 tree.c                                        |  3 ++-
 upload-pack.c                                 |  8 +++----
 walker.c                                      |  2 +-
 xdiff-interface.c                             |  2 +-
 60 files changed, 184 insertions(+), 142 deletions(-)

diff --git a/apply.c b/apply.c
index 57f45cedd2b..eb71586a372 100644
--- a/apply.c
+++ b/apply.c
@@ -3201,7 +3201,8 @@ static int apply_binary(struct apply_state *state,
 		unsigned long size;
 		char *result;
 
-		result = read_object_file(&oid, &type, &size);
+		result = repo_read_object_file(the_repository, &oid, &type,
+					       &size);
 		if (!result)
 			return error(_("the necessary postimage %s for "
 				       "'%s' cannot be read"),
@@ -3264,7 +3265,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
 		unsigned long sz;
 		char *result;
 
-		result = read_object_file(oid, &type, &sz);
+		result = repo_read_object_file(the_repository, oid, &type,
+					       &sz);
 		if (!result)
 			return -1;
 		/* XXX read_sha1_file NUL-terminates */
@@ -3492,7 +3494,8 @@ static int resolve_to(struct image *image, const struct object_id *result_id)
 
 	clear_image(image);
 
-	image->buf = read_object_file(result_id, &type, &size);
+	image->buf = repo_read_object_file(the_repository, result_id, &type,
+					   &size);
 	if (!image->buf || type != OBJ_BLOB)
 		die("unable to read blob object %s", oid_to_hex(result_id));
 	image->len = size;
diff --git a/archive.c b/archive.c
index 732e2100544..0b48de00634 100644
--- a/archive.c
+++ b/archive.c
@@ -84,7 +84,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
 			       (args->tree ? &args->tree->object.oid : NULL), oid);
 
 	path += args->baselen;
-	buffer = read_object_file(oid, type, sizep);
+	buffer = repo_read_object_file(the_repository, oid, type, sizep);
 	if (buffer && S_ISREG(mode)) {
 		struct strbuf buf = STRBUF_INIT;
 		size_t size = 0;
diff --git a/bisect.c b/bisect.c
index 3088516e174..db7aa2032e1 100644
--- a/bisect.c
+++ b/bisect.c
@@ -148,8 +148,9 @@ static void show_list(const char *debug, int counted, int nr,
 		unsigned commit_flags = commit->object.flags;
 		enum object_type type;
 		unsigned long size;
-		char *buf = read_object_file(&commit->object.oid, &type,
-					     &size);
+		char *buf = repo_read_object_file(the_repository,
+						  &commit->object.oid, &type,
+						  &size);
 		const char *subject_start;
 		int subject_len;
 
diff --git a/blame.c b/blame.c
index af2b67c0847..7009a3379c5 100644
--- a/blame.c
+++ b/blame.c
@@ -1028,8 +1028,9 @@ static void fill_origin_blob(struct diff_options *opt,
 				    &o->blob_oid, 1, &file->ptr, &file_size))
 			;
 		else
-			file->ptr = read_object_file(&o->blob_oid, &type,
-						     &file_size);
+			file->ptr = repo_read_object_file(the_repository,
+							  &o->blob_oid, &type,
+							  &file_size);
 		file->size = file_size;
 
 		if (!file->ptr)
@@ -2838,8 +2839,10 @@ void setup_scoreboard(struct blame_scoreboard *sb,
 				    &sb->final_buf_size))
 			;
 		else
-			sb->final_buf = read_object_file(&o->blob_oid, &type,
-							 &sb->final_buf_size);
+			sb->final_buf = repo_read_object_file(the_repository,
+							      &o->blob_oid,
+							      &type,
+							      &sb->final_buf_size);
 
 		if (!sb->final_buf)
 			die(_("cannot read blob %s for path %s"),
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index cc17635e765..caf2d258619 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -60,7 +60,7 @@ static int filter_object(const char *path, unsigned mode,
 {
 	enum object_type type;
 
-	*buf = read_object_file(oid, &type, size);
+	*buf = repo_read_object_file(the_repository, oid, &type, size);
 	if (!*buf)
 		return error(_("cannot read object %s '%s'"),
 			     oid_to_hex(oid), path);
@@ -152,7 +152,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
 		goto cleanup;
 
 	case 'e':
-		return !has_object_file(&oid);
+		return !repo_has_object_file(the_repository, &oid);
 
 	case 'w':
 
@@ -187,7 +187,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
 			ret = stream_blob(&oid);
 			goto cleanup;
 		}
-		buf = read_object_file(&oid, &type, &size);
+		buf = repo_read_object_file(the_repository, &oid, &type,
+					    &size);
 		if (!buf)
 			die("Cannot read object %s", obj_name);
 
@@ -207,8 +208,10 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
 		if (exp_type_id == OBJ_BLOB) {
 			struct object_id blob_oid;
 			if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {
-				char *buffer = read_object_file(&oid, &type,
-								&size);
+				char *buffer = repo_read_object_file(the_repository,
+								     &oid,
+								     &type,
+								     &size);
 				const char *target;
 				if (!skip_prefix(buffer, "object ", &target) ||
 				    get_oid_hex(target, &blob_oid))
@@ -383,9 +386,10 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
 				if (!textconv_object(the_repository,
 						     data->rest, 0100644, oid,
 						     1, &contents, &size))
-					contents = read_object_file(oid,
-								    &type,
-								    &size);
+					contents = repo_read_object_file(the_repository,
+									 oid,
+									 &type,
+									 &size);
 				if (!contents)
 					die("could not convert '%s' %s",
 					    oid_to_hex(oid), data->rest);
@@ -402,7 +406,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
 		unsigned long size;
 		void *contents;
 
-		contents = read_object_file(oid, &type, &size);
+		contents = repo_read_object_file(the_repository, oid, &type,
+						 &size);
 
 		if (use_mailmap) {
 			size_t s = size;
diff --git a/builtin/clone.c b/builtin/clone.c
index 65b5b7db6de..4de4640ed45 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -547,9 +547,9 @@ static void write_followtags(const struct ref *refs, const char *msg)
 			continue;
 		if (ends_with(ref->name, "^{}"))
 			continue;
-		if (!has_object_file_with_flags(&ref->old_oid,
-						OBJECT_INFO_QUICK |
-						OBJECT_INFO_SKIP_FETCH_OBJECT))
+		if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid,
+						     OBJECT_INFO_QUICK |
+						     OBJECT_INFO_SKIP_FETCH_OBJECT))
 			continue;
 		update_ref(msg, ref->name, &ref->old_oid, NULL, 0,
 			   UPDATE_REFS_DIE_ON_ERR);
diff --git a/builtin/difftool.c b/builtin/difftool.c
index dbbfb19f192..30daa83bc6b 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -295,7 +295,8 @@ static char *get_symlink(const struct object_id *oid, const char *path)
 	} else {
 		enum object_type type;
 		unsigned long size;
-		data = read_object_file(oid, &type, &size);
+		data = repo_read_object_file(the_repository, oid, &type,
+					     &size);
 		if (!data)
 			die(_("could not read object %s for symlink %s"),
 				oid_to_hex(oid), path);
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 5fe7c02970e..6515bd2ad8b 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -296,7 +296,7 @@ static void export_blob(const struct object_id *oid)
 		object = (struct object *)lookup_blob(the_repository, oid);
 		eaten = 0;
 	} else {
-		buf = read_object_file(oid, &type, &size);
+		buf = repo_read_object_file(the_repository, oid, &type, &size);
 		if (!buf)
 			die("could not read blob %s", oid_to_hex(oid));
 		if (check_object_signature(the_repository, oid, buf, size,
@@ -766,7 +766,8 @@ static void handle_tag(const char *name, struct tag *tag)
 		return;
 	}
 
-	buf = read_object_file(&tag->object.oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &tag->object.oid, &type,
+				    &size);
 	if (!buf)
 		die("could not read tag %s", oid_to_hex(&tag->object.oid));
 	message = memmem(buf, size, "\n\n", 2);
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 2098c0c5a37..20654341782 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -1265,7 +1265,7 @@ static void load_tree(struct tree_entry *root)
 			die("Can't load tree %s", oid_to_hex(oid));
 	} else {
 		enum object_type type;
-		buf = read_object_file(oid, &type, &size);
+		buf = repo_read_object_file(the_repository, oid, &type, &size);
 		if (!buf || type != OBJ_TREE)
 			die("Can't load tree %s", oid_to_hex(oid));
 	}
@@ -2936,7 +2936,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
 	char *buf;
 
 	if (!oe || oe->pack_id == MAX_PACK_ID) {
-		buf = read_object_file(oid, &type, &size);
+		buf = repo_read_object_file(the_repository, oid, &type, &size);
 	} else {
 		type = oe->type;
 		buf = gfi_unpack_entry(oe, &size);
@@ -3044,7 +3044,8 @@ static struct object_entry *dereference(struct object_entry *oe,
 		buf = gfi_unpack_entry(oe, &size);
 	} else {
 		enum object_type unused;
-		buf = read_object_file(oid, &unused, &size);
+		buf = repo_read_object_file(the_repository, oid, &unused,
+					    &size);
 	}
 	if (!buf)
 		die("Can't load object %s", oid_to_hex(oid));
diff --git a/builtin/fetch.c b/builtin/fetch.c
index db8815032fc..784e344d2bb 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -407,9 +407,9 @@ static void find_non_local_tags(const struct ref *refs,
 		 */
 		if (ends_with(ref->name, "^{}")) {
 			if (item &&
-			    !has_object_file_with_flags(&ref->old_oid, quick_flags) &&
+			    !repo_has_object_file_with_flags(the_repository, &ref->old_oid, quick_flags) &&
 			    !oidset_contains(&fetch_oids, &ref->old_oid) &&
-			    !has_object_file_with_flags(&item->oid, quick_flags) &&
+			    !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
 			    !oidset_contains(&fetch_oids, &item->oid))
 				clear_item(item);
 			item = NULL;
@@ -423,7 +423,7 @@ static void find_non_local_tags(const struct ref *refs,
 		 * fetch.
 		 */
 		if (item &&
-		    !has_object_file_with_flags(&item->oid, quick_flags) &&
+		    !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
 		    !oidset_contains(&fetch_oids, &item->oid))
 			clear_item(item);
 
@@ -444,7 +444,7 @@ static void find_non_local_tags(const struct ref *refs,
 	 * checked to see if it needs fetching.
 	 */
 	if (item &&
-	    !has_object_file_with_flags(&item->oid, quick_flags) &&
+	    !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
 	    !oidset_contains(&fetch_oids, &item->oid))
 		clear_item(item);
 
@@ -1320,8 +1320,8 @@ static int check_exist_and_connected(struct ref *ref_map)
 	 * we need all direct targets to exist.
 	 */
 	for (r = rm; r; r = r->next) {
-		if (!has_object_file_with_flags(&r->old_oid,
-						OBJECT_INFO_SKIP_FETCH_OBJECT))
+		if (!repo_has_object_file_with_flags(the_repository, &r->old_oid,
+						     OBJECT_INFO_SKIP_FETCH_OBJECT))
 			return -1;
 	}
 
diff --git a/builtin/grep.c b/builtin/grep.c
index f7821c5fbba..18561b10029 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -560,7 +560,8 @@ static int grep_cache(struct grep_opt *opt,
 			void *data;
 			unsigned long size;
 
-			data = read_object_file(&ce->oid, &type, &size);
+			data = repo_read_object_file(the_repository, &ce->oid,
+						     &type, &size);
 			init_tree_desc(&tree, data, size);
 
 			hit |= grep_tree(opt, pathspec, &tree, &name, 0, 0);
@@ -650,7 +651,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
 			void *data;
 			unsigned long size;
 
-			data = read_object_file(&entry.oid, &type, &size);
+			data = repo_read_object_file(the_repository,
+						     &entry.oid, &type, &size);
 			if (!data)
 				die(_("unable to read tree (%s)"),
 				    oid_to_hex(&entry.oid));
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 6648f2daef5..4cf69ee1d97 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -801,7 +801,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
 	if (startup_info->have_repository) {
 		read_lock();
 		collision_test_needed =
-			has_object_file_with_flags(oid, OBJECT_INFO_QUICK);
+			repo_has_object_file_with_flags(the_repository, oid,
+							OBJECT_INFO_QUICK);
 		read_unlock();
 	}
 
@@ -821,7 +822,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
 			die(_("cannot read existing object info %s"), oid_to_hex(oid));
 		if (has_type != type || has_size != size)
 			die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
-		has_data = read_object_file(oid, &has_type, &has_size);
+		has_data = repo_read_object_file(the_repository, oid,
+						 &has_type, &has_size);
 		read_unlock();
 		if (!data)
 			data = new_data = get_data_from_pack(obj_entry);
@@ -1414,7 +1416,8 @@ static void fix_unresolved_deltas(struct hashfile *f)
 
 		if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
 			continue;
-		data = read_object_file(&d->oid, &type, &size);
+		data = repo_read_object_file(the_repository, &d->oid, &type,
+					     &size);
 		if (!data)
 			continue;
 
diff --git a/builtin/log.c b/builtin/log.c
index b76a1c82d8f..3dde77bde27 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -675,7 +675,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
 {
 	unsigned long size;
 	enum object_type type;
-	char *buf = read_object_file(oid, &type, &size);
+	char *buf = repo_read_object_file(the_repository, oid, &type, &size);
 	int offset = 0;
 
 	if (!buf)
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index c0acbc6a546..d628ad1da9f 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -69,7 +69,9 @@ static void *result(struct merge_list *entry, unsigned long *size)
 	const char *path = entry->path;
 
 	if (!entry->stage)
-		return read_object_file(&entry->blob->object.oid, &type, size);
+		return repo_read_object_file(the_repository,
+					     &entry->blob->object.oid, &type,
+					     size);
 	base = NULL;
 	if (entry->stage == 1) {
 		base = entry->blob;
@@ -92,8 +94,9 @@ static void *origin(struct merge_list *entry, unsigned long *size)
 	enum object_type type;
 	while (entry) {
 		if (entry->stage == 2)
-			return read_object_file(&entry->blob->object.oid,
-						&type, size);
+			return repo_read_object_file(the_repository,
+						     &entry->blob->object.oid,
+						     &type, size);
 		entry = entry->link;
 	}
 	return NULL;
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 5d22909122d..141a2d45693 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -51,7 +51,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)
 	void *buffer;
 	const struct object_id *repl;
 
-	buffer = read_object_file(tagged_oid, &type, &size);
+	buffer = repo_read_object_file(the_repository, tagged_oid, &type,
+				       &size);
 	if (!buffer)
 		die(_("could not read tagged object '%s'"),
 		    oid_to_hex(tagged_oid));
diff --git a/builtin/notes.c b/builtin/notes.c
index b497eae520e..ba1daa4ff0f 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -124,7 +124,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)
 {
 	unsigned long size;
 	enum object_type type;
-	char *buf = read_object_file(oid, &type, &size);
+	char *buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (buf) {
 		if (size)
 			write_or_die(fd, buf, size);
@@ -259,7 +259,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
 
 	if (repo_get_oid(the_repository, arg, &object))
 		die(_("failed to resolve '%s' as a valid ref."), arg);
-	if (!(buf = read_object_file(&object, &type, &len)))
+	if (!(buf = repo_read_object_file(the_repository, &object, &type, &len)))
 		die(_("failed to read object '%s'."), arg);
 	if (type != OBJ_BLOB) {
 		free(buf);
@@ -616,7 +616,8 @@ static int append_edit(int argc, const char **argv, const char *prefix)
 		/* Append buf to previous note contents */
 		unsigned long size;
 		enum object_type type;
-		char *prev_buf = read_object_file(note, &type, &size);
+		char *prev_buf = repo_read_object_file(the_repository, note,
+						       &type, &size);
 
 		strbuf_grow(&d.buf, size + 1);
 		if (d.buf.len && prev_buf && size)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 74a167a180c..3c9b35642cb 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -288,11 +288,13 @@ static void *get_delta(struct object_entry *entry)
 	void *buf, *base_buf, *delta_buf;
 	enum object_type type;
 
-	buf = read_object_file(&entry->idx.oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &entry->idx.oid, &type,
+				    &size);
 	if (!buf)
 		die(_("unable to read %s"), oid_to_hex(&entry->idx.oid));
-	base_buf = read_object_file(&DELTA(entry)->idx.oid, &type,
-				    &base_size);
+	base_buf = repo_read_object_file(the_repository,
+					 &DELTA(entry)->idx.oid, &type,
+					 &base_size);
 	if (!base_buf)
 		die("unable to read %s",
 		    oid_to_hex(&DELTA(entry)->idx.oid));
@@ -454,7 +456,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
 				       &size, NULL)) != NULL)
 			buf = NULL;
 		else {
-			buf = read_object_file(&entry->idx.oid, &type, &size);
+			buf = repo_read_object_file(the_repository,
+						    &entry->idx.oid, &type,
+						    &size);
 			if (!buf)
 				die(_("unable to read %s"),
 				    oid_to_hex(&entry->idx.oid));
@@ -1665,7 +1669,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
 	/* Did not find one.  Either we got a bogus request or
 	 * we need to read and perhaps cache.
 	 */
-	data = read_object_file(oid, &type, &size);
+	data = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!data)
 		return NULL;
 	if (type != OBJ_TREE) {
@@ -2525,7 +2529,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
 	/* Load data if not already done */
 	if (!trg->data) {
 		packing_data_lock(&to_pack);
-		trg->data = read_object_file(&trg_entry->idx.oid, &type, &sz);
+		trg->data = repo_read_object_file(the_repository,
+						  &trg_entry->idx.oid, &type,
+						  &sz);
 		packing_data_unlock(&to_pack);
 		if (!trg->data)
 			die(_("object %s cannot be read"),
@@ -2538,7 +2544,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
 	}
 	if (!src->data) {
 		packing_data_lock(&to_pack);
-		src->data = read_object_file(&src_entry->idx.oid, &type, &sz);
+		src->data = repo_read_object_file(the_repository,
+						  &src_entry->idx.oid, &type,
+						  &sz);
 		packing_data_unlock(&to_pack);
 		if (!src->data) {
 			if (src_entry->preferred_base) {
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 6d4fc1368a4..5609206499c 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1494,7 +1494,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
 		}
 	}
 
-	if (!is_null_oid(new_oid) && !has_object_file(new_oid)) {
+	if (!is_null_oid(new_oid) && !repo_has_object_file(the_repository, new_oid)) {
 		error("unpack should have generated %s, "
 		      "but I can't find it!", oid_to_hex(new_oid));
 		ret = "bad pack";
diff --git a/builtin/remote.c b/builtin/remote.c
index 729f6f3643a..a6b100dce7f 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -443,7 +443,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
 			info->status = PUSH_STATUS_UPTODATE;
 		else if (is_null_oid(&ref->old_oid))
 			info->status = PUSH_STATUS_CREATE;
-		else if (has_object_file(&ref->old_oid) &&
+		else if (repo_has_object_file(the_repository, &ref->old_oid) &&
 			 ref_newer(&ref->new_oid, &ref->old_oid))
 			info->status = PUSH_STATUS_FASTFORWARD;
 		else
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index eb3ad1688ba..b294ae41641 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -26,7 +26,7 @@ static void show_one(const char *refname, const struct object_id *oid)
 	const char *hex;
 	struct object_id peeled;
 
-	if (!has_object_file(oid))
+	if (!repo_has_object_file(the_repository, oid))
 		die("git show-ref: bad ref %s (%s)", refname,
 		    oid_to_hex(oid));
 
diff --git a/builtin/tag.c b/builtin/tag.c
index e6cbf6e5a8d..cd97a141faf 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -215,7 +215,7 @@ static void write_tag_body(int fd, const struct object_id *oid)
 	struct strbuf payload = STRBUF_INIT;
 	struct strbuf signature = STRBUF_INIT;
 
-	orig = buf = read_object_file(oid, &type, &size);
+	orig = buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!buf)
 		return;
 	if (parse_signature(buf, size, &payload, &signature)) {
@@ -366,7 +366,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
 		strbuf_addstr(sb, "object of unknown type");
 		break;
 	case OBJ_COMMIT:
-		if ((buf = read_object_file(oid, &type, &size))) {
+		if ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {
 			subject_len = find_commit_subject(buf, &subject_start);
 			strbuf_insert(sb, sb->len, subject_start, subject_len);
 		} else {
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index e0d5178acc5..9d5c1524197 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -10,7 +10,7 @@ static char *create_temp_file(struct object_id *oid)
 	unsigned long size;
 	int fd;
 
-	buf = read_object_file(oid, &type, &size);
+	buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!buf || type != OBJ_BLOB)
 		die("unable to read blob object %s", oid_to_hex(oid));
 
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 43789b8ef29..c0720961743 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -442,7 +442,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
 		delta_data = get_data(delta_size);
 		if (!delta_data)
 			return;
-		if (has_object_file(&base_oid))
+		if (repo_has_object_file(the_repository, &base_oid))
 			; /* Ok we have this one */
 		else if (resolve_against_held(nr, &base_oid,
 					      delta_data, delta_size))
@@ -508,7 +508,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
 	if (resolve_against_held(nr, &base_oid, delta_data, delta_size))
 		return;
 
-	base = read_object_file(&base_oid, &type, &base_size);
+	base = repo_read_object_file(the_repository, &base_oid, &type,
+				     &base_size);
 	if (!base) {
 		error("failed to read delta-pack base object %s",
 		      oid_to_hex(&base_oid));
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 855b68ec23b..b44b94e8663 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -124,7 +124,7 @@ static int already_written(struct bulk_checkin_packfile *state, struct object_id
 	int i;
 
 	/* The object may already exist in the repository */
-	if (has_object_file(oid))
+	if (repo_has_object_file(the_repository, oid))
 		return 1;
 
 	/* Might want to keep the list sorted */
diff --git a/bundle.c b/bundle.c
index 6ab6cd7378d..9b57bade7a6 100644
--- a/bundle.c
+++ b/bundle.c
@@ -293,7 +293,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
 	if (revs->max_age == -1 && revs->min_age == -1)
 		goto out;
 
-	buf = read_object_file(&tag->oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &tag->oid, &type, &size);
 	if (!buf)
 		goto out;
 	line = memmem(buf, size, "\ntagger ", 8);
diff --git a/cache-tree.c b/cache-tree.c
index 88c2c04f87f..59610117d0b 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -229,7 +229,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
 	int i;
 	if (!it)
 		return 0;
-	if (it->entry_count < 0 || !has_object_file(&it->oid))
+	if (it->entry_count < 0 || !repo_has_object_file(the_repository, &it->oid))
 		return 0;
 	for (i = 0; i < it->subtree_nr; i++) {
 		if (!cache_tree_fully_valid(it->down[i]->cache_tree))
@@ -280,7 +280,7 @@ static int update_one(struct cache_tree *it,
 		}
 	}
 
-	if (0 <= it->entry_count && has_object_file(&it->oid))
+	if (0 <= it->entry_count && repo_has_object_file(the_repository, &it->oid))
 		return it->entry_count;
 
 	/*
@@ -386,7 +386,7 @@ static int update_one(struct cache_tree *it,
 		ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
 			!must_check_existence(ce);
 		if (is_null_oid(oid) ||
-		    (!ce_missing_ok && !has_object_file(oid))) {
+		    (!ce_missing_ok && !repo_has_object_file(the_repository, oid))) {
 			strbuf_release(&buffer);
 			if (expected_missing)
 				return -1;
@@ -434,7 +434,7 @@ static int update_one(struct cache_tree *it,
 		struct object_id oid;
 		hash_object_file(the_hash_algo, buffer.buf, buffer.len,
 				 OBJ_TREE, &oid);
-		if (has_object_file_with_flags(&oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
+		if (repo_has_object_file_with_flags(the_repository, &oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
 			oidcpy(&it->oid, &oid);
 		else
 			to_invalidate = 1;
diff --git a/combine-diff.c b/combine-diff.c
index d84ab878b72..20f8a03924f 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -332,7 +332,7 @@ static char *grab_blob(struct repository *r,
 		*size = fill_textconv(r, textconv, df, &blob);
 		free_filespec(df);
 	} else {
-		blob = read_object_file(oid, &type, size);
+		blob = repo_read_object_file(the_repository, oid, &type, size);
 		if (type != OBJ_BLOB)
 			die("object '%s' is not a blob!", oid_to_hex(oid));
 	}
diff --git a/commit.c b/commit.c
index 6036376d05a..dd22e76c3e1 100644
--- a/commit.c
+++ b/commit.c
@@ -1212,7 +1212,8 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header
 	desc = merge_remote_util(parent);
 	if (!desc || !desc->obj)
 		return;
-	buf = read_object_file(&desc->obj->oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &desc->obj->oid, &type,
+				    &size);
 	if (!buf || type != OBJ_TAG)
 		goto free_return;
 	if (!parse_signature(buf, size, &payload, &signature))
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index 3c0bd8781e7..fa159aba5b5 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -77,6 +77,16 @@
 |
 - diff_setup
 + repo_diff_setup
+// object-store.h
+|
+- read_object_file
++ repo_read_object_file
+|
+- has_object_file
++ repo_has_object_file
+|
+- has_object_file_with_flags
++ repo_has_object_file_with_flags
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 00461ee86b3..69e9694111e 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,17 +5,7 @@
 @@
 @@
 (
-// object-store.h
-- read_object_file
-+ repo_read_object_file
-|
-- has_object_file
-+ repo_has_object_file
-|
-- has_object_file_with_flags
-+ repo_has_object_file_with_flags
 // pretty.h
-|
 - format_commit_message
 + repo_format_commit_message
 // packfile.h
diff --git a/dir.c b/dir.c
index 4e99f0c868f..6615afe8f13 100644
--- a/dir.c
+++ b/dir.c
@@ -267,7 +267,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
 	*size_out = 0;
 	*data_out = NULL;
 
-	data = read_object_file(oid, &type, &sz);
+	data = repo_read_object_file(the_repository, oid, &type, &sz);
 	if (!data || type != OBJ_BLOB) {
 		free(data);
 		return -1;
diff --git a/entry.c b/entry.c
index 971ab268714..7c50220a782 100644
--- a/entry.c
+++ b/entry.c
@@ -86,7 +86,8 @@ void *read_blob_entry(const struct cache_entry *ce, size_t *size)
 {
 	enum object_type type;
 	unsigned long ul;
-	void *blob_data = read_object_file(&ce->oid, &type, &ul);
+	void *blob_data = repo_read_object_file(the_repository, &ce->oid,
+						&type, &ul);
 
 	*size = ul;
 	if (blob_data) {
diff --git a/fetch-pack.c b/fetch-pack.c
index 04016d1e325..8c497b48219 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -762,9 +762,9 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
 		if (!commit) {
 			struct object *o;
 
-			if (!has_object_file_with_flags(&ref->old_oid,
-						OBJECT_INFO_QUICK |
-						OBJECT_INFO_SKIP_FETCH_OBJECT))
+			if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid,
+							     OBJECT_INFO_QUICK |
+							     OBJECT_INFO_SKIP_FETCH_OBJECT))
 				continue;
 			o = parse_object(the_repository, &ref->old_oid);
 			if (!o || o->type != OBJ_COMMIT)
@@ -1963,7 +1963,7 @@ static void update_shallow(struct fetch_pack_args *args,
 		struct oid_array extra = OID_ARRAY_INIT;
 		struct object_id *oid = si->shallow->oid;
 		for (i = 0; i < si->shallow->nr; i++)
-			if (has_object_file(&oid[i]))
+			if (repo_has_object_file(the_repository, &oid[i]))
 				oid_array_append(&extra, &oid[i]);
 		if (extra.nr) {
 			setup_alternate_shallow(&shallow_lock,
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index a5de91ba22c..e9c6623647d 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -520,7 +520,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
 		struct object_id *oid = origins.items[i].util;
 		enum object_type type;
 		unsigned long size;
-		char *buf = read_object_file(oid, &type, &size);
+		char *buf = repo_read_object_file(the_repository, oid, &type,
+						  &size);
 		char *origbuf = buf;
 		unsigned long len = size;
 		struct signature_check sigc = { NULL };
diff --git a/fsck.c b/fsck.c
index 807a84971a2..0343fb7a887 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1332,7 +1332,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,
 		if (oidset_contains(blobs_done, oid))
 			continue;
 
-		buf = read_object_file(oid, &type, &size);
+		buf = repo_read_object_file(the_repository, oid, &type, &size);
 		if (!buf) {
 			if (is_promisor_object(oid))
 				continue;
diff --git a/http-push.c b/http-push.c
index 45d5cc0972f..6776f3f2758 100644
--- a/http-push.c
+++ b/http-push.c
@@ -362,7 +362,8 @@ static void start_put(struct transfer_request *request)
 	ssize_t size;
 	git_zstream stream;
 
-	unpacked = read_object_file(&request->obj->oid, &type, &len);
+	unpacked = repo_read_object_file(the_repository, &request->obj->oid,
+					 &type, &len);
 	hdrlen = format_object_header(hdr, sizeof(hdr), type, len);
 
 	/* Set it up */
@@ -1427,7 +1428,7 @@ static void one_remote_ref(const char *refname)
 	 * Fetch a copy of the object if it doesn't exist locally - it
 	 * may be required for updating server info later.
 	 */
-	if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
+	if (repo->can_update_info_refs && !repo_has_object_file(the_repository, &ref->old_oid)) {
 		obj = lookup_unknown_object(the_repository, &ref->old_oid);
 		fprintf(stderr,	"  fetch %s for %s\n",
 			oid_to_hex(&ref->old_oid), refname);
@@ -1628,14 +1629,14 @@ static int delete_remote_branch(const char *pattern, int force)
 			return error("Remote HEAD symrefs too deep");
 		if (is_null_oid(&head_oid))
 			return error("Unable to resolve remote HEAD");
-		if (!has_object_file(&head_oid))
+		if (!repo_has_object_file(the_repository, &head_oid))
 			return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid));
 
 		/* Remote branch must resolve to a known object */
 		if (is_null_oid(&remote_ref->old_oid))
 			return error("Unable to resolve remote branch %s",
 				     remote_ref->name);
-		if (!has_object_file(&remote_ref->old_oid))
+		if (!repo_has_object_file(the_repository, &remote_ref->old_oid))
 			return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, oid_to_hex(&remote_ref->old_oid));
 
 		/* Remote branch must be an ancestor of remote HEAD */
@@ -1855,7 +1856,7 @@ int cmd_main(int argc, const char **argv)
 		if (!force_all &&
 		    !is_null_oid(&ref->old_oid) &&
 		    !ref->force) {
-			if (!has_object_file(&ref->old_oid) ||
+			if (!repo_has_object_file(the_repository, &ref->old_oid) ||
 			    !ref_newer(&ref->peer_ref->new_oid,
 				       &ref->old_oid)) {
 				/*
diff --git a/http-walker.c b/http-walker.c
index b8f0f98ae14..da1b6b64210 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -135,7 +135,7 @@ static int fill_active_slot(struct walker *walker)
 	list_for_each_safe(pos, tmp, head) {
 		obj_req = list_entry(pos, struct object_request, node);
 		if (obj_req->state == WAITING) {
-			if (has_object_file(&obj_req->oid))
+			if (repo_has_object_file(the_repository, &obj_req->oid))
 				obj_req->state = COMPLETE;
 			else {
 				start_object_request(walker, obj_req);
@@ -492,7 +492,7 @@ static int fetch_object(struct walker *walker, unsigned char *hash)
 	if (!obj_req)
 		return error("Couldn't find request for %s in the queue", hex);
 
-	if (has_object_file(&obj_req->oid)) {
+	if (repo_has_object_file(the_repository, &obj_req->oid)) {
 		if (obj_req->req)
 			abort_http_object_request(obj_req->req);
 		abort_object_request(obj_req);
diff --git a/list-objects.c b/list-objects.c
index 5550b3aafeb..ccad7304dfa 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -64,7 +64,7 @@ static void process_blob(struct traversal_context *ctx,
 	 * of missing objects.
 	 */
 	if (ctx->revs->exclude_promisor_objects &&
-	    !has_object_file(&obj->oid) &&
+	    !repo_has_object_file(the_repository, &obj->oid) &&
 	    is_promisor_object(&obj->oid))
 		return;
 
diff --git a/mailmap.c b/mailmap.c
index ed8289aea58..f68f664bb1b 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -216,7 +216,7 @@ static int read_mailmap_blob(struct string_list *map, const char *name)
 	if (repo_get_oid(the_repository, name, &oid) < 0)
 		return 0;
 
-	buf = read_object_file(&oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &oid, &type, &size);
 	if (!buf)
 		return error("unable to read mailmap object at %s", name);
 	if (type != OBJ_BLOB)
diff --git a/match-trees.c b/match-trees.c
index 49398e599fe..dfc4093425e 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -55,7 +55,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,
 	enum object_type type;
 	unsigned long size;
 
-	buffer = read_object_file(hash, &type, &size);
+	buffer = repo_read_object_file(the_repository, hash, &type, &size);
 	if (!buffer)
 		die("unable to read tree (%s)", oid_to_hex(hash));
 	if (type != OBJ_TREE)
@@ -188,7 +188,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
 	if (*subpath)
 		subpath++;
 
-	buf = read_object_file(oid1, &type, &sz);
+	buf = repo_read_object_file(the_repository, oid1, &type, &sz);
 	if (!buf)
 		die("cannot read tree %s", oid_to_hex(oid1));
 	init_tree_desc(&desc, buf, sz);
diff --git a/merge-blobs.c b/merge-blobs.c
index 8138090f81c..f13246406c2 100644
--- a/merge-blobs.c
+++ b/merge-blobs.c
@@ -12,7 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
 	unsigned long size;
 	enum object_type type;
 
-	buf = read_object_file(&obj->object.oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &obj->object.oid, &type,
+				    &size);
 	if (!buf)
 		return -1;
 	if (type != OBJ_BLOB) {
@@ -78,7 +79,8 @@ void *merge_blobs(struct index_state *istate, const char *path,
 			return NULL;
 		if (!our)
 			our = their;
-		return read_object_file(&our->object.oid, &type, size);
+		return repo_read_object_file(the_repository, &our->object.oid,
+					     &type, size);
 	}
 
 	if (fill_mmfile_blob(&f1, our) < 0)
diff --git a/merge-ort.c b/merge-ort.c
index e9f8bd15982..979e8b057b1 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -3505,7 +3505,7 @@ static int read_oid_strbuf(struct merge_options *opt,
 	void *buf;
 	enum object_type type;
 	unsigned long size;
-	buf = read_object_file(oid, &type, &size);
+	buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!buf)
 		return err(opt, _("cannot read object %s"), oid_to_hex(oid));
 	if (type != OBJ_BLOB) {
diff --git a/merge-recursive.c b/merge-recursive.c
index 75fa0ef3183..d83ce19bb1f 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -951,7 +951,8 @@ static int update_file_flags(struct merge_options *opt,
 			goto update_index;
 		}
 
-		buf = read_object_file(&contents->oid, &type, &size);
+		buf = repo_read_object_file(the_repository, &contents->oid,
+					    &type, &size);
 		if (!buf) {
 			ret = err(opt, _("cannot read object %s '%s'"),
 				  oid_to_hex(&contents->oid), path);
@@ -3021,7 +3022,7 @@ static int read_oid_strbuf(struct merge_options *opt,
 	void *buf;
 	enum object_type type;
 	unsigned long size;
-	buf = read_object_file(oid, &type, &size);
+	buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!buf)
 		return err(opt, _("cannot read object %s"), oid_to_hex(oid));
 	if (type != OBJ_BLOB) {
diff --git a/notes-cache.c b/notes-cache.c
index 9dfd251a815..38466091360 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -81,7 +81,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,
 	value_oid = get_note(&c->tree, key_oid);
 	if (!value_oid)
 		return NULL;
-	value = read_object_file(value_oid, &type, &size);
+	value = repo_read_object_file(the_repository, value_oid, &type, &size);
 
 	*outsize = size;
 	return value;
diff --git a/notes-merge.c b/notes-merge.c
index df1a16ac66c..8a09cd9f77c 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -326,7 +326,7 @@ static void write_note_to_worktree(const struct object_id *obj,
 {
 	enum object_type type;
 	unsigned long size;
-	void *buf = read_object_file(note, &type, &size);
+	void *buf = repo_read_object_file(the_repository, note, &type, &size);
 
 	if (!buf)
 		die("cannot read note %s for object %s",
diff --git a/notes.c b/notes.c
index 750e18c4004..e4dab62cad3 100644
--- a/notes.c
+++ b/notes.c
@@ -786,7 +786,7 @@ static int prune_notes_helper(const struct object_id *object_oid,
 	struct note_delete_list **l = (struct note_delete_list **) cb_data;
 	struct note_delete_list *n;
 
-	if (has_object_file(object_oid))
+	if (repo_has_object_file(the_repository, object_oid))
 		return 0; /* nothing to do for this note */
 
 	/* failed to find object => prune this note */
@@ -807,13 +807,15 @@ int combine_notes_concatenate(struct object_id *cur_oid,
 
 	/* read in both note blob objects */
 	if (!is_null_oid(new_oid))
-		new_msg = read_object_file(new_oid, &new_type, &new_len);
+		new_msg = repo_read_object_file(the_repository, new_oid,
+						&new_type, &new_len);
 	if (!new_msg || !new_len || new_type != OBJ_BLOB) {
 		free(new_msg);
 		return 0;
 	}
 	if (!is_null_oid(cur_oid))
-		cur_msg = read_object_file(cur_oid, &cur_type, &cur_len);
+		cur_msg = repo_read_object_file(the_repository, cur_oid,
+						&cur_type, &cur_len);
 	if (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {
 		free(cur_msg);
 		free(new_msg);
@@ -869,7 +871,7 @@ static int string_list_add_note_lines(struct string_list *list,
 		return 0;
 
 	/* read_sha1_file NUL-terminates */
-	data = read_object_file(oid, &t, &len);
+	data = repo_read_object_file(the_repository, oid, &t, &len);
 	if (t != OBJ_BLOB || !data || !len) {
 		free(data);
 		return t != OBJ_BLOB || !data;
@@ -1264,7 +1266,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid
 	if (!oid)
 		return;
 
-	if (!(msg = read_object_file(oid, &type, &msglen)) || type != OBJ_BLOB) {
+	if (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) {
 		free(msg);
 		return;
 	}
diff --git a/object-file.c b/object-file.c
index 939865c1ae0..141cf85f25b 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1678,7 +1678,7 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,
 	struct cached_object *co;
 
 	hash_object_file(the_hash_algo, buf, len, type, oid);
-	if (has_object_file_with_flags(oid, OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT) ||
+	if (repo_has_object_file_with_flags(the_repository, oid, OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT) ||
 	    find_cached_object(oid))
 		return 0;
 	ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc);
diff --git a/object-store.h b/object-store.h
index 1a713d89d7c..b47849d4e7e 100644
--- a/object-store.h
+++ b/object-store.h
@@ -245,9 +245,6 @@ void *repo_read_object_file(struct repository *r,
 			    const struct object_id *oid,
 			    enum object_type *type,
 			    unsigned long *size);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define read_object_file(oid, type, size) repo_read_object_file(the_repository, oid, type, size)
-#endif
 
 /* Read and unpack an object file into memory, write memory to an object file */
 int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);
@@ -324,10 +321,6 @@ int has_object(struct repository *r, const struct object_id *oid,
 int repo_has_object_file(struct repository *r, const struct object_id *oid);
 int repo_has_object_file_with_flags(struct repository *r,
 				    const struct object_id *oid, int flags);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define has_object_file(oid) repo_has_object_file(the_repository, oid)
-#define has_object_file_with_flags(oid, flags) repo_has_object_file_with_flags(the_repository, oid, flags)
-#endif
 
 /*
  * Return true iff an alternate object database has a loose object
diff --git a/read-cache.c b/read-cache.c
index d6c69164d0f..1548e886684 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -263,7 +263,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)
 	if (strbuf_readlink(&sb, ce->name, expected_size))
 		return -1;
 
-	buffer = read_object_file(&ce->oid, &type, &size);
+	buffer = repo_read_object_file(the_repository, &ce->oid, &type, &size);
 	if (buffer) {
 		if (size == sb.len)
 			match = memcmp(buffer, sb.buf, size);
@@ -3553,7 +3553,8 @@ void *read_blob_data_from_index(struct index_state *istate,
 	}
 	if (pos < 0)
 		return NULL;
-	data = read_object_file(&istate->cache[pos]->oid, &type, &sz);
+	data = repo_read_object_file(the_repository, &istate->cache[pos]->oid,
+				     &type, &sz);
 	if (!data || type != OBJ_BLOB) {
 		free(data);
 		return NULL;
diff --git a/reflog.c b/reflog.c
index 6e8362e7a2f..510663e1e51 100644
--- a/reflog.c
+++ b/reflog.c
@@ -28,7 +28,8 @@ static int tree_is_complete(const struct object_id *oid)
 	if (!tree->buffer) {
 		enum object_type type;
 		unsigned long size;
-		void *data = read_object_file(oid, &type, &size);
+		void *data = repo_read_object_file(the_repository, oid, &type,
+						   &size);
 		if (!data) {
 			tree->object.flags |= INCOMPLETE;
 			return 0;
@@ -39,7 +40,7 @@ static int tree_is_complete(const struct object_id *oid)
 	init_tree_desc(&desc, tree->buffer, tree->size);
 	complete = 1;
 	while (tree_entry(&desc, &entry)) {
-		if (!has_object_file(&entry.oid) ||
+		if (!repo_has_object_file(the_repository, &entry.oid) ||
 		    (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {
 			tree->object.flags |= INCOMPLETE;
 			complete = 0;
diff --git a/remote.c b/remote.c
index 71b1ae2db05..12f6bea6252 100644
--- a/remote.c
+++ b/remote.c
@@ -1759,7 +1759,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
 		if (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {
 			if (starts_with(ref->name, "refs/tags/"))
 				reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
-			else if (!has_object_file(&ref->old_oid))
+			else if (!repo_has_object_file(the_repository, &ref->old_oid))
 				reject_reason = REF_STATUS_REJECT_FETCH_FIRST;
 			else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||
 				 !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))
diff --git a/rerere.c b/rerere.c
index 876ab435da9..dfbc1d555ec 100644
--- a/rerere.c
+++ b/rerere.c
@@ -965,8 +965,9 @@ static int handle_cache(struct index_state *istate,
 			break;
 		i = ce_stage(ce) - 1;
 		if (!mmfile[i].ptr) {
-			mmfile[i].ptr = read_object_file(&ce->oid, &type,
-							 &size);
+			mmfile[i].ptr = repo_read_object_file(the_repository,
+							      &ce->oid, &type,
+							      &size);
 			mmfile[i].size = size;
 		}
 	}
diff --git a/send-pack.c b/send-pack.c
index f2e19838c9c..8f8b3d986c7 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -42,9 +42,9 @@ int option_parse_push_signed(const struct option *opt,
 static void feed_object(const struct object_id *oid, FILE *fh, int negative)
 {
 	if (negative &&
-	    !has_object_file_with_flags(oid,
-					OBJECT_INFO_SKIP_FETCH_OBJECT |
-					OBJECT_INFO_QUICK))
+	    !repo_has_object_file_with_flags(the_repository, oid,
+					     OBJECT_INFO_SKIP_FETCH_OBJECT |
+					     OBJECT_INFO_QUICK))
 		return;
 
 	if (negative)
diff --git a/shallow.c b/shallow.c
index 1a2b159fd4e..07278467e47 100644
--- a/shallow.c
+++ b/shallow.c
@@ -301,7 +301,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
 	if (graft->nr_parent != -1)
 		return 0;
 	if (data->flags & QUICK) {
-		if (!has_object_file(&graft->oid))
+		if (!repo_has_object_file(the_repository, &graft->oid))
 			return 0;
 	} else if (data->flags & SEEN_ONLY) {
 		struct commit *c = lookup_commit(the_repository, &graft->oid);
@@ -466,7 +466,7 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
 	ALLOC_ARRAY(info->ours, sa->nr);
 	ALLOC_ARRAY(info->theirs, sa->nr);
 	for (i = 0; i < sa->nr; i++) {
-		if (has_object_file(sa->oid + i)) {
+		if (repo_has_object_file(the_repository, sa->oid + i)) {
 			struct commit_graft *graft;
 			graft = lookup_commit_graft(the_repository,
 						    &sa->oid[i]);
@@ -494,7 +494,7 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)
 	for (i = dst = 0; i < info->nr_theirs; i++) {
 		if (i != dst)
 			info->theirs[dst] = info->theirs[i];
-		if (has_object_file(oid + info->theirs[i]))
+		if (repo_has_object_file(the_repository, oid + info->theirs[i]))
 			dst++;
 	}
 	info->nr_theirs = dst;
diff --git a/submodule-config.c b/submodule-config.c
index 336732ed785..4245bc5975c 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -588,7 +588,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,
 	if (submodule)
 		goto out;
 
-	config = read_object_file(&oid, &type, &config_size);
+	config = repo_read_object_file(the_repository, &oid, &type,
+				       &config_size);
 	if (!config || type != OBJ_BLOB)
 		goto out;
 
diff --git a/tag.c b/tag.c
index dfc900e62e0..d62084842f2 100644
--- a/tag.c
+++ b/tag.c
@@ -54,7 +54,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
 				repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
 				type_name(type));
 
-	buf = read_object_file(oid, &type, &size);
+	buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!buf)
 		return error("%s: unable to read file.",
 				name_to_report ?
@@ -216,7 +216,8 @@ int parse_tag(struct tag *item)
 
 	if (item->object.parsed)
 		return 0;
-	data = read_object_file(&item->object.oid, &type, &size);
+	data = repo_read_object_file(the_repository, &item->object.oid, &type,
+				     &size);
 	if (!data)
 		return error("Could not read %s",
 			     oid_to_hex(&item->object.oid));
diff --git a/tree.c b/tree.c
index f0742f4167b..1b403c4b5ce 100644
--- a/tree.c
+++ b/tree.c
@@ -129,7 +129,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)
 
 	if (item->object.parsed)
 		return 0;
-	buffer = read_object_file(&item->object.oid, &type, &size);
+	buffer = repo_read_object_file(the_repository, &item->object.oid,
+				       &type, &size);
 	if (!buffer)
 		return quiet_on_missing ? -1 :
 			error("Could not read %s",
diff --git a/upload-pack.c b/upload-pack.c
index 551f22ffa5d..4ef27ed47fb 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -499,8 +499,8 @@ static int got_oid(struct upload_pack_data *data,
 {
 	if (get_oid_hex(hex, oid))
 		die("git upload-pack: expected SHA1 object, got '%s'", hex);
-	if (!has_object_file_with_flags(oid,
-					OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
+	if (!repo_has_object_file_with_flags(the_repository, oid,
+					     OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
 		return -1;
 	return do_got_oid(data, oid);
 }
@@ -1600,8 +1600,8 @@ static int process_haves(struct upload_pack_data *data, struct oid_array *common
 	for (i = 0; i < data->haves.nr; i++) {
 		const struct object_id *oid = &data->haves.oid[i];
 
-		if (!has_object_file_with_flags(oid,
-						OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
+		if (!repo_has_object_file_with_flags(the_repository, oid,
+						     OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
 			continue;
 
 		oid_array_append(common, oid);
diff --git a/walker.c b/walker.c
index 98d65a559b4..8418066e509 100644
--- a/walker.c
+++ b/walker.c
@@ -145,7 +145,7 @@ static int process(struct walker *walker, struct object *obj)
 		return 0;
 	obj->flags |= SEEN;
 
-	if (has_object_file(&obj->oid)) {
+	if (repo_has_object_file(the_repository, &obj->oid)) {
 		/* We already have it, so we should scan it now. */
 		obj->flags |= TO_SCAN;
 	}
diff --git a/xdiff-interface.c b/xdiff-interface.c
index e87950de32e..c6f244116ce 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -183,7 +183,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)
 		return;
 	}
 
-	ptr->ptr = read_object_file(oid, &type, &size);
+	ptr->ptr = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!ptr->ptr || type != OBJ_BLOB)
 		die("unable to read blob object %s", oid_to_hex(oid));
 	ptr->size = size;
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 10/17] cocci: apply the "pretty.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (8 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 09/17] cocci: apply the "object-store.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 11/17] cocci: apply the "packfile.h" " Ævar Arnfjörð Bjarmason
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"pretty.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 archive.c                                       |  3 ++-
 bisect.c                                        |  3 ++-
 builtin/bisect.c                                | 10 ++++++----
 builtin/commit.c                                | 13 ++++++++-----
 builtin/notes.c                                 |  3 ++-
 builtin/shortlog.c                              |  6 ++++--
 contrib/coccinelle/the_repository.cocci         |  4 ++++
 contrib/coccinelle/the_repository.pending.cocci |  4 ----
 fmt-merge-msg.c                                 |  3 ++-
 log-tree.c                                      |  9 ++++++---
 notes-cache.c                                   |  3 ++-
 object-name.c                                   |  6 ++++--
 pretty.c                                        |  3 ++-
 pretty.h                                        |  4 ----
 sequencer.c                                     | 12 ++++++++----
 t/helper/test-revision-walking.c                |  3 ++-
 16 files changed, 54 insertions(+), 35 deletions(-)

diff --git a/archive.c b/archive.c
index 0b48de00634..d43687a5c44 100644
--- a/archive.c
+++ b/archive.c
@@ -59,7 +59,8 @@ static void format_subst(const struct commit *commit,
 		strbuf_add(&fmt, b + 8, c - b - 8);
 
 		strbuf_add(buf, src, b - src);
-		format_commit_message(commit, fmt.buf, buf, ctx);
+		repo_format_commit_message(the_repository, commit, fmt.buf,
+					   buf, ctx);
 		len -= c + 1 - src;
 		src  = c + 1;
 	}
diff --git a/bisect.c b/bisect.c
index db7aa2032e1..761dd48ad20 100644
--- a/bisect.c
+++ b/bisect.c
@@ -752,7 +752,8 @@ enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
 	}
 
 	commit = lookup_commit_reference(the_repository, bisect_rev);
-	format_commit_message(commit, "[%H] %s%n", &commit_msg, &pp);
+	repo_format_commit_message(the_repository, commit, "[%H] %s%n",
+				   &commit_msg, &pp);
 	fputs(commit_msg.buf, stdout);
 	strbuf_release(&commit_msg);
 
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 7d51eecab82..34ba7b18f69 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -265,7 +265,8 @@ static void log_commit(FILE *fp, char *fmt, const char *state,
 	struct strbuf commit_msg = STRBUF_INIT;
 	char *label = xstrfmt(fmt, state);
 
-	format_commit_message(commit, "%s", &commit_msg, &pp);
+	repo_format_commit_message(the_repository, commit, "%s", &commit_msg,
+				   &pp);
 
 	fprintf(fp, "# %s: [%s] %s\n", label, oid_to_hex(&commit->object.oid),
 		commit_msg.buf);
@@ -603,8 +604,8 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
 
 	while ((commit = get_revision(&revs)) != NULL) {
 		strbuf_reset(&commit_name);
-		format_commit_message(commit, "%s",
-				      &commit_name, &pp);
+		repo_format_commit_message(the_repository, commit, "%s",
+					   &commit_name, &pp);
 		fprintf(fp, "# possible first %s commit: [%s] %s\n",
 			terms->term_bad, oid_to_hex(&commit->object.oid),
 			commit_name.buf);
@@ -633,7 +634,8 @@ static int bisect_successful(struct bisect_terms *terms)
 
 	read_ref(bad_ref, &oid);
 	commit = lookup_commit_reference_by_name(bad_ref);
-	format_commit_message(commit, "%s", &commit_name, &pp);
+	repo_format_commit_message(the_repository, commit, "%s", &commit_name,
+				   &pp);
 
 	res = append_to_file(git_path_bisect_log(), "# first %s commit: [%s] %s\n",
 			    terms->term_bad, oid_to_hex(&commit->object.oid),
diff --git a/builtin/commit.c b/builtin/commit.c
index bda6afc4bd6..92b7e8c56f7 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -719,7 +719,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
 	 * duplicate the subject line.
 	 */
 	fmt = starts_with(subject, "amend!") ? "%b" : "%B";
-	format_commit_message(commit, fmt, sb, ctx);
+	repo_format_commit_message(the_repository, commit, fmt, sb, ctx);
 	repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
@@ -760,8 +760,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 			if (!c)
 				die(_("could not lookup commit %s"), squash_message);
 			ctx.output_encoding = get_commit_output_encoding();
-			format_commit_message(c, "squash! %s\n\n", &sb,
-					      &ctx);
+			repo_format_commit_message(the_repository, c,
+						   "squash! %s\n\n", &sb,
+						   &ctx);
 		}
 	}
 
@@ -795,7 +796,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 			die(_("could not lookup commit %s"), fixup_commit);
 		ctx.output_encoding = get_commit_output_encoding();
 		fmt = xstrfmt("%s! %%s\n\n", fixup_prefix);
-		format_commit_message(commit, fmt, &sb, &ctx);
+		repo_format_commit_message(the_repository, commit, fmt, &sb,
+					   &ctx);
 		free(fmt);
 		hook_arg1 = "message";
 
@@ -1135,7 +1137,8 @@ static const char *find_author_by_nickname(const char *name)
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode.type = DATE_NORMAL;
 		strbuf_release(&buf);
-		format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
+		repo_format_commit_message(the_repository, commit,
+					   "%aN <%aE>", &buf, &ctx);
 		release_revisions(&revs);
 		return strbuf_detach(&buf, NULL);
 	}
diff --git a/builtin/notes.c b/builtin/notes.c
index ba1daa4ff0f..f4939176dae 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -742,7 +742,8 @@ static int merge_commit(struct notes_merge_options *o)
 
 	/* Reuse existing commit message in reflog message */
 	memset(&pretty_ctx, 0, sizeof(pretty_ctx));
-	format_commit_message(partial, "%s", &msg, &pretty_ctx);
+	repo_format_commit_message(the_repository, partial, "%s", &msg,
+				   &pretty_ctx);
 	strbuf_trim(&msg);
 	strbuf_insertstr(&msg, 0, "notes: ");
 	update_ref(msg.buf, o->local_ref, &oid,
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 8afd1ad865e..62f91b8b932 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -223,7 +223,8 @@ static void insert_records_from_format(struct shortlog *log,
 	for_each_string_list_item(item, &log->format) {
 		strbuf_reset(&buf);
 
-		format_commit_message(commit, item->string, &buf, ctx);
+		repo_format_commit_message(the_repository, commit,
+					   item->string, &buf, ctx);
 
 		if (!shortlog_needs_dedup(log) || strset_add(dups, buf.buf))
 			insert_one_record(log, buf.buf, oneline);
@@ -249,7 +250,8 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 		if (log->user_format)
 			pretty_print_commit(&ctx, commit, &oneline);
 		else
-			format_commit_message(commit, "%s", &oneline, &ctx);
+			repo_format_commit_message(the_repository, commit,
+						   "%s", &oneline, &ctx);
 	}
 	oneline_str = oneline.len ? oneline.buf : "<none>";
 
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index fa159aba5b5..ff4c56114f1 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -87,6 +87,10 @@
 |
 - has_object_file_with_flags
 + repo_has_object_file_with_flags
+// pretty.h
+|
+- format_commit_message
++ repo_format_commit_message
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 69e9694111e..375850e773c 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// pretty.h
-- format_commit_message
-+ repo_format_commit_message
 // packfile.h
-|
 - approximate_object_count
 + repo_approximate_object_count
 // promisor-remote.h
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index e9c6623647d..62529344407 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -385,7 +385,8 @@ static void shortlog(const char *name,
 		if (subjects.nr > limit)
 			continue;
 
-		format_commit_message(commit, "%s", &sb, &ctx);
+		repo_format_commit_message(the_repository, commit, "%s", &sb,
+					   &ctx);
 		strbuf_ltrim(&sb);
 
 		if (!sb.len)
diff --git a/log-tree.c b/log-tree.c
index 1bd4d6ab008..7eee664cd23 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -407,7 +407,8 @@ void fmt_output_commit(struct strbuf *filename,
 	struct pretty_print_context ctx = {0};
 	struct strbuf subject = STRBUF_INIT;
 
-	format_commit_message(commit, "%f", &subject, &ctx);
+	repo_format_commit_message(the_repository, commit, "%f", &subject,
+				   &ctx);
 	fmt_output_subject(filename, subject.buf, info);
 	strbuf_release(&subject);
 }
@@ -985,8 +986,10 @@ static int do_remerge_diff(struct rev_info *opt,
 	o.msg_header_prefix = "remerge";
 
 	ctx.abbrev = DEFAULT_ABBREV;
-	format_commit_message(parent1, "%h (%s)", &parent1_desc, &ctx);
-	format_commit_message(parent2, "%h (%s)", &parent2_desc, &ctx);
+	repo_format_commit_message(the_repository, parent1, "%h (%s)",
+				   &parent1_desc, &ctx);
+	repo_format_commit_message(the_repository, parent2, "%h (%s)",
+				   &parent2_desc, &ctx);
 	o.branch1 = parent1_desc.buf;
 	o.branch2 = parent2_desc.buf;
 
diff --git a/notes-cache.c b/notes-cache.c
index 38466091360..e5e9092d367 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -23,7 +23,8 @@ static int notes_cache_match_validity(struct repository *r,
 		return 0;
 
 	memset(&pretty_ctx, 0, sizeof(pretty_ctx));
-	format_commit_message(commit, "%s", &msg, &pretty_ctx);
+	repo_format_commit_message(the_repository, commit, "%s", &msg,
+				   &pretty_ctx);
 	strbuf_trim(&msg);
 
 	ret = !strcmp(msg.buf, validity);
diff --git a/object-name.c b/object-name.c
index 2926f26251f..df31f192ce3 100644
--- a/object-name.c
+++ b/object-name.c
@@ -394,8 +394,10 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
 		if (commit) {
 			struct pretty_print_context pp = {0};
 			pp.date_mode.type = DATE_SHORT;
-			format_commit_message(commit, "%ad", &date, &pp);
-			format_commit_message(commit, "%s", &msg, &pp);
+			repo_format_commit_message(the_repository, commit,
+						   "%ad", &date, &pp);
+			repo_format_commit_message(the_repository, commit,
+						   "%s", &msg, &pp);
 		}
 
 		/*
diff --git a/pretty.c b/pretty.c
index 7e1614f67fe..076d1c363e7 100644
--- a/pretty.c
+++ b/pretty.c
@@ -2199,7 +2199,8 @@ void pretty_print_commit(struct pretty_print_context *pp,
 	int need_8bit_cte = pp->need_8bit_cte;
 
 	if (pp->fmt == CMIT_FMT_USERFORMAT) {
-		format_commit_message(commit, user_format, sb, pp);
+		repo_format_commit_message(the_repository, commit,
+					   user_format, sb, pp);
 		return;
 	}
 
diff --git a/pretty.h b/pretty.h
index f34e24c53a4..1e37c56d73d 100644
--- a/pretty.h
+++ b/pretty.h
@@ -120,10 +120,6 @@ void repo_format_commit_message(struct repository *r,
 			const struct commit *commit,
 			const char *format, struct strbuf *sb,
 			const struct pretty_print_context *context);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define format_commit_message(c, f, s, con) \
-	repo_format_commit_message(the_repository, c, f, s, con)
-#endif
 
 /*
  * Parse given arguments from "arg", check it for correctness and
diff --git a/sequencer.c b/sequencer.c
index 592b3d2875a..aa3ebb47d98 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1343,8 +1343,10 @@ void print_commit_summary(struct repository *r,
 
 	strbuf_addstr(&format, "format:%h] %s");
 
-	format_commit_message(commit, "%an <%ae>", &author_ident, &pctx);
-	format_commit_message(commit, "%cn <%ce>", &committer_ident, &pctx);
+	repo_format_commit_message(the_repository, commit, "%an <%ae>",
+				   &author_ident, &pctx);
+	repo_format_commit_message(the_repository, commit, "%cn <%ce>",
+				   &committer_ident, &pctx);
 	if (strbuf_cmp(&author_ident, &committer_ident)) {
 		strbuf_addstr(&format, "\n Author: ");
 		strbuf_addbuf_percentquote(&format, &author_ident);
@@ -1352,7 +1354,8 @@ void print_commit_summary(struct repository *r,
 	if (flags & SUMMARY_SHOW_AUTHOR_DATE) {
 		struct strbuf date = STRBUF_INIT;
 
-		format_commit_message(commit, "%ad", &date, &pctx);
+		repo_format_commit_message(the_repository, commit, "%ad",
+					   &date, &pctx);
 		strbuf_addstr(&format, "\n Date: ");
 		strbuf_addbuf_percentquote(&format, &date);
 		strbuf_release(&date);
@@ -2125,7 +2128,8 @@ static void refer_to_commit(struct replay_opts *opts,
 			.abbrev = DEFAULT_ABBREV,
 			.date_mode.type = DATE_SHORT,
 		};
-		format_commit_message(commit, "%h (%s, %ad)", msgbuf, &ctx);
+		repo_format_commit_message(the_repository, commit,
+					   "%h (%s, %ad)", msgbuf, &ctx);
 	} else {
 		strbuf_addstr(msgbuf, oid_to_hex(&commit->object.oid));
 	}
diff --git a/t/helper/test-revision-walking.c b/t/helper/test-revision-walking.c
index 4a45d5bac2a..c7b22cb33d5 100644
--- a/t/helper/test-revision-walking.c
+++ b/t/helper/test-revision-walking.c
@@ -19,7 +19,8 @@ static void print_commit(struct commit *commit)
 	struct strbuf sb = STRBUF_INIT;
 	struct pretty_print_context ctx = {0};
 	ctx.date_mode.type = DATE_NORMAL;
-	format_commit_message(commit, " %m %s", &sb, &ctx);
+	repo_format_commit_message(the_repository, commit, " %m %s", &sb,
+				   &ctx);
 	printf("%s\n", sb.buf);
 	strbuf_release(&sb);
 }
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 11/17] cocci: apply the "packfile.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (9 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 10/17] cocci: apply the "pretty.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 12/17] cocci: apply the "promisor-remote.h" " Ævar Arnfjörð Bjarmason
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"packfile.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/gc.c                                    | 2 +-
 commit-graph.c                                  | 2 +-
 contrib/coccinelle/the_repository.cocci         | 4 ++++
 contrib/coccinelle/the_repository.pending.cocci | 4 ----
 packfile.h                                      | 1 -
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/builtin/gc.c b/builtin/gc.c
index e60decbc56c..bef26020f99 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -284,7 +284,7 @@ static uint64_t total_ram(void)
 
 static uint64_t estimate_repack_memory(struct packed_git *pack)
 {
-	unsigned long nr_objects = approximate_object_count();
+	unsigned long nr_objects = repo_approximate_object_count(the_repository);
 	size_t os_cache, heap;
 
 	if (!pack || !nr_objects)
diff --git a/commit-graph.c b/commit-graph.c
index 8273085aa60..268410e913c 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2360,7 +2360,7 @@ int write_commit_graph(struct object_directory *odb,
 			replace = ctx->opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;
 	}
 
-	ctx->approx_nr_objects = approximate_object_count();
+	ctx->approx_nr_objects = repo_approximate_object_count(the_repository);
 
 	if (ctx->append && ctx->r->objects->commit_graph) {
 		struct commit_graph *g = ctx->r->objects->commit_graph;
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index ff4c56114f1..a325361f961 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -91,6 +91,10 @@
 |
 - format_commit_message
 + repo_format_commit_message
+// packfile.h
+|
+- approximate_object_count
++ repo_approximate_object_count
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 375850e773c..9b426e49e66 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// packfile.h
-- approximate_object_count
-+ repo_approximate_object_count
 // promisor-remote.h
-|
 - promisor_remote_reinit
 + repo_promisor_remote_reinit
 |
diff --git a/packfile.h b/packfile.h
index a3f6723857b..6ec16567971 100644
--- a/packfile.h
+++ b/packfile.h
@@ -65,7 +65,6 @@ struct packed_git *get_all_packs(struct repository *r);
  * for speed.
  */
 unsigned long repo_approximate_object_count(struct repository *r);
-#define approximate_object_count() repo_approximate_object_count(the_repository)
 
 struct packed_git *find_sha1_pack(const unsigned char *sha1,
 				  struct packed_git *packs);
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 12/17] cocci: apply the "promisor-remote.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (10 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 11/17] cocci: apply the "packfile.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 13/17] cocci: apply the "refs.h" " Ævar Arnfjörð Bjarmason
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"promisor-remote.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/cat-file.c                              |  2 +-
 builtin/fetch.c                                 |  4 ++--
 builtin/gc.c                                    |  2 +-
 builtin/index-pack.c                            |  2 +-
 builtin/pack-objects.c                          |  2 +-
 builtin/repack.c                                |  2 +-
 cache-tree.c                                    |  4 ++--
 connected.c                                     |  4 ++--
 contrib/coccinelle/the_repository.cocci         | 10 ++++++++++
 contrib/coccinelle/the_repository.pending.cocci | 10 ----------
 diff.c                                          |  2 +-
 diffcore-break.c                                |  2 +-
 diffcore-rename.c                               |  4 ++--
 list-objects-filter-options.c                   |  7 ++++---
 merge-ort.c                                     |  2 +-
 packfile.c                                      |  2 +-
 promisor-remote.h                               | 15 ---------------
 unpack-trees.c                                  |  2 +-
 18 files changed, 32 insertions(+), 46 deletions(-)

diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index caf2d258619..b72dd91bd1f 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -792,7 +792,7 @@ static int batch_objects(struct batch_options *opt)
 		if (!memcmp(&data.info, &empty, sizeof(empty)))
 			data.skip_object_info = 1;
 
-		if (has_promisor_remote())
+		if (repo_has_promisor_remote(the_repository))
 			warning("This repository uses promisor remotes. Some objects may not be loaded.");
 
 		read_replace_refs = 0;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 784e344d2bb..0020015ca42 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2008,7 +2008,7 @@ static inline void fetch_one_setup_partial(struct remote *remote)
 	 * If no prior partial clone/fetch and the current fetch DID NOT
 	 * request a partial-fetch, do a normal fetch.
 	 */
-	if (!has_promisor_remote() && !filter_options.choice)
+	if (!repo_has_promisor_remote(the_repository) && !filter_options.choice)
 		return;
 
 	/*
@@ -2264,7 +2264,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 			printf("%s\n", oid_to_hex(oid));
 		oidset_clear(&acked_commits);
 	} else if (remote) {
-		if (filter_options.choice || has_promisor_remote())
+		if (filter_options.choice || repo_has_promisor_remote(the_repository))
 			fetch_one_setup_partial(remote);
 		result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs);
 	} else {
diff --git a/builtin/gc.c b/builtin/gc.c
index bef26020f99..a1a2ae4da29 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -699,7 +699,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 			strvec_push(&prune, prune_expire);
 			if (quiet)
 				strvec_push(&prune, "--no-progress");
-			if (has_promisor_remote())
+			if (repo_has_promisor_remote(the_repository))
 				strvec_push(&prune,
 					    "--exclude-promisor-objects");
 			prune_cmd.git_cmd = 1;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 4cf69ee1d97..de47f3f6441 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1390,7 +1390,7 @@ static void fix_unresolved_deltas(struct hashfile *f)
 		sorted_by_pos[i] = &ref_deltas[i];
 	QSORT(sorted_by_pos, nr_ref_deltas, delta_pos_compare);
 
-	if (has_promisor_remote()) {
+	if (repo_has_promisor_remote(the_repository)) {
 		/*
 		 * Prefetch the delta bases.
 		 */
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 3c9b35642cb..2f2c02589b3 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2078,7 +2078,7 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
 
 	if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
 				     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
-		if (has_promisor_remote()) {
+		if (repo_has_promisor_remote(the_repository)) {
 			prefetch_to_pack(object_index);
 			if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
 						     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
diff --git a/builtin/repack.c b/builtin/repack.c
index f6493795318..25658fe732b 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -901,7 +901,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		strvec_push(&cmd.args, "--reflog");
 		strvec_push(&cmd.args, "--indexed-objects");
 	}
-	if (has_promisor_remote())
+	if (repo_has_promisor_remote(the_repository))
 		strvec_push(&cmd.args, "--exclude-promisor-objects");
 	if (!write_midx) {
 		if (write_bitmaps > 0)
diff --git a/cache-tree.c b/cache-tree.c
index 59610117d0b..ab2cc1edf29 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -240,7 +240,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
 
 static int must_check_existence(const struct cache_entry *ce)
 {
-	return !(has_promisor_remote() && ce_skip_worktree(ce));
+	return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce));
 }
 
 static int update_one(struct cache_tree *it,
@@ -470,7 +470,7 @@ int cache_tree_update(struct index_state *istate, int flags)
 	if (!istate->cache_tree)
 		istate->cache_tree = cache_tree();
 
-	if (!(flags & WRITE_TREE_MISSING_OK) && has_promisor_remote())
+	if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(the_repository))
 		prefetch_cache_entries(istate, must_check_existence);
 
 	trace_performance_enter();
diff --git a/connected.c b/connected.c
index b90fd61790c..5853fd7cbfd 100644
--- a/connected.c
+++ b/connected.c
@@ -54,7 +54,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
 		strbuf_release(&idx_file);
 	}
 
-	if (has_promisor_remote()) {
+	if (repo_has_promisor_remote(the_repository)) {
 		/*
 		 * For partial clones, we don't want to have to do a regular
 		 * connectivity check because we have to enumerate and exclude
@@ -97,7 +97,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
 	strvec_push(&rev_list.args,"rev-list");
 	strvec_push(&rev_list.args, "--objects");
 	strvec_push(&rev_list.args, "--stdin");
-	if (has_promisor_remote())
+	if (repo_has_promisor_remote(the_repository))
 		strvec_push(&rev_list.args, "--exclude-promisor-objects");
 	if (!opt->is_deepening_fetch) {
 		strvec_push(&rev_list.args, "--not");
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index a325361f961..d5b644a8687 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -95,6 +95,16 @@
 |
 - approximate_object_count
 + repo_approximate_object_count
+// promisor-remote.h
+|
+- promisor_remote_reinit
++ repo_promisor_remote_reinit
+|
+- promisor_remote_find
++ repo_promisor_remote_find
+|
+- has_promisor_remote
++ repo_has_promisor_remote
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 9b426e49e66..e17a60198c5 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,17 +5,7 @@
 @@
 @@
 (
-// promisor-remote.h
-- promisor_remote_reinit
-+ repo_promisor_remote_reinit
-|
-- promisor_remote_find
-+ repo_promisor_remote_find
-|
-- has_promisor_remote
-+ repo_has_promisor_remote
 // refs.h
-|
 - dwim_ref
 + repo_dwim_ref
 // rerere.h
diff --git a/diff.c b/diff.c
index 3abeca9d46c..5278343f95a 100644
--- a/diff.c
+++ b/diff.c
@@ -6860,7 +6860,7 @@ void diffcore_std(struct diff_options *options)
 	 * If no prefetching occurs, diffcore_rename() will prefetch if it
 	 * decides that it needs inexact rename detection.
 	 */
-	if (options->repo == the_repository && has_promisor_remote() &&
+	if (options->repo == the_repository && repo_has_promisor_remote(the_repository) &&
 	    (options->output_format & output_formats_to_prefetch ||
 	     options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
 		diff_queued_diff_prefetch(options->repo);
diff --git a/diffcore-break.c b/diffcore-break.c
index 0d4a14964d0..5462420bbbe 100644
--- a/diffcore-break.c
+++ b/diffcore-break.c
@@ -65,7 +65,7 @@ static int should_break(struct repository *r,
 	    oideq(&src->oid, &dst->oid))
 		return 0; /* they are the same */
 
-	if (r == the_repository && has_promisor_remote()) {
+	if (r == the_repository && repo_has_promisor_remote(the_repository)) {
 		options.missing_object_cb = diff_queued_diff_prefetch;
 		options.missing_object_data = r;
 	}
diff --git a/diffcore-rename.c b/diffcore-rename.c
index c0422d9e709..a97b1322b51 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -981,7 +981,7 @@ static int find_basename_matches(struct diff_options *options,
 			strintmap_set(&dests, base, i);
 	}
 
-	if (options->repo == the_repository && has_promisor_remote()) {
+	if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {
 		dpf_options.missing_object_cb = basename_prefetch;
 		dpf_options.missing_object_data = &prefetch_options;
 	}
@@ -1567,7 +1567,7 @@ void diffcore_rename_extended(struct diff_options *options,
 
 	/* Finish setting up dpf_options */
 	prefetch_options.skip_unmodified = skip_unmodified;
-	if (options->repo == the_repository && has_promisor_remote()) {
+	if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {
 		dpf_options.missing_object_cb = inexact_prefetch;
 		dpf_options.missing_object_data = &prefetch_options;
 	}
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index ee01bcd2cc3..ccfeabc4778 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -341,7 +341,7 @@ void partial_clone_register(
 	char *filter_name;
 
 	/* Check if it is already registered */
-	if ((promisor_remote = promisor_remote_find(remote))) {
+	if ((promisor_remote = repo_promisor_remote_find(the_repository, remote))) {
 		if (promisor_remote->partial_clone_filter)
 			/*
 			 * Remote is already registered and a filter is already
@@ -369,14 +369,15 @@ void partial_clone_register(
 	free(filter_name);
 
 	/* Make sure the config info are reset */
-	promisor_remote_reinit();
+	repo_promisor_remote_reinit(the_repository);
 }
 
 void partial_clone_get_default_filter_spec(
 	struct list_objects_filter_options *filter_options,
 	const char *remote)
 {
-	struct promisor_remote *promisor = promisor_remote_find(remote);
+	struct promisor_remote *promisor = repo_promisor_remote_find(the_repository,
+								     remote);
 	struct strbuf errbuf = STRBUF_INIT;
 
 	/*
diff --git a/merge-ort.c b/merge-ort.c
index 979e8b057b1..ba3f5607bbb 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4216,7 +4216,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,
 	struct string_list_item *e;
 	struct oid_array to_fetch = OID_ARRAY_INIT;
 
-	if (opt->repo != the_repository || !has_promisor_remote())
+	if (opt->repo != the_repository || !repo_has_promisor_remote(the_repository))
 		return;
 
 	for (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {
diff --git a/packfile.c b/packfile.c
index 79e21ab18e7..4aee73d545f 100644
--- a/packfile.c
+++ b/packfile.c
@@ -2263,7 +2263,7 @@ int is_promisor_object(const struct object_id *oid)
 	static int promisor_objects_prepared;
 
 	if (!promisor_objects_prepared) {
-		if (has_promisor_remote()) {
+		if (repo_has_promisor_remote(the_repository)) {
 			for_each_packed_object(add_promisor_object,
 					       &promisor_objects,
 					       FOR_EACH_OBJECT_PROMISOR_ONLY |
diff --git a/promisor-remote.h b/promisor-remote.h
index df36eb08efc..2cb9eda9ea4 100644
--- a/promisor-remote.h
+++ b/promisor-remote.h
@@ -18,24 +18,9 @@ struct promisor_remote {
 };
 
 void repo_promisor_remote_reinit(struct repository *r);
-static inline void promisor_remote_reinit(void)
-{
-	repo_promisor_remote_reinit(the_repository);
-}
-
 void promisor_remote_clear(struct promisor_remote_config *config);
-
 struct promisor_remote *repo_promisor_remote_find(struct repository *r, const char *remote_name);
-static inline struct promisor_remote *promisor_remote_find(const char *remote_name)
-{
-	return repo_promisor_remote_find(the_repository, remote_name);
-}
-
 int repo_has_promisor_remote(struct repository *r);
-static inline int has_promisor_remote(void)
-{
-	return repo_has_promisor_remote(the_repository);
-}
 
 /*
  * Fetches all requested objects from all promisor remotes, trying them one at
diff --git a/unpack-trees.c b/unpack-trees.c
index 3d05e45a279..b82ad7e45d0 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -458,7 +458,7 @@ static int check_updates(struct unpack_trees_options *o,
 	if (should_update_submodules())
 		load_gitmodules_file(index, &state);
 
-	if (has_promisor_remote())
+	if (repo_has_promisor_remote(the_repository))
 		/*
 		 * Prefetch the objects that are to be checked out in the loop
 		 * below.
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 13/17] cocci: apply the "refs.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (11 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 12/17] cocci: apply the "promisor-remote.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 14/17] cocci: apply the "rerere.h" " Ævar Arnfjörð Bjarmason
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"refs.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 archive.c                                       | 5 +++--
 branch.c                                        | 3 ++-
 builtin/checkout.c                              | 6 ++++--
 builtin/fast-export.c                           | 3 ++-
 builtin/log.c                                   | 3 ++-
 builtin/merge.c                                 | 3 ++-
 builtin/reset.c                                 | 3 ++-
 builtin/rev-parse.c                             | 4 +++-
 builtin/show-branch.c                           | 3 ++-
 builtin/stash.c                                 | 3 ++-
 bundle.c                                        | 3 ++-
 commit.c                                        | 3 ++-
 contrib/coccinelle/the_repository.cocci         | 4 ++++
 contrib/coccinelle/the_repository.pending.cocci | 4 ----
 refs.h                                          | 6 ------
 remote.c                                        | 5 +++--
 wt-status.c                                     | 3 ++-
 17 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/archive.c b/archive.c
index d43687a5c44..716a18567bc 100644
--- a/archive.c
+++ b/archive.c
@@ -456,10 +456,11 @@ static void parse_treeish_arg(const char **argv,
 		const char *colon = strchrnul(name, ':');
 		int refnamelen = colon - name;
 
-		if (!dwim_ref(name, refnamelen, &oid, &ref, 0))
+		if (!repo_dwim_ref(the_repository, name, refnamelen, &oid, &ref, 0))
 			die(_("no such ref: %.*s"), refnamelen, name);
 	} else {
-		dwim_ref(name, strlen(name), &oid, &ref, 0);
+		repo_dwim_ref(the_repository, name, strlen(name), &oid, &ref,
+			      0);
 	}
 
 	if (repo_get_oid(the_repository, name, &oid))
diff --git a/branch.c b/branch.c
index 2efb5fbaa5f..a01e465b114 100644
--- a/branch.c
+++ b/branch.c
@@ -541,7 +541,8 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
 		die(_("not a valid object name: '%s'"), start_name);
 	}
 
-	switch (dwim_ref(start_name, strlen(start_name), &oid, &real_ref, 0)) {
+	switch (repo_dwim_ref(the_repository, start_name, strlen(start_name),
+			      &oid, &real_ref, 0)) {
 	case 0:
 		/* Not branching from any existing branch */
 		if (explicit_tracking)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 1d1f33e33e7..cb7cd315b34 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -703,7 +703,8 @@ static void setup_branch_path(struct branch_info *branch)
 	 * If this is a ref, resolve it; otherwise, look up the OID for our
 	 * expression.  Failure here is okay.
 	 */
-	if (!dwim_ref(branch->name, strlen(branch->name), &branch->oid, &branch->refname, 0))
+	if (!repo_dwim_ref(the_repository, branch->name, strlen(branch->name),
+			   &branch->oid, &branch->refname, 0))
 		repo_get_oid_committish(the_repository, branch->name, &branch->oid);
 
 	strbuf_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL);
@@ -1424,7 +1425,8 @@ static void die_expecting_a_branch(const struct branch_info *branch_info)
 	char *to_free;
 	int code;
 
-	if (dwim_ref(branch_info->name, strlen(branch_info->name), &oid, &to_free, 0) == 1) {
+	if (repo_dwim_ref(the_repository, branch_info->name,
+			  strlen(branch_info->name), &oid, &to_free, 0) == 1) {
 		const char *ref = to_free;
 
 		if (skip_prefix(ref, "refs/tags/", &ref))
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 6515bd2ad8b..550f078a8ed 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -918,7 +918,8 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
 		if (e->flags & UNINTERESTING)
 			continue;
 
-		if (dwim_ref(e->name, strlen(e->name), &oid, &full_name, 0) != 1)
+		if (repo_dwim_ref(the_repository, e->name, strlen(e->name),
+				  &oid, &full_name, 0) != 1)
 			continue;
 
 		if (refspecs.nr) {
diff --git a/builtin/log.c b/builtin/log.c
index 3dde77bde27..acf3faecd81 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1204,7 +1204,8 @@ static char *find_branch_name(struct rev_info *rev)
 		return NULL;
 	ref = rev->cmdline.rev[positive].name;
 	tip_oid = &rev->cmdline.rev[positive].item->oid;
-	if (dwim_ref(ref, strlen(ref), &branch_oid, &full_ref, 0) &&
+	if (repo_dwim_ref(the_repository, ref, strlen(ref), &branch_oid,
+			  &full_ref, 0) &&
 	    skip_prefix(full_ref, "refs/heads/", &v) &&
 	    oideq(tip_oid, &branch_oid))
 		branch = xstrdup(v);
diff --git a/builtin/merge.c b/builtin/merge.c
index 197e152aba9..69666546ca2 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -517,7 +517,8 @@ static void merge_name(const char *remote, struct strbuf *msg)
 	if (!remote_head)
 		die(_("'%s' does not point to a commit"), remote);
 
-	if (dwim_ref(remote, strlen(remote), &branch_head, &found_ref, 0) > 0) {
+	if (repo_dwim_ref(the_repository, remote, strlen(remote), &branch_head,
+			  &found_ref, 0) > 0) {
 		if (starts_with(found_ref, "refs/heads/")) {
 			strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
 				    oid_to_hex(&branch_head), remote);
diff --git a/builtin/reset.c b/builtin/reset.c
index 75b447ffdc6..b65f379440b 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -465,7 +465,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 			char *ref = NULL;
 			int err;
 
-			dwim_ref(rev, strlen(rev), &dummy, &ref, 0);
+			repo_dwim_ref(the_repository, rev, strlen(rev),
+				      &dummy, &ref, 0);
 			if (ref && !starts_with(ref, "refs/"))
 				FREE_AND_NULL(ref);
 
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 5685cf0ea7d..663f282c5f7 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -136,7 +136,9 @@ static void show_rev(int type, const struct object_id *oid, const char *name)
 			struct object_id discard;
 			char *full;
 
-			switch (dwim_ref(name, strlen(name), &discard, &full, 0)) {
+			switch (repo_dwim_ref(the_repository, name,
+					      strlen(name), &discard, &full,
+					      0)) {
 			case 0:
 				/*
 				 * Not found -- not a ref.  We could
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index d60e536a53b..af680485d58 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -746,7 +746,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 			die(Q_("only %d entry can be shown at one time.",
 			       "only %d entries can be shown at one time.",
 			       MAX_REVS), MAX_REVS);
-		if (!dwim_ref(*av, strlen(*av), &oid, &ref, 0))
+		if (!repo_dwim_ref(the_repository, *av, strlen(*av), &oid,
+				   &ref, 0))
 			die(_("no such ref %s"), *av);
 
 		/* Has the base been specified? */
diff --git a/builtin/stash.c b/builtin/stash.c
index 6c062e52048..364273f1012 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -211,7 +211,8 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
 	end_of_rev = strchrnul(revision, '@');
 	strbuf_add(&symbolic, revision, end_of_rev - revision);
 
-	ret = dwim_ref(symbolic.buf, symbolic.len, &dummy, &expanded_ref, 0);
+	ret = repo_dwim_ref(the_repository, symbolic.buf, symbolic.len,
+			    &dummy, &expanded_ref, 0);
 	strbuf_release(&symbolic);
 	switch (ret) {
 	case 0: /* Not found, but valid ref */
diff --git a/bundle.c b/bundle.c
index 9b57bade7a6..dca96e51ee0 100644
--- a/bundle.c
+++ b/bundle.c
@@ -382,7 +382,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 
 		if (e->item->flags & UNINTERESTING)
 			continue;
-		if (dwim_ref(e->name, strlen(e->name), &oid, &ref, 0) != 1)
+		if (repo_dwim_ref(the_repository, e->name, strlen(e->name),
+				  &oid, &ref, 0) != 1)
 			goto skip_write_ref;
 		if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flag))
 			flag = 0;
diff --git a/commit.c b/commit.c
index dd22e76c3e1..0e2fc7dbab8 100644
--- a/commit.c
+++ b/commit.c
@@ -996,7 +996,8 @@ struct commit *get_fork_point(const char *refname, struct commit *commit)
 	struct commit *ret = NULL;
 	char *full_refname;
 
-	switch (dwim_ref(refname, strlen(refname), &oid, &full_refname, 0)) {
+	switch (repo_dwim_ref(the_repository, refname, strlen(refname), &oid,
+			      &full_refname, 0)) {
 	case 0:
 		die("No such ref: '%s'", refname);
 	case 1:
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index d5b644a8687..b20a3e70845 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -105,6 +105,10 @@
 |
 - has_promisor_remote
 + repo_has_promisor_remote
+// refs.h
+|
+- dwim_ref
++ repo_dwim_ref
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index e17a60198c5..8bf30798a04 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// refs.h
-- dwim_ref
-+ repo_dwim_ref
 // rerere.h
-|
 - rerere
 + repo_rerere
 // revision.h
diff --git a/refs.h b/refs.h
index 935cdd1ece3..2998244b615 100644
--- a/refs.h
+++ b/refs.h
@@ -159,12 +159,6 @@ int expand_ref(struct repository *r, const char *str, int len, struct object_id
 int repo_dwim_ref(struct repository *r, const char *str, int len,
 		  struct object_id *oid, char **ref, int nonfatal_dangling_mark);
 int repo_dwim_log(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
-static inline int dwim_ref(const char *str, int len, struct object_id *oid,
-			   char **ref, int nonfatal_dangling_mark)
-{
-	return repo_dwim_ref(the_repository, str, len, oid, ref,
-			     nonfatal_dangling_mark);
-}
 int dwim_log(const char *str, int len, struct object_id *oid, char **ref);
 
 /*
diff --git a/remote.c b/remote.c
index 12f6bea6252..a03b03e467e 100644
--- a/remote.c
+++ b/remote.c
@@ -1808,8 +1808,9 @@ static void set_merge(struct remote_state *remote_state, struct branch *ret)
 		if (!remote_find_tracking(remote, ret->merge[i]) ||
 		    strcmp(ret->remote_name, "."))
 			continue;
-		if (dwim_ref(ret->merge_name[i], strlen(ret->merge_name[i]),
-			     &oid, &ref, 0) == 1)
+		if (repo_dwim_ref(the_repository, ret->merge_name[i],
+				  strlen(ret->merge_name[i]), &oid, &ref,
+				  0) == 1)
 			ret->merge[i]->dst = ref;
 		else
 			ret->merge[i]->dst = xstrdup(ret->merge_name[i]);
diff --git a/wt-status.c b/wt-status.c
index c55c51b1924..dcd1d0cee4c 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1664,7 +1664,8 @@ static void wt_status_get_detached_from(struct repository *r,
 		return;
 	}
 
-	if (dwim_ref(cb.buf.buf, cb.buf.len, &oid, &ref, 1) == 1 &&
+	if (repo_dwim_ref(the_repository, cb.buf.buf, cb.buf.len, &oid, &ref,
+			  1) == 1 &&
 	    /* oid is a commit? match without further lookup */
 	    (oideq(&cb.noid, &oid) ||
 	     /* perhaps oid is a tag, try to dereference to a commit */
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 14/17] cocci: apply the "rerere.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (12 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 13/17] cocci: apply the "refs.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-17 15:35 ` [PATCH 15/17] cocci: apply the "revision.h" " Ævar Arnfjörð Bjarmason
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"rerere.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/stash.c                                 | 2 +-
 contrib/coccinelle/the_repository.cocci         | 4 ++++
 contrib/coccinelle/the_repository.pending.cocci | 4 ----
 rerere.h                                        | 3 ---
 4 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/builtin/stash.c b/builtin/stash.c
index 364273f1012..2017c278df2 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -601,7 +601,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
 		ret = error(_("could not write index"));
 
 	if (ret) {
-		rerere(0);
+		repo_rerere(the_repository, 0);
 
 		if (index)
 			fprintf_ln(stderr, _("Index was not unstashed."));
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index b20a3e70845..1d1ac7d4fc5 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -109,6 +109,10 @@
 |
 - dwim_ref
 + repo_dwim_ref
+// rerere.h
+|
+- rerere
++ repo_rerere
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 8bf30798a04..1190a3312bd 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// rerere.h
-- rerere
-+ repo_rerere
 // revision.h
-|
 - init_revisions
 + repo_init_revisions
 )
diff --git a/rerere.h b/rerere.h
index c32d79c3bd8..876c316321e 100644
--- a/rerere.h
+++ b/rerere.h
@@ -24,9 +24,6 @@ struct rerere_id {
 };
 
 int setup_rerere(struct repository *,struct string_list *, int);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define rerere(flags) repo_rerere(the_repository, flags)
-#endif
 int repo_rerere(struct repository *, int);
 /*
  * Given the conflict ID and the name of a "file" used for replaying
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 15/17] cocci: apply the "revision.h" part of "the_repository.pending"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (13 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 14/17] cocci: apply the "rerere.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-22 23:38   ` Glen Choo
  2023-03-17 15:35 ` [PATCH 16/17] post-cocci: adjust comments for recent repo_* migration Ævar Arnfjörð Bjarmason
                   ` (3 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"revision.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 add-interactive.c                               |  2 +-
 builtin/bisect.c                                |  4 ++--
 builtin/stash.c                                 |  6 +++---
 builtin/submodule--helper.c                     |  2 +-
 contrib/coccinelle/the_repository.cocci         |  4 ++++
 contrib/coccinelle/the_repository.pending.cocci | 14 --------------
 range-diff.c                                    |  2 +-
 revision.h                                      |  3 ---
 8 files changed, 12 insertions(+), 25 deletions(-)
 delete mode 100644 contrib/coccinelle/the_repository.pending.cocci

diff --git a/add-interactive.c b/add-interactive.c
index 00a0f6f96f3..33f41d65a47 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -551,7 +551,7 @@ static int get_modified_files(struct repository *r,
 		opt.def = is_initial ?
 			empty_tree_oid_hex() : oid_to_hex(&head_oid);
 
-		init_revisions(&rev, NULL);
+		repo_init_revisions(the_repository, &rev, NULL);
 		setup_revisions(0, NULL, &rev, &opt);
 
 		rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 34ba7b18f69..0f35361bd16 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -568,7 +568,7 @@ static int prepare_revs(struct bisect_terms *terms, struct rev_info *revs)
 	 * sets up a revision walk.
 	 */
 	reset_revision_walk();
-	init_revisions(revs, NULL);
+	repo_init_revisions(the_repository, revs, NULL);
 	setup_revisions(0, NULL, revs, NULL);
 	for_each_glob_ref_in(add_bisect_ref, bad, "refs/bisect/", &cb);
 	cb.object_flags = UNINTERESTING;
@@ -1095,7 +1095,7 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, int argc,
 			struct rev_info revs;
 			struct commit *commit;
 
-			init_revisions(&revs, NULL);
+			repo_init_revisions(the_repository, &revs, NULL);
 			setup_revisions(2, argv + i - 1, &revs, NULL);
 
 			if (prepare_revision_walk(&revs))
diff --git a/builtin/stash.c b/builtin/stash.c
index 2017c278df2..888ffa07288 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -901,7 +901,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
 
 	init_diff_ui_defaults();
 	git_config(git_diff_ui_config, NULL);
-	init_revisions(&rev, prefix);
+	repo_init_revisions(the_repository, &rev, prefix);
 
 	argc = parse_options(argc, argv, prefix, options, git_stash_show_usage,
 			     PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT |
@@ -1090,7 +1090,7 @@ static int check_changes_tracked_files(const struct pathspec *ps)
 	if (repo_read_index(the_repository) < 0)
 		return -1;
 
-	init_revisions(&rev, NULL);
+	repo_init_revisions(the_repository, &rev, NULL);
 	copy_pathspec(&rev.prune_data, ps);
 
 	rev.diffopt.flags.quick = 1;
@@ -1277,7 +1277,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
 	struct strbuf diff_output = STRBUF_INIT;
 	struct index_state istate = INDEX_STATE_INIT(the_repository);
 
-	init_revisions(&rev, NULL);
+	repo_init_revisions(the_repository, &rev, NULL);
 	copy_pathspec(&rev.prune_data, ps);
 
 	set_alternate_index_output(stash_index_path.buf);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 25c70f415f1..32b8e498172 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1108,7 +1108,7 @@ static int compute_summary_module_list(struct object_id *head_oid,
 		strvec_pushv(&diff_args, info->argv);
 
 	git_config(git_diff_basic_config, NULL);
-	init_revisions(&rev, info->prefix);
+	repo_init_revisions(the_repository, &rev, info->prefix);
 	rev.abbrev = 0;
 	precompose_argv_prefix(diff_args.nr, diff_args.v, NULL);
 	setup_revisions(diff_args.nr, diff_args.v, &rev, &opt);
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index 1d1ac7d4fc5..765ad689678 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -113,6 +113,10 @@
 |
 - rerere
 + repo_rerere
+// revision.h
+|
+- init_revisions
++ repo_init_revisions
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
deleted file mode 100644
index 1190a3312bd..00000000000
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ /dev/null
@@ -1,14 +0,0 @@
-// This file is used for the ongoing refactoring of
-// bringing the index or repository struct in all of
-// our code base.
-
-@@
-@@
-(
-// revision.h
-- init_revisions
-+ repo_init_revisions
-)
-  (
-+ the_repository,
-  ...)
diff --git a/range-diff.c b/range-diff.c
index 15d0bc35a87..ff5d19f8add 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -588,7 +588,7 @@ int is_range_diff_range(const char *arg)
 	int i, positive = 0, negative = 0;
 	struct rev_info revs;
 
-	init_revisions(&revs, NULL);
+	repo_init_revisions(the_repository, &revs, NULL);
 	if (setup_revisions(3, argv, &revs, NULL) == 1) {
 		for (i = 0; i < revs.pending.nr; i++)
 			if (revs.pending.objects[i].item->flags & UNINTERESTING)
diff --git a/revision.h b/revision.h
index 30febad09a1..eeb91677d07 100644
--- a/revision.h
+++ b/revision.h
@@ -415,9 +415,6 @@ struct rev_info {
 void repo_init_revisions(struct repository *r,
 			 struct rev_info *revs,
 			 const char *prefix);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define init_revisions(revs, prefix) repo_init_revisions(the_repository, revs, prefix)
-#endif
 
 /**
  * Parse revision information, filling in the `rev_info` structure, and
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 16/17] post-cocci: adjust comments for recent repo_* migration
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (14 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 15/17] cocci: apply the "revision.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-19  6:12   ` Elijah Newren
  2023-03-17 15:35 ` [PATCH 17/17] libs: use "struct repository *" argument, not "the_repository" Ævar Arnfjörð Bjarmason
                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

In preceding commits we changed many calls to macros that were
providing a "the_repository" argument to invoke corresponding repo_*()
function instead. Let's follow-up and adjust references to those in
comments, which coccinelle didn't (and inherently can't) catch.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/branch.c   | 2 +-
 builtin/shortlog.c | 2 +-
 cache.h            | 4 ++--
 commit.h           | 4 ++--
 diff.h             | 2 +-
 object-file.c      | 2 +-
 object-store.h     | 4 ++--
 pretty.c           | 2 +-
 refs.c             | 2 +-
 sequencer.c        | 6 +++---
 strbuf.h           | 6 +++---
 11 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index bbcfb34b3c6..45910039e6b 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -156,7 +156,7 @@ static int branch_merged(int kind, const char *name,
 	/*
 	 * After the safety valve is fully redefined to "check with
 	 * upstream, if any, otherwise with HEAD", we should just
-	 * return the result of the in_merge_bases() above without
+	 * return the result of the repo_in_merge_bases() above without
 	 * any of the following code, but during the transition period,
 	 * a gentle reminder is in order.
 	 */
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 62f91b8b932..f287a6acd03 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -176,7 +176,7 @@ static void insert_records_from_trailers(struct shortlog *log,
 		return;
 
 	/*
-	 * Using format_commit_message("%B") would be simpler here, but
+	 * Using repo_format_commit_message("%B") would be simpler here, but
 	 * this saves us copying the message.
 	 */
 	commit_buffer = repo_logmsg_reencode(the_repository, commit, NULL,
diff --git a/cache.h b/cache.h
index d835ac8b4d2..555354e1961 100644
--- a/cache.h
+++ b/cache.h
@@ -443,7 +443,7 @@ void validate_cache_entries(const struct index_state *istate);
 /*
  * Bulk prefetch all missing cache entries that are not GITLINKs and that match
  * the given predicate. This function should only be called if
- * has_promisor_remote() returns true.
+ * repo_has_promisor_remote() returns true.
  */
 typedef int (*must_prefetch_predicate)(const struct cache_entry *);
 void prefetch_cache_entries(const struct index_state *istate,
@@ -1201,7 +1201,7 @@ void check_repository_format(struct repository_format *fmt);
  * terminated.
  *
  * The non-`_r` version returns a static buffer which remains valid until 4
- * more calls to find_unique_abbrev are made.
+ * more calls to repo_find_unique_abbrev are made.
  *
  * The `_r` variant writes to a buffer supplied by the caller, which must be at
  * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
diff --git a/commit.h b/commit.h
index e98ee6e698e..d4adf111019 100644
--- a/commit.h
+++ b/commit.h
@@ -130,7 +130,7 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,
 /*
  * Get the commit's object contents, either from cache or by reading the object
  * from disk. The resulting memory should not be modified, and must be given
- * to unuse_commit_buffer when the caller is done.
+ * to repo_unuse_commit_buffer when the caller is done.
  */
 const void *repo_get_commit_buffer(struct repository *r,
 				   const struct commit *,
@@ -139,7 +139,7 @@ const void *repo_get_commit_buffer(struct repository *r,
 /*
  * Tell the commit subsystem that we are done with a particular commit buffer.
  * The commit and buffer should be the input and return value, respectively,
- * from an earlier call to get_commit_buffer.  The buffer may or may not be
+ * from an earlier call to repo_get_commit_buffer.  The buffer may or may not be
  * freed by this call; callers should not access the memory afterwards.
  */
 void repo_unuse_commit_buffer(struct repository *r,
diff --git a/diff.h b/diff.h
index 8b510eb579d..0aa36e81261 100644
--- a/diff.h
+++ b/diff.h
@@ -614,7 +614,7 @@ void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc);
 #define DIFF_STATUS_FILTER_BROKEN	'B'
 
 /*
- * This is different from find_unique_abbrev() in that
+ * This is different from repo_find_unique_abbrev() in that
  * it stuffs the result with dots for alignment.
  */
 const char *diff_aligned_abbrev(const struct object_id *sha1, int);
diff --git a/object-file.c b/object-file.c
index 141cf85f25b..47c52681640 100644
--- a/object-file.c
+++ b/object-file.c
@@ -267,7 +267,7 @@ int hash_algo_by_length(int len)
 
 /*
  * This is meant to hold a *small* number of objects that you would
- * want read_object_file() to be able to return, but yet you do not want
+ * want repo_read_object_file() to be able to return, but yet you do not want
  * to write them into the object store (e.g. a browse-only
  * application).
  */
diff --git a/object-store.h b/object-store.h
index b47849d4e7e..9217ae83064 100644
--- a/object-store.h
+++ b/object-store.h
@@ -216,7 +216,7 @@ struct raw_object_store {
 	/*
 	 * A fast, rough count of the number of objects in the repository.
 	 * These two fields are not meant for direct access. Use
-	 * approximate_object_count() instead.
+	 * repo_approximate_object_count() instead.
 	 */
 	unsigned long approximate_object_count;
 	unsigned approximate_object_count_valid : 1;
@@ -343,7 +343,7 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect);
 
 /*
  * Enabling the object read lock allows multiple threads to safely call the
- * following functions in parallel: repo_read_object_file(), read_object_file(),
+ * following functions in parallel: repo_read_object_file(),
  * read_object_with_reference(), oid_object_info() and oid_object_info_extended().
  *
  * obj_read_lock() and obj_read_unlock() may also be used to protect other
diff --git a/pretty.c b/pretty.c
index 076d1c363e7..23ac06b93f3 100644
--- a/pretty.c
+++ b/pretty.c
@@ -719,7 +719,7 @@ const char *repo_logmsg_reencode(struct repository *r,
 		 * Otherwise, we still want to munge the encoding header in the
 		 * result, which will be done by modifying the buffer. If we
 		 * are using a fresh copy, we can reuse it. But if we are using
-		 * the cached copy from get_commit_buffer, we need to duplicate it
+		 * the cached copy from repo_get_commit_buffer, we need to duplicate it
 		 * to avoid munging the cached copy.
 		 */
 		if (msg == get_cached_commit_buffer(r, commit, NULL))
diff --git a/refs.c b/refs.c
index aeae31c972f..cd7537bce64 100644
--- a/refs.c
+++ b/refs.c
@@ -1821,7 +1821,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
 			return NULL;
 
 		/*
-		 * dwim_ref() uses REF_ISBROKEN to distinguish between
+		 * repo_dwim_ref() uses REF_ISBROKEN to distinguish between
 		 * missing refs and refs that were present but invalid,
 		 * to complain about the latter to stderr.
 		 *
diff --git a/sequencer.c b/sequencer.c
index aa3ebb47d98..fb5a540fa04 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -768,9 +768,9 @@ static int is_index_unchanged(struct repository *r)
 	/*
 	 * If head_commit is NULL, check_commit, called from
 	 * lookup_commit, would have indicated that head_commit is not
-	 * a commit object already.  parse_commit() will return failure
+	 * a commit object already.  repo_parse_commit() will return failure
 	 * without further complaints in such a case.  Otherwise, if
-	 * the commit is invalid, parse_commit() will complain.  So
+	 * the commit is invalid, repo_parse_commit() will complain.  So
 	 * there is nothing for us to say here.  Just return failure.
 	 */
 	if (repo_parse_commit(the_repository, head_commit))
@@ -5365,7 +5365,7 @@ static const char *label_oid(struct object_id *oid, const char *label,
 	 * For "uninteresting" commits, i.e. commits that are not to be
 	 * rebased, and which can therefore not be labeled, we use a unique
 	 * abbreviation of the commit name. This is slightly more complicated
-	 * than calling find_unique_abbrev() because we also need to make
+	 * than calling repo_find_unique_abbrev() because we also need to make
 	 * sure that the abbreviation does not conflict with any other
 	 * label.
 	 *
diff --git a/strbuf.h b/strbuf.h
index f6dbb9681ee..b980f9edc6d 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -631,7 +631,7 @@ void strbuf_add_separated_string_list(struct strbuf *str,
 void strbuf_list_free(struct strbuf **list);
 
 /**
- * Add the abbreviation, as generated by find_unique_abbrev, of `sha1` to
+ * Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
  * the strbuf `sb`.
  */
 struct repository;
@@ -706,14 +706,14 @@ static inline void strbuf_complete_line(struct strbuf *sb)
 
 /*
  * Copy "name" to "sb", expanding any special @-marks as handled by
- * interpret_branch_name(). The result is a non-qualified branch name
+ * repo_interpret_branch_name(). The result is a non-qualified branch name
  * (so "foo" or "origin/master" instead of "refs/heads/foo" or
  * "refs/remotes/origin/master").
  *
  * Note that the resulting name may not be a syntactically valid refname.
  *
  * If "allowed" is non-zero, restrict the set of allowed expansions. See
- * interpret_branch_name() for details.
+ * repo_interpret_branch_name() for details.
  */
 void strbuf_branchname(struct strbuf *sb, const char *name,
 		       unsigned allowed);
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 17/17] libs: use "struct repository *" argument, not "the_repository"
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (15 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 16/17] post-cocci: adjust comments for recent repo_* migration Ævar Arnfjörð Bjarmason
@ 2023-03-17 15:35 ` Ævar Arnfjörð Bjarmason
  2023-03-19  6:19   ` Elijah Newren
  2023-03-17 19:22 ` [PATCH 00/17] cocci: remove "the_index" wrapper macros Junio C Hamano
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
  18 siblings, 1 reply; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-17 15:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

As can easily be seen from grepping in our sources, we had these uses
of "the_repository" in various library code in cases where the
function in question was already getting a "struct repository *"
argument. Let's use that argument instead.

Out of these changes only the changes to "cache-tree.c",
"commit-reach.c", "shallow.c" and "upload-pack.c" would have cleanly
applied before the migration away from the "repo_*()" wrapper macros
in the preceding commits.

The rest aren't new, as we'd previously implicitly refer to
"the_repository", but it's now more obvious that we were doing the
wrong thing all along, and should have used the parameter instead.

The change to change "get_index_format_default(the_repository)" in
"read-cache.c" to use the "r" variable instead should arguably have
been part of [1], or in the subsequent cleanup in [2]. Let's do it
here, as can be seen from the initial code in [3] it's not important
that we use "the_repository" there, but would prefer to always use the
current repository.

This change excludes the "the_repository" use in "upload-pack.c"'s
upload_pack_advertise(), as the in-flight [4] makes that change.

1. ee1f0c242ef (read-cache: add index.skipHash config option,
   2023-01-06)
2. 6269f8eaad0 (treewide: always have a valid "index_state.repo"
   member, 2023-01-17)
3. 7211b9e7534 (repo-settings: consolidate some config settings,
   2019-08-13)
4. <Y/hbUsGPVNAxTdmS@coredump.intra.peff.net>

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 add-interactive.c |   2 +-
 branch.c          |   8 ++--
 builtin/replace.c |   2 +-
 cache-tree.c      |   4 +-
 combine-diff.c    |   2 +-
 commit-graph.c    |   2 +-
 commit-reach.c    |   2 +-
 merge-recursive.c |   2 +-
 notes-cache.c     |   2 +-
 notes-utils.c     |   2 +-
 object-name.c     |   8 ++--
 read-cache.c      |   4 +-
 reset.c           |   2 +-
 sequencer.c       | 102 ++++++++++++++++++++++------------------------
 shallow.c         |   2 +-
 tree.c            |   2 +-
 wt-status.c       |  10 ++---
 17 files changed, 76 insertions(+), 82 deletions(-)

diff --git a/add-interactive.c b/add-interactive.c
index 33f41d65a47..02bf6fc15cb 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -551,7 +551,7 @@ static int get_modified_files(struct repository *r,
 		opt.def = is_initial ?
 			empty_tree_oid_hex() : oid_to_hex(&head_oid);
 
-		repo_init_revisions(the_repository, &rev, NULL);
+		repo_init_revisions(r, &rev, NULL);
 		setup_revisions(0, NULL, &rev, &opt);
 
 		rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
diff --git a/branch.c b/branch.c
index a01e465b114..2b266e6fcb9 100644
--- a/branch.c
+++ b/branch.c
@@ -531,7 +531,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
 		explicit_tracking = 1;
 
 	real_ref = NULL;
-	if (repo_get_oid_mb(the_repository, start_name, &oid)) {
+	if (repo_get_oid_mb(r, start_name, &oid)) {
 		if (explicit_tracking) {
 			int code = die_message(_(upstream_missing), start_name);
 			advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
@@ -541,8 +541,8 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
 		die(_("not a valid object name: '%s'"), start_name);
 	}
 
-	switch (repo_dwim_ref(the_repository, start_name, strlen(start_name),
-			      &oid, &real_ref, 0)) {
+	switch (repo_dwim_ref(r, start_name, strlen(start_name), &oid,
+			      &real_ref, 0)) {
 	case 0:
 		/* Not branching from any existing branch */
 		if (explicit_tracking)
@@ -773,7 +773,7 @@ void create_branches_recursively(struct repository *r, const char *name,
 			    name);
 	}
 
-	create_branch(the_repository, name, start_commitish, force, 0, reflog, quiet,
+	create_branch(r, name, start_commitish, force, 0, reflog, quiet,
 		      BRANCH_TRACK_NEVER, dry_run);
 	if (dry_run)
 		return;
diff --git a/builtin/replace.c b/builtin/replace.c
index 85f0b79c924..bd67107a7c7 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -54,7 +54,7 @@ static int show_reference(struct repository *r, const char *refname,
 			struct object_id object;
 			enum object_type obj_type, repl_type;
 
-			if (repo_get_oid(the_repository, refname, &object))
+			if (repo_get_oid(r, refname, &object))
 				return error(_("failed to resolve '%s' as a valid ref"), refname);
 
 			obj_type = oid_object_info(r, &object, NULL);
diff --git a/cache-tree.c b/cache-tree.c
index ab2cc1edf29..b0e490b5aa4 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -814,14 +814,14 @@ void prime_cache_tree(struct repository *r,
 {
 	struct strbuf tree_path = STRBUF_INIT;
 
-	trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
+	trace2_region_enter("cache-tree", "prime_cache_tree", r);
 	cache_tree_free(&istate->cache_tree);
 	istate->cache_tree = cache_tree();
 
 	prime_cache_tree_rec(r, istate->cache_tree, tree, &tree_path);
 	strbuf_release(&tree_path);
 	istate->cache_changed |= CACHE_TREE_CHANGED;
-	trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
+	trace2_region_leave("cache-tree", "prime_cache_tree", r);
 }
 
 /*
diff --git a/combine-diff.c b/combine-diff.c
index 20f8a03924f..fa5967a5be6 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -332,7 +332,7 @@ static char *grab_blob(struct repository *r,
 		*size = fill_textconv(r, textconv, df, &blob);
 		free_filespec(df);
 	} else {
-		blob = repo_read_object_file(the_repository, oid, &type, size);
+		blob = repo_read_object_file(r, oid, &type, size);
 		if (type != OBJ_BLOB)
 			die("object '%s' is not a blob!", oid_to_hex(oid));
 	}
diff --git a/commit-graph.c b/commit-graph.c
index 268410e913c..035816f4d8c 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2549,7 +2549,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
 
 		graph_commit = lookup_commit(r, &cur_oid);
 		odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
-		if (repo_parse_commit_internal(the_repository, odb_commit, 0, 0)) {
+		if (repo_parse_commit_internal(r, odb_commit, 0, 0)) {
 			graph_report(_("failed to parse commit %s from object database for commit-graph"),
 				     oid_to_hex(&cur_oid));
 			continue;
diff --git a/commit-reach.c b/commit-reach.c
index c88faf7e7b2..01eb11b5957 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -448,7 +448,7 @@ int repo_is_descendant_of(struct repository *r,
 	if (!with_commit)
 		return 1;
 
-	if (generation_numbers_enabled(the_repository)) {
+	if (generation_numbers_enabled(r)) {
 		struct commit_list *from_list = NULL;
 		int result;
 		commit_list_insert(commit, &from_list);
diff --git a/merge-recursive.c b/merge-recursive.c
index d83ce19bb1f..20aa18e2203 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3798,7 +3798,7 @@ static struct commit *get_ref(struct repository *repo,
 		return make_virtual_commit(repo, (struct tree*)object, name);
 	if (object->type != OBJ_COMMIT)
 		return NULL;
-	if (repo_parse_commit(the_repository, (struct commit *)object))
+	if (repo_parse_commit(repo, (struct commit *)object))
 		return NULL;
 	return (struct commit *)object;
 }
diff --git a/notes-cache.c b/notes-cache.c
index e5e9092d367..1a6e214ea79 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -23,7 +23,7 @@ static int notes_cache_match_validity(struct repository *r,
 		return 0;
 
 	memset(&pretty_ctx, 0, sizeof(pretty_ctx));
-	repo_format_commit_message(the_repository, commit, "%s", &msg,
+	repo_format_commit_message(r, commit, "%s", &msg,
 				   &pretty_ctx);
 	strbuf_trim(&msg);
 
diff --git a/notes-utils.c b/notes-utils.c
index 0550cfded86..4be0aaa6de9 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -23,7 +23,7 @@ void create_notes_commit(struct repository *r,
 		struct object_id parent_oid;
 		if (!read_ref(t->ref, &parent_oid)) {
 			struct commit *parent = lookup_commit(r, &parent_oid);
-			if (repo_parse_commit(the_repository, parent))
+			if (repo_parse_commit(r, parent))
 				die("Failed to find/parse commit %s", t->ref);
 			commit_list_insert(parent, &parents);
 		}
diff --git a/object-name.c b/object-name.c
index df31f192ce3..c7bc311dcef 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1038,7 +1038,7 @@ static enum get_oid_result get_parent(struct repository *r,
 	if (ret)
 		return ret;
 	commit = lookup_commit_reference(r, &oid);
-	if (repo_parse_commit(the_repository, commit))
+	if (repo_parse_commit(r, commit))
 		return MISSING_OBJECT;
 	if (!idx) {
 		oidcpy(result, &commit->object.oid);
@@ -1072,7 +1072,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r,
 		return MISSING_OBJECT;
 
 	while (generation--) {
-		if (repo_parse_commit(the_repository, commit) || !commit->parents)
+		if (repo_parse_commit(r, commit) || !commit->parents)
 			return MISSING_OBJECT;
 		commit = commit->parents->item;
 	}
@@ -1363,10 +1363,10 @@ static int get_oid_oneline(struct repository *r,
 		commit = pop_most_recent_commit(&list, ONELINE_SEEN);
 		if (!parse_object(r, &commit->object.oid))
 			continue;
-		buf = repo_get_commit_buffer(the_repository, commit, NULL);
+		buf = repo_get_commit_buffer(r, commit, NULL);
 		p = strstr(buf, "\n\n");
 		matches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));
-		repo_unuse_commit_buffer(the_repository, commit, buf);
+		repo_unuse_commit_buffer(r, commit, buf);
 
 		if (matches) {
 			oidcpy(oid, &commit->object.oid);
diff --git a/read-cache.c b/read-cache.c
index 1548e886684..892fede6b41 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2628,7 +2628,7 @@ int repo_index_has_changes(struct repository *repo,
 
 	if (tree)
 		cmp = tree->object.oid;
-	if (tree || !repo_get_oid_tree(the_repository, "HEAD", &cmp)) {
+	if (tree || !repo_get_oid_tree(repo, "HEAD", &cmp)) {
 		struct diff_options opt;
 
 		repo_diff_setup(repo, &opt);
@@ -2947,7 +2947,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
 	}
 
 	if (!istate->version)
-		istate->version = get_index_format_default(the_repository);
+		istate->version = get_index_format_default(r);
 
 	/* demote version 3 to version 2 when the latter suffices */
 	if (istate->version == 3 || istate->version == 2)
diff --git a/reset.c b/reset.c
index 3a9c6dfdd0a..65f8138c78b 100644
--- a/reset.c
+++ b/reset.c
@@ -106,7 +106,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
 		goto leave_reset_head;
 	}
 
-	if (!repo_get_oid(the_repository, "HEAD", &head_oid)) {
+	if (!repo_get_oid(r, "HEAD", &head_oid)) {
 		head = &head_oid;
 	} else if (!oid || !reset_hard) {
 		ret = error(_("could not determine HEAD revision"));
diff --git a/sequencer.c b/sequencer.c
index fb5a540fa04..f8f4e72112c 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -694,8 +694,8 @@ static int do_recursive_merge(struct repository *r,
 	o.show_rename_progress = 1;
 
 	head_tree = parse_tree_indirect(head);
-	next_tree = next ? repo_get_commit_tree(the_repository, next) : empty_tree(r);
-	base_tree = base ? repo_get_commit_tree(the_repository, base) : empty_tree(r);
+	next_tree = next ? repo_get_commit_tree(r, next) : empty_tree(r);
+	base_tree = base ? repo_get_commit_tree(r, base) : empty_tree(r);
 
 	for (i = 0; i < opts->xopts_nr; i++)
 		parse_merge_opt(&o, opts->xopts[i]);
@@ -773,7 +773,7 @@ static int is_index_unchanged(struct repository *r)
 	 * the commit is invalid, repo_parse_commit() will complain.  So
 	 * there is nothing for us to say here.  Just return failure.
 	 */
-	if (repo_parse_commit(the_repository, head_commit))
+	if (repo_parse_commit(r, head_commit))
 		return -1;
 
 	if (!(cache_tree_oid = get_cache_tree_oid(istate)))
@@ -1338,15 +1338,15 @@ void print_commit_summary(struct repository *r,
 	commit = lookup_commit(r, oid);
 	if (!commit)
 		die(_("couldn't look up newly created commit"));
-	if (repo_parse_commit(the_repository, commit))
+	if (repo_parse_commit(r, commit))
 		die(_("could not parse newly created commit"));
 
 	strbuf_addstr(&format, "format:%h] %s");
 
-	repo_format_commit_message(the_repository, commit, "%an <%ae>",
-				   &author_ident, &pctx);
-	repo_format_commit_message(the_repository, commit, "%cn <%ce>",
-				   &committer_ident, &pctx);
+	repo_format_commit_message(r, commit, "%an <%ae>", &author_ident,
+				   &pctx);
+	repo_format_commit_message(r, commit, "%cn <%ce>", &committer_ident,
+				   &pctx);
 	if (strbuf_cmp(&author_ident, &committer_ident)) {
 		strbuf_addstr(&format, "\n Author: ");
 		strbuf_addbuf_percentquote(&format, &author_ident);
@@ -1354,8 +1354,7 @@ void print_commit_summary(struct repository *r,
 	if (flags & SUMMARY_SHOW_AUTHOR_DATE) {
 		struct strbuf date = STRBUF_INIT;
 
-		repo_format_commit_message(the_repository, commit, "%ad",
-					   &date, &pctx);
+		repo_format_commit_message(r, commit, "%ad", &date, &pctx);
 		strbuf_addstr(&format, "\n Date: ");
 		strbuf_addbuf_percentquote(&format, &date);
 		strbuf_release(&date);
@@ -1385,7 +1384,7 @@ void print_commit_summary(struct repository *r,
 	rev.diffopt.detect_rename = DIFF_DETECT_RENAME;
 	diff_setup_done(&rev.diffopt);
 
-	refs = get_main_ref_store(the_repository);
+	refs = get_main_ref_store(r);
 	head = refs_resolve_ref_unsafe(refs, "HEAD", 0, NULL, NULL);
 	if (!head)
 		die(_("unable to resolve HEAD after creating commit"));
@@ -1411,7 +1410,7 @@ static int parse_head(struct repository *r, struct commit **head)
 	struct commit *current_head;
 	struct object_id oid;
 
-	if (repo_get_oid(the_repository, "HEAD", &oid)) {
+	if (repo_get_oid(r, "HEAD", &oid)) {
 		current_head = NULL;
 	} else {
 		current_head = lookup_commit_reference(r, &oid);
@@ -1421,7 +1420,7 @@ static int parse_head(struct repository *r, struct commit **head)
 			warning(_("HEAD %s is not a commit!"),
 				oid_to_hex(&oid));
 		}
-		if (repo_parse_commit(the_repository, current_head))
+		if (repo_parse_commit(r, current_head))
 			return error(_("could not parse HEAD commit"));
 	}
 	*head = current_head;
@@ -1464,9 +1463,8 @@ static int try_to_commit(struct repository *r,
 	if (flags & AMEND_MSG) {
 		const char *exclude_gpgsig[] = { "gpgsig", "gpgsig-sha256", NULL };
 		const char *out_enc = get_commit_output_encoding();
-		const char *message = repo_logmsg_reencode(the_repository,
-							   current_head, NULL,
-							   out_enc);
+		const char *message = repo_logmsg_reencode(r, current_head,
+							   NULL, out_enc);
 
 		if (!msg) {
 			const char *orig_message = NULL;
@@ -1477,7 +1475,7 @@ static int try_to_commit(struct repository *r,
 			hook_commit = "HEAD";
 		}
 		author = amend_author = get_author(message);
-		repo_unuse_commit_buffer(the_repository, current_head,
+		repo_unuse_commit_buffer(r, current_head,
 					 message);
 		if (!author) {
 			res = error(_("unable to parse commit author"));
@@ -2004,18 +2002,18 @@ static int update_squash_messages(struct repository *r,
 		struct commit *head_commit;
 		const char *head_message, *body;
 
-		if (repo_get_oid(the_repository, "HEAD", &head))
+		if (repo_get_oid(r, "HEAD", &head))
 			return error(_("need a HEAD to fixup"));
 		if (!(head_commit = lookup_commit_reference(r, &head)))
 			return error(_("could not read HEAD"));
-		if (!(head_message = repo_logmsg_reencode(the_repository, head_commit, NULL, encoding)))
+		if (!(head_message = repo_logmsg_reencode(r, head_commit, NULL,
+							  encoding)))
 			return error(_("could not read HEAD's commit message"));
 
 		find_commit_subject(head_message, &body);
 		if (command == TODO_FIXUP && !flag && write_message(body, strlen(body),
 							rebase_path_fixup_msg(), 0) < 0) {
-			repo_unuse_commit_buffer(the_repository, head_commit,
-						 head_message);
+			repo_unuse_commit_buffer(r, head_commit, head_message);
 			return error(_("cannot write '%s'"), rebase_path_fixup_msg());
 		}
 		strbuf_addf(&buf, "%c ", comment_line_char);
@@ -2030,11 +2028,10 @@ static int update_squash_messages(struct repository *r,
 		else
 			strbuf_addstr(&buf, body);
 
-		repo_unuse_commit_buffer(the_repository, head_commit,
-					 head_message);
+		repo_unuse_commit_buffer(r, head_commit, head_message);
 	}
 
-	if (!(message = repo_logmsg_reencode(the_repository, commit, NULL, encoding)))
+	if (!(message = repo_logmsg_reencode(r, commit, NULL, encoding)))
 		return error(_("could not read commit message of %s"),
 			     oid_to_hex(&commit->object.oid));
 	find_commit_subject(message, &body);
@@ -2049,7 +2046,7 @@ static int update_squash_messages(struct repository *r,
 		strbuf_add_commented_lines(&buf, body, strlen(body));
 	} else
 		return error(_("unknown command: %d"), command);
-	repo_unuse_commit_buffer(the_repository, commit, message);
+	repo_unuse_commit_buffer(r, commit, message);
 
 	if (!res)
 		res = write_message(buf.buf, buf.len, rebase_path_squash_msg(),
@@ -2162,7 +2159,7 @@ static int do_pick_commit(struct repository *r,
 		if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL))
 			return error(_("your index file is unmerged."));
 	} else {
-		unborn = repo_get_oid(the_repository, "HEAD", &head);
+		unborn = repo_get_oid(r, "HEAD", &head);
 		/* Do we want to generate a root commit? */
 		if (is_pick_or_similar(command) && opts->have_squash_onto &&
 		    oideq(&head, &opts->squash_onto)) {
@@ -2224,7 +2221,7 @@ static int do_pick_commit(struct repository *r,
 		msg_file = NULL;
 		goto fast_forward_edit;
 	}
-	if (parent && repo_parse_commit(the_repository, parent) < 0)
+	if (parent && repo_parse_commit(r, parent) < 0)
 		/* TRANSLATORS: The first %s will be a "todo" command like
 		   "revert" or "pick", the second %s a SHA1. */
 		return error(_("%s: cannot parse parent commit %s"),
@@ -2616,7 +2613,7 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
 	end_of_object_name = (char *) bol + strcspn(bol, " \t\n");
 	saved = *end_of_object_name;
 	*end_of_object_name = '\0';
-	status = repo_get_oid(the_repository, bol, &commit_oid);
+	status = repo_get_oid(r, bol, &commit_oid);
 	if (status < 0)
 		error(_("could not parse '%s'"), bol); /* return later */
 	*end_of_object_name = saved;
@@ -3531,12 +3528,12 @@ static int make_patch(struct repository *r,
 	strbuf_addf(&buf, "%s/message", get_dir(opts));
 	if (!file_exists(buf.buf)) {
 		const char *encoding = get_commit_output_encoding();
-		const char *commit_buffer = repo_logmsg_reencode(the_repository,
+		const char *commit_buffer = repo_logmsg_reencode(r,
 								 commit, NULL,
 								 encoding);
 		find_commit_subject(commit_buffer, &subject);
 		res |= write_message(subject, strlen(subject), buf.buf, 1);
-		repo_unuse_commit_buffer(the_repository, commit,
+		repo_unuse_commit_buffer(r, commit,
 					 commit_buffer);
 	}
 	strbuf_release(&buf);
@@ -3716,7 +3713,7 @@ static int do_label(struct repository *r, const char *name, int len)
 	if (!transaction) {
 		error("%s", err.buf);
 		ret = -1;
-	} else if (repo_get_oid(the_repository, "HEAD", &head_oid)) {
+	} else if (repo_get_oid(r, "HEAD", &head_oid)) {
 		error(_("could not read HEAD"));
 		ret = -1;
 	} else if (ref_transaction_update(transaction, ref_name.buf, &head_oid,
@@ -4004,8 +4001,7 @@ static int do_merge(struct repository *r,
 
 	if (commit) {
 		const char *encoding = get_commit_output_encoding();
-		const char *message = repo_logmsg_reencode(the_repository,
-							   commit, NULL,
+		const char *message = repo_logmsg_reencode(r, commit, NULL,
 							   encoding);
 		const char *body;
 		int len;
@@ -4019,7 +4015,7 @@ static int do_merge(struct repository *r,
 		find_commit_subject(message, &body);
 		len = strlen(body);
 		ret = write_message(body, len, git_path_merge_msg(r), 0);
-		repo_unuse_commit_buffer(the_repository, commit, message);
+		repo_unuse_commit_buffer(r, commit, message);
 		if (ret) {
 			error_errno(_("could not write '%s'"),
 				    git_path_merge_msg(r));
@@ -4119,8 +4115,7 @@ static int do_merge(struct repository *r,
 	}
 
 	merge_commit = to_merge->item;
-	bases = repo_get_merge_bases(the_repository, head_commit,
-				     merge_commit);
+	bases = repo_get_merge_bases(r, head_commit, merge_commit);
 	if (bases && oideq(&merge_commit->object.oid,
 			   &bases->item->object.oid)) {
 		ret = 0;
@@ -4475,7 +4470,7 @@ void create_autostash(struct repository *r, const char *path)
 		if (capture_command(&stash, &buf, GIT_MAX_HEXSZ))
 			die(_("Cannot autostash"));
 		strbuf_trim_trailing_newline(&buf);
-		if (repo_get_oid(the_repository, buf.buf, &oid))
+		if (repo_get_oid(r, buf.buf, &oid))
 			die(_("Unexpected stash response: '%s'"),
 			    buf.buf);
 		strbuf_reset(&buf);
@@ -4600,9 +4595,9 @@ static int stopped_at_head(struct repository *r)
 	struct commit *commit;
 	struct commit_message message;
 
-	if (repo_get_oid(the_repository, "HEAD", &head) ||
+	if (repo_get_oid(r, "HEAD", &head) ||
 	    !(commit = lookup_commit(r, &head)) ||
-	    repo_parse_commit(the_repository, commit) || get_message(commit, &message))
+	    repo_parse_commit(r, commit) || get_message(commit, &message))
 		fprintf(stderr, _("Stopped at HEAD\n"));
 	else {
 		fprintf(stderr, _("Stopped at %s\n"), message.label);
@@ -4750,7 +4745,7 @@ static int pick_commits(struct repository *r,
 				 * otherwise we do not.
 				 */
 				if (item->command == TODO_REWORD &&
-				    !repo_get_oid(the_repository, "HEAD", &oid) &&
+				    !repo_get_oid(r, "HEAD", &oid) &&
 				    (oideq(&item->commit->object.oid, &oid) ||
 				     (opts->have_squash_onto &&
 				      oideq(&opts->squash_onto, &oid))))
@@ -4839,7 +4834,7 @@ static int pick_commits(struct repository *r,
 			struct object_id head, orig;
 			int res;
 
-			if (repo_get_oid(the_repository, "HEAD", &head)) {
+			if (repo_get_oid(r, "HEAD", &head)) {
 				res = error(_("cannot read HEAD"));
 cleanup_head_ref:
 				strbuf_release(&head_ref);
@@ -4886,8 +4881,8 @@ static int pick_commits(struct repository *r,
 			log_tree_opt.disable_stdin = 1;
 
 			if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
-			    !repo_get_oid(the_repository, buf.buf, &orig) &&
-			    !repo_get_oid(the_repository, "HEAD", &head)) {
+			    !repo_get_oid(r, buf.buf, &orig) &&
+			    !repo_get_oid(r, "HEAD", &head)) {
 				diff_tree_oid(&orig, &head, "",
 					      &log_tree_opt.diffopt);
 				log_tree_diff_flush(&log_tree_opt);
@@ -4979,7 +4974,7 @@ static int commit_staged_changes(struct repository *r,
 		struct strbuf rev = STRBUF_INIT;
 		struct object_id head, to_amend;
 
-		if (repo_get_oid(the_repository, "HEAD", &head))
+		if (repo_get_oid(r, "HEAD", &head))
 			return error(_("cannot amend non-existing commit"));
 		if (!read_oneliner(&rev, rebase_path_amend(), 0))
 			return error(_("invalid file: '%s'"), rebase_path_amend());
@@ -5059,14 +5054,13 @@ static int commit_staged_changes(struct repository *r,
 				const char *encoding = get_commit_output_encoding();
 
 				if (parse_head(r, &commit) ||
-				    !(p = repo_logmsg_reencode(the_repository, commit, NULL, encoding)) ||
+				    !(p = repo_logmsg_reencode(r, commit, NULL, encoding)) ||
 				    write_message(p, strlen(p), path, 0)) {
-					repo_unuse_commit_buffer(the_repository,
-								 commit, p);
+					repo_unuse_commit_buffer(r, commit, p);
 					return error(_("could not write file: "
 						       "'%s'"), path);
 				}
-				repo_unuse_commit_buffer(the_repository,
+				repo_unuse_commit_buffer(r,
 							 commit, p);
 			}
 		}
@@ -5206,7 +5200,7 @@ int sequencer_pick_revisions(struct repository *r,
 		if (!strlen(name))
 			continue;
 
-		if (!repo_get_oid(the_repository, name, &oid)) {
+		if (!repo_get_oid(r, name, &oid)) {
 			if (!lookup_commit_reference_gently(r, &oid, 1)) {
 				enum object_type type = oid_object_info(r,
 									&oid,
@@ -5249,7 +5243,7 @@ int sequencer_pick_revisions(struct repository *r,
 	if (walk_revs_populate_todo(&todo_list, opts) ||
 			create_seq_dir(r) < 0)
 		return -1;
-	if (repo_get_oid(the_repository, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
+	if (repo_get_oid(r, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
 		return error(_("can't revert as initial commit"));
 	if (save_head(oid_to_hex(&oid)))
 		return -1;
@@ -5944,7 +5938,7 @@ static int skip_unnecessary_picks(struct repository *r,
 			continue;
 		if (item->command != TODO_PICK)
 			break;
-		if (repo_parse_commit(the_repository, item->commit)) {
+		if (repo_parse_commit(r, item->commit)) {
 			return error(_("could not parse commit '%s'"),
 				oid_to_hex(&item->commit->object.oid));
 		}
@@ -6115,7 +6109,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
 	struct object_id oid = onto->object.oid;
 	int res;
 
-	repo_find_unique_abbrev_r(the_repository, shortonto, &oid,
+	repo_find_unique_abbrev_r(r, shortonto, &oid,
 				  DEFAULT_ABBREV);
 
 	if (buf->len == 0) {
@@ -6395,8 +6389,8 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
 		if (file_exists(git_path_seq_dir()))
 			*whence = FROM_CHERRY_PICK_MULTI;
 		if (file_exists(rebase_path()) &&
-		    !repo_get_oid(the_repository, "REBASE_HEAD", &rebase_head) &&
-		    !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
+		    !repo_get_oid(r, "REBASE_HEAD", &rebase_head) &&
+		    !repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
 		    oideq(&rebase_head, &cherry_pick_head))
 			*whence = FROM_REBASE_PICK;
 		else
diff --git a/shallow.c b/shallow.c
index 07278467e47..fbafc4b30e9 100644
--- a/shallow.c
+++ b/shallow.c
@@ -30,7 +30,7 @@ int register_shallow(struct repository *r, const struct object_id *oid)
 {
 	struct commit_graft *graft =
 		xmalloc(sizeof(struct commit_graft));
-	struct commit *commit = lookup_commit(the_repository, oid);
+	struct commit *commit = lookup_commit(r, oid);
 
 	oidcpy(&graft->oid, oid);
 	graft->nr_parent = -1;
diff --git a/tree.c b/tree.c
index 1b403c4b5ce..8643b734642 100644
--- a/tree.c
+++ b/tree.c
@@ -58,7 +58,7 @@ int read_tree_at(struct repository *r,
 				    oid_to_hex(&entry.oid),
 				    base->buf, entry.path);
 
-			if (repo_parse_commit(the_repository, commit))
+			if (repo_parse_commit(r, commit))
 				die("Invalid commit %s in submodule path %s%s",
 				    oid_to_hex(&entry.oid),
 				    base->buf, entry.path);
diff --git a/wt-status.c b/wt-status.c
index dcd1d0cee4c..28e35a2165a 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1664,7 +1664,7 @@ static void wt_status_get_detached_from(struct repository *r,
 		return;
 	}
 
-	if (repo_dwim_ref(the_repository, cb.buf.buf, cb.buf.len, &oid, &ref,
+	if (repo_dwim_ref(r, cb.buf.buf, cb.buf.len, &oid, &ref,
 			  1) == 1 &&
 	    /* oid is a commit? match without further lookup */
 	    (oideq(&cb.noid, &oid) ||
@@ -1677,9 +1677,9 @@ static void wt_status_get_detached_from(struct repository *r,
 		state->detached_from = xstrdup(from);
 	} else
 		state->detached_from =
-			xstrdup(repo_find_unique_abbrev(the_repository, &cb.noid, DEFAULT_ABBREV));
+			xstrdup(repo_find_unique_abbrev(r, &cb.noid, DEFAULT_ABBREV));
 	oidcpy(&state->detached_oid, &cb.noid);
-	state->detached_at = !repo_get_oid(the_repository, "HEAD", &oid) &&
+	state->detached_at = !repo_get_oid(r, "HEAD", &oid) &&
 			     oideq(&oid, &state->detached_oid);
 
 	free(ref);
@@ -1770,13 +1770,13 @@ void wt_status_get_state(struct repository *r,
 	} else if (wt_status_check_rebase(NULL, state)) {
 		;		/* all set */
 	} else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
-		   !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &oid)) {
+		   !repo_get_oid(r, "CHERRY_PICK_HEAD", &oid)) {
 		state->cherry_pick_in_progress = 1;
 		oidcpy(&state->cherry_pick_head_oid, &oid);
 	}
 	wt_status_check_bisect(NULL, state);
 	if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") &&
-	    !repo_get_oid(the_repository, "REVERT_HEAD", &oid)) {
+	    !repo_get_oid(r, "REVERT_HEAD", &oid)) {
 		state->revert_in_progress = 1;
 		oidcpy(&state->revert_head_oid, &oid);
 	}
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* Re: [PATCH 01/17] cocci: remove dead rule from "the_repository.pending.cocci"
  2023-03-17 15:35 ` [PATCH 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
@ 2023-03-17 16:14   ` Eric Sunshine
  2023-03-19  5:53   ` Elijah Newren
  1 sibling, 0 replies; 60+ messages in thread
From: Eric Sunshine @ 2023-03-17 16:14 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Junio C Hamano

On Fri, Mar 17, 2023 at 11:42 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> The "parse_commit_gently" macro went away in [1], so we don't need to
> carry his for its migration.

Nit: ECANTPARSE "carry his for its"

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 00/17] cocci: remove "the_index" wrapper macros
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (16 preceding siblings ...)
  2023-03-17 15:35 ` [PATCH 17/17] libs: use "struct repository *" argument, not "the_repository" Ævar Arnfjörð Bjarmason
@ 2023-03-17 19:22 ` Junio C Hamano
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
  18 siblings, 0 replies; 60+ messages in thread
From: Junio C Hamano @ 2023-03-17 19:22 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> In 2.40 the last use of "USE_THE_INDEX_COMPATIBILITY_MACROS" went
> away, this series does the same for our long-standing migration of
> "NO_THE_REPOSITORY_COMPATIBILITY_MACROS".

Is the series title on the Subject: line still valid, or did you
misspell "repository" somehow?


^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 01/17] cocci: remove dead rule from "the_repository.pending.cocci"
  2023-03-17 15:35 ` [PATCH 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
  2023-03-17 16:14   ` Eric Sunshine
@ 2023-03-19  5:53   ` Elijah Newren
  1 sibling, 0 replies; 60+ messages in thread
From: Elijah Newren @ 2023-03-19  5:53 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Junio C Hamano

On Fri, Mar 17, 2023 at 9:41 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> The "parse_commit_gently" macro went away in [1], so we don't need to
> carry his for its migration.

s/his/this/ ?

> 1. ea3f7e598c8 (revision: use repository from rev_info when parsing
>    commits, 2020-06-23)

Thanks for the explanation and link.


> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  contrib/coccinelle/the_repository.pending.cocci | 8 --------
>  1 file changed, 8 deletions(-)
>
> diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
> index 747d382ff5f..23b97536da5 100644
> --- a/contrib/coccinelle/the_repository.pending.cocci
> +++ b/contrib/coccinelle/the_repository.pending.cocci
> @@ -34,14 +34,6 @@ expression G;
>  + repo_parse_commit_internal(the_repository,
>    E, F, G)
>
> -@@
> -expression E;
> -expression F;
> -@@
> -- parse_commit_gently(
> -+ repo_parse_commit_gently(the_repository,
> -  E, F)
> -
>  @@
>  expression E;
>  @@
> --
> 2.40.0.rc1.1034.g5867a1b10c5

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules
  2023-03-17 15:35 ` [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
@ 2023-03-19  5:55   ` Elijah Newren
  2023-03-22 22:46   ` Glen Choo
  1 sibling, 0 replies; 60+ messages in thread
From: Elijah Newren @ 2023-03-19  5:55 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Junio C Hamano

On Fri, Mar 17, 2023 at 8:53 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> When these rules started being added in [1] they didn't use a ";"
> after the ")", and would thus catch uses of these macros within
> expressions. But as of [2] the new additions were broken in that
> they'd only match a subset of the users of these macros.
>
> Rather than narrowly fixing that, let's have these use the much less
> verbose pattern introduced in my recent [3]: There's no need to
> exhaustively enumerate arguments if we use the "..." syntax. This
> means that we can fold all of these different rules into one.
>
> 1. afd69dcc219 (object-store: prepare read_object_file to deal with
>    any repo, 2018-11-13)
> 2. 21a9651ba3f (commit-reach: prepare get_merge_bases to handle any
>    repo, 2018-11-13)
> 3. 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci,
>    2022-11-19)
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  .../coccinelle/the_repository.pending.cocci   | 160 +++++-------------
>  1 file changed, 46 insertions(+), 114 deletions(-)
>
> diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
> index 23b97536da5..99e192736ee 100644
> --- a/contrib/coccinelle/the_repository.pending.cocci
> +++ b/contrib/coccinelle/the_repository.pending.cocci
> @@ -3,118 +3,50 @@
>  // our code base.
>
>  @@
> -expression E;
> -expression F;
> -expression G;
>  @@
> -- read_object_file(
> -+ repo_read_object_file(the_repository,
> -  E, F, G)
> -
> -@@
> -expression E;
> -@@
> -- has_object_file(
> -+ repo_has_object_file(the_repository,
> -  E)
> -
> -@@
> -expression E;
> -@@
> -- has_object_file_with_flags(
> -+ repo_has_object_file_with_flags(the_repository,
> -  E)
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -@@
> -- parse_commit_internal(
> -+ repo_parse_commit_internal(the_repository,
> -  E, F, G)
> -
> -@@
> -expression E;
> -@@
> -- parse_commit(
> -+ repo_parse_commit(the_repository,
> -  E)
> -
> -@@
> -expression E;
> -expression F;
> -@@
> -- get_merge_bases(
> -+ repo_get_merge_bases(the_repository,
> -  E, F);
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -@@
> -- get_merge_bases_many(
> -+ repo_get_merge_bases_many(the_repository,
> -  E, F, G);
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -@@
> -- get_merge_bases_many_dirty(
> -+ repo_get_merge_bases_many_dirty(the_repository,
> -  E, F, G);
> -
> -@@
> -expression E;
> -expression F;
> -@@
> -- in_merge_bases(
> -+ repo_in_merge_bases(the_repository,
> -  E, F);
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -@@
> -- in_merge_bases_many(
> -+ repo_in_merge_bases_many(the_repository,
> -  E, F, G);
> -
> -@@
> -expression E;
> -expression F;
> -@@
> -- get_commit_buffer(
> -+ repo_get_commit_buffer(the_repository,
> -  E, F);
> -
> -@@
> -expression E;
> -expression F;
> -@@
> -- unuse_commit_buffer(
> -+ repo_unuse_commit_buffer(the_repository,
> -  E, F);
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -@@
> -- logmsg_reencode(
> -+ repo_logmsg_reencode(the_repository,
> -  E, F, G);
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -expression H;
> -@@
> -- format_commit_message(
> -+ repo_format_commit_message(the_repository,
> -  E, F, G, H);
> +(
> +- read_object_file
> ++ repo_read_object_file
> +|
> +- has_object_file
> ++ repo_has_object_file
> +|
> +- has_object_file_with_flags
> ++ repo_has_object_file_with_flags
> +|
> +- parse_commit_internal
> ++ repo_parse_commit_internal
> +|
> +- parse_commit
> ++ repo_parse_commit
> +|
> +- get_merge_bases
> ++ repo_get_merge_bases
> +|
> +- get_merge_bases_many
> ++ repo_get_merge_bases_many
> +|
> +- get_merge_bases_many_dirty
> ++ repo_get_merge_bases_many_dirty
> +|
> +- in_merge_bases
> ++ repo_in_merge_bases
> +|
> +- in_merge_bases_many
> ++ repo_in_merge_bases_many
> +|
> +- get_commit_buffer
> ++ repo_get_commit_buffer
> +|
> +- unuse_commit_buffer
> ++ repo_unuse_commit_buffer
> +|
> +- logmsg_reencode
> ++ repo_logmsg_reencode
> +|
> +- format_commit_message
> ++ repo_format_commit_message
> +)
> +  (
> ++ the_repository,
> +  ...)
> --
> 2.40.0.rc1.1034.g5867a1b10c5

I know virtually nothing about cocci, but the commit message explains
well enough that it's clear what you're doing and what's happening.
:-)

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 03/17] cocci: sort "the_repository" rules by header
  2023-03-17 15:35 ` [PATCH 03/17] cocci: sort "the_repository" rules by header Ævar Arnfjörð Bjarmason
@ 2023-03-19  5:59   ` Elijah Newren
  0 siblings, 0 replies; 60+ messages in thread
From: Elijah Newren @ 2023-03-19  5:59 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Junio C Hamano

On Fri, Mar 17, 2023 at 9:16 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> Sort the "the_repository.pending.cocci" file by which header the
> macros are in, and add a comment to that effect in front of the
> rules. This will make subsequent commits easier to follow, as we'll be
> applying these rules on a header-by-header basis.

Is this at risk of becoming out-of-date with en/header-cleanup or my
second series over at https://github.com/gitgitgadget/git/pull/1493
that I'm planning to submit soon?  It doesn't look like you're adding
any comments pointing at cache.h, and I'm mostly moving stuff out of
there, but I'm just curious if we are risking adding
likely-to-become-stale comments.

>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  .../coccinelle/the_repository.pending.cocci   | 34 +++++++++++--------
>  1 file changed, 19 insertions(+), 15 deletions(-)
>
> diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
> index 99e192736ee..84b79dce480 100644
> --- a/contrib/coccinelle/the_repository.pending.cocci
> +++ b/contrib/coccinelle/the_repository.pending.cocci
> @@ -5,21 +5,7 @@
>  @@
>  @@
>  (
> -- read_object_file
> -+ repo_read_object_file
> -|
> -- has_object_file
> -+ repo_has_object_file
> -|
> -- has_object_file_with_flags
> -+ repo_has_object_file_with_flags
> -|
> -- parse_commit_internal
> -+ repo_parse_commit_internal
> -|
> -- parse_commit
> -+ repo_parse_commit
> -|
> +// commit-reach.h
>  - get_merge_bases
>  + repo_get_merge_bases
>  |
> @@ -34,6 +20,13 @@
>  |
>  - in_merge_bases_many
>  + repo_in_merge_bases_many
> +// commit.h
> +|
> +- parse_commit_internal
> ++ repo_parse_commit_internal
> +|
> +- parse_commit
> ++ repo_parse_commit
>  |
>  - get_commit_buffer
>  + repo_get_commit_buffer
> @@ -43,6 +36,17 @@
>  |
>  - logmsg_reencode
>  + repo_logmsg_reencode
> +// object-store.h
> +|
> +- read_object_file
> ++ repo_read_object_file
> +|
> +- has_object_file
> ++ repo_has_object_file
> +|
> +- has_object_file_with_flags
> ++ repo_has_object_file_with_flags
> +// pretty.h
>  |
>  - format_commit_message
>  + repo_format_commit_message
> --
> 2.40.0.rc1.1034.g5867a1b10c5

Other than the minor comment above, things all make sense.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 04/17] cocci: add missing "the_repository" macros to "pending"
  2023-03-17 15:35 ` [PATCH 04/17] cocci: add missing "the_repository" macros to "pending" Ævar Arnfjörð Bjarmason
@ 2023-03-19  6:04   ` Elijah Newren
  0 siblings, 0 replies; 60+ messages in thread
From: Elijah Newren @ 2023-03-19  6:04 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Junio C Hamano

On Fri, Mar 17, 2023 at 8:57 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> In the case of diff.h, rerere.h and revision.h the macros were added
> in [1], [2] and [3] when "the_repository.pending.cocci" didn't
> exist. None of the subsequently added migration rules covered
> them. Let's add those missing rules.
>
> In the case of macros in "cache.h", "commit.h", "packfile.h",
> "promisor-remote.h" and "refs.h" those aren't guarded by
> "NO_THE_REPOSITORY_COMPATIBILITY_MACROS", but they're also macros that
> add "the_repository" as the first argument, so we should migrate away
> from them.

Yaay, nice to see work on migrating away from the_repository again.  :-)

> 1. 2abf3503854 (revision.c: remove implicit dependency on the_index,
>    2018-09-21)
> 2. e6757652350 (diff.c: remove implicit dependency on the_index,
>    2018-09-21)
> 3. 35843b1123e (rerere.c: remove implicit dependency on the_index,
>    2018-09-21)
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  .../coccinelle/the_repository.pending.cocci   | 70 +++++++++++++++++++
>  1 file changed, 70 insertions(+)
>
> diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
> index 84b79dce480..8b3f2580e6b 100644
> --- a/contrib/coccinelle/the_repository.pending.cocci
> +++ b/contrib/coccinelle/the_repository.pending.cocci
> @@ -5,7 +5,44 @@
>  @@
>  @@
>  (
> +// cache.h
> +- get_oid
> ++ repo_get_oid
> +|
> +- get_oid_commit
> ++ repo_get_oid_commit
> +|
> +- get_oid_committish
> ++ repo_get_oid_committish
> +|
> +- get_oid_tree
> ++ repo_get_oid_tree
> +|
> +- get_oid_treeish
> ++ repo_get_oid_treeish
> +|
> +- get_oid_blob
> ++ repo_get_oid_blob
> +|
> +- get_oid_mb
> ++ repo_get_oid_mb
> +|
> +- find_unique_abbrev
> ++ repo_find_unique_abbrev
> +|
> +- find_unique_abbrev_r
> ++ repo_find_unique_abbrev_r
> +|
> +- for_each_abbrev
> ++ repo_for_each_abbrev
> +|
> +- interpret_branch_name
> ++ repo_interpret_branch_name
> +|
> +- peel_to_type
> ++ repo_peel_to_type
>  // commit-reach.h
> +|
>  - get_merge_bases
>  + repo_get_merge_bases
>  |
> @@ -36,6 +73,13 @@
>  |
>  - logmsg_reencode
>  + repo_logmsg_reencode
> +|
> +- get_commit_tree
> ++ repo_get_commit_tree
> +// diff.h
> +|
> +- diff_setup
> ++ repo_diff_setup
>  // object-store.h
>  |
>  - read_object_file
> @@ -50,6 +94,32 @@
>  |
>  - format_commit_message
>  + repo_format_commit_message
> +// packfile.h
> +|
> +- approximate_object_count
> ++ repo_approximate_object_count
> +// promisor-remote.h
> +|
> +- promisor_remote_reinit
> ++ repo_promisor_remote_reinit
> +|
> +- promisor_remote_find
> ++ repo_promisor_remote_find
> +|
> +- has_promisor_remote
> ++ repo_has_promisor_remote
> +// refs.h
> +|
> +- dwim_ref
> ++ repo_dwim_ref
> +// rerere.h
> +|
> +- rerere
> ++ repo_rerere
> +// revision.h
> +|
> +- init_revisions
> ++ repo_init_revisions
>  )
>    (
>  + the_repository,
> --
> 2.40.0.rc1.1034.g5867a1b10c5

Makes sense.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 05/17] cocci: apply the "cache.h" part of "the_repository.pending"
  2023-03-17 15:35 ` [PATCH 05/17] cocci: apply the "cache.h" part of "the_repository.pending" Ævar Arnfjörð Bjarmason
@ 2023-03-19  6:06   ` Elijah Newren
  2023-03-22 23:17   ` Glen Choo
  1 sibling, 0 replies; 60+ messages in thread
From: Elijah Newren @ 2023-03-19  6:06 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Junio C Hamano

On Fri, Mar 17, 2023 at 8:47 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> Apply the part of "the_repository.pending.cocci" pertaining to
> "cache.h".

I know you said we only really needed to review 01-04, and 16-17, but
I spot-checked this one anyway, particularly since it conflicted with
what I was originally trying to include in
https://github.com/gitgitgadget/git/pull/1493.  But, I pulled that
piece out to submit later, I'm in favor of the changes you are making
here.

Also, looking over this patch I think answered my question on the
previous patch.  You only needed the functions sorted by filename for
the duration of your series, so that's good too.

Anyway, looks good.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 16/17] post-cocci: adjust comments for recent repo_* migration
  2023-03-17 15:35 ` [PATCH 16/17] post-cocci: adjust comments for recent repo_* migration Ævar Arnfjörð Bjarmason
@ 2023-03-19  6:12   ` Elijah Newren
  0 siblings, 0 replies; 60+ messages in thread
From: Elijah Newren @ 2023-03-19  6:12 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Junio C Hamano

On Fri, Mar 17, 2023 at 9:22 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> In preceding commits we changed many calls to macros that were
> providing a "the_repository" argument to invoke corresponding repo_*()
> function instead. Let's follow-up and adjust references to those in
> comments, which coccinelle didn't (and inherently can't) catch.

Nice.

> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  builtin/branch.c   | 2 +-
>  builtin/shortlog.c | 2 +-
>  cache.h            | 4 ++--
>  commit.h           | 4 ++--
>  diff.h             | 2 +-
>  object-file.c      | 2 +-
>  object-store.h     | 4 ++--
>  pretty.c           | 2 +-
>  refs.c             | 2 +-
>  sequencer.c        | 6 +++---
>  strbuf.h           | 6 +++---
>  11 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/builtin/branch.c b/builtin/branch.c
> index bbcfb34b3c6..45910039e6b 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -156,7 +156,7 @@ static int branch_merged(int kind, const char *name,
>         /*
>          * After the safety valve is fully redefined to "check with
>          * upstream, if any, otherwise with HEAD", we should just
> -        * return the result of the in_merge_bases() above without
> +        * return the result of the repo_in_merge_bases() above without
>          * any of the following code, but during the transition period,
>          * a gentle reminder is in order.
>          */
> diff --git a/builtin/shortlog.c b/builtin/shortlog.c
> index 62f91b8b932..f287a6acd03 100644
> --- a/builtin/shortlog.c
> +++ b/builtin/shortlog.c
> @@ -176,7 +176,7 @@ static void insert_records_from_trailers(struct shortlog *log,
>                 return;
>
>         /*
> -        * Using format_commit_message("%B") would be simpler here, but
> +        * Using repo_format_commit_message("%B") would be simpler here, but
>          * this saves us copying the message.
>          */
>         commit_buffer = repo_logmsg_reencode(the_repository, commit, NULL,
> diff --git a/cache.h b/cache.h
> index d835ac8b4d2..555354e1961 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -443,7 +443,7 @@ void validate_cache_entries(const struct index_state *istate);
>  /*
>   * Bulk prefetch all missing cache entries that are not GITLINKs and that match
>   * the given predicate. This function should only be called if
> - * has_promisor_remote() returns true.
> + * repo_has_promisor_remote() returns true.
>   */
>  typedef int (*must_prefetch_predicate)(const struct cache_entry *);
>  void prefetch_cache_entries(const struct index_state *istate,
> @@ -1201,7 +1201,7 @@ void check_repository_format(struct repository_format *fmt);
>   * terminated.
>   *
>   * The non-`_r` version returns a static buffer which remains valid until 4
> - * more calls to find_unique_abbrev are made.
> + * more calls to repo_find_unique_abbrev are made.
>   *
>   * The `_r` variant writes to a buffer supplied by the caller, which must be at
>   * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
> diff --git a/commit.h b/commit.h
> index e98ee6e698e..d4adf111019 100644
> --- a/commit.h
> +++ b/commit.h
> @@ -130,7 +130,7 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,
>  /*
>   * Get the commit's object contents, either from cache or by reading the object
>   * from disk. The resulting memory should not be modified, and must be given
> - * to unuse_commit_buffer when the caller is done.
> + * to repo_unuse_commit_buffer when the caller is done.
>   */
>  const void *repo_get_commit_buffer(struct repository *r,
>                                    const struct commit *,
> @@ -139,7 +139,7 @@ const void *repo_get_commit_buffer(struct repository *r,
>  /*
>   * Tell the commit subsystem that we are done with a particular commit buffer.
>   * The commit and buffer should be the input and return value, respectively,
> - * from an earlier call to get_commit_buffer.  The buffer may or may not be
> + * from an earlier call to repo_get_commit_buffer.  The buffer may or may not be
>   * freed by this call; callers should not access the memory afterwards.
>   */
>  void repo_unuse_commit_buffer(struct repository *r,
> diff --git a/diff.h b/diff.h
> index 8b510eb579d..0aa36e81261 100644
> --- a/diff.h
> +++ b/diff.h
> @@ -614,7 +614,7 @@ void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc);
>  #define DIFF_STATUS_FILTER_BROKEN      'B'
>
>  /*
> - * This is different from find_unique_abbrev() in that
> + * This is different from repo_find_unique_abbrev() in that
>   * it stuffs the result with dots for alignment.
>   */
>  const char *diff_aligned_abbrev(const struct object_id *sha1, int);
> diff --git a/object-file.c b/object-file.c
> index 141cf85f25b..47c52681640 100644
> --- a/object-file.c
> +++ b/object-file.c
> @@ -267,7 +267,7 @@ int hash_algo_by_length(int len)
>
>  /*
>   * This is meant to hold a *small* number of objects that you would
> - * want read_object_file() to be able to return, but yet you do not want
> + * want repo_read_object_file() to be able to return, but yet you do not want
>   * to write them into the object store (e.g. a browse-only
>   * application).
>   */
> diff --git a/object-store.h b/object-store.h
> index b47849d4e7e..9217ae83064 100644
> --- a/object-store.h
> +++ b/object-store.h
> @@ -216,7 +216,7 @@ struct raw_object_store {
>         /*
>          * A fast, rough count of the number of objects in the repository.
>          * These two fields are not meant for direct access. Use
> -        * approximate_object_count() instead.
> +        * repo_approximate_object_count() instead.
>          */
>         unsigned long approximate_object_count;
>         unsigned approximate_object_count_valid : 1;
> @@ -343,7 +343,7 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect);
>
>  /*
>   * Enabling the object read lock allows multiple threads to safely call the
> - * following functions in parallel: repo_read_object_file(), read_object_file(),
> + * following functions in parallel: repo_read_object_file(),
>   * read_object_with_reference(), oid_object_info() and oid_object_info_extended().
>   *
>   * obj_read_lock() and obj_read_unlock() may also be used to protect other
> diff --git a/pretty.c b/pretty.c
> index 076d1c363e7..23ac06b93f3 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -719,7 +719,7 @@ const char *repo_logmsg_reencode(struct repository *r,
>                  * Otherwise, we still want to munge the encoding header in the
>                  * result, which will be done by modifying the buffer. If we
>                  * are using a fresh copy, we can reuse it. But if we are using
> -                * the cached copy from get_commit_buffer, we need to duplicate it
> +                * the cached copy from repo_get_commit_buffer, we need to duplicate it
>                  * to avoid munging the cached copy.
>                  */
>                 if (msg == get_cached_commit_buffer(r, commit, NULL))
> diff --git a/refs.c b/refs.c
> index aeae31c972f..cd7537bce64 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -1821,7 +1821,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
>                         return NULL;
>
>                 /*
> -                * dwim_ref() uses REF_ISBROKEN to distinguish between
> +                * repo_dwim_ref() uses REF_ISBROKEN to distinguish between
>                  * missing refs and refs that were present but invalid,
>                  * to complain about the latter to stderr.
>                  *
> diff --git a/sequencer.c b/sequencer.c
> index aa3ebb47d98..fb5a540fa04 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -768,9 +768,9 @@ static int is_index_unchanged(struct repository *r)
>         /*
>          * If head_commit is NULL, check_commit, called from
>          * lookup_commit, would have indicated that head_commit is not
> -        * a commit object already.  parse_commit() will return failure
> +        * a commit object already.  repo_parse_commit() will return failure
>          * without further complaints in such a case.  Otherwise, if
> -        * the commit is invalid, parse_commit() will complain.  So
> +        * the commit is invalid, repo_parse_commit() will complain.  So
>          * there is nothing for us to say here.  Just return failure.
>          */
>         if (repo_parse_commit(the_repository, head_commit))
> @@ -5365,7 +5365,7 @@ static const char *label_oid(struct object_id *oid, const char *label,
>          * For "uninteresting" commits, i.e. commits that are not to be
>          * rebased, and which can therefore not be labeled, we use a unique
>          * abbreviation of the commit name. This is slightly more complicated
> -        * than calling find_unique_abbrev() because we also need to make
> +        * than calling repo_find_unique_abbrev() because we also need to make
>          * sure that the abbreviation does not conflict with any other
>          * label.
>          *
> diff --git a/strbuf.h b/strbuf.h
> index f6dbb9681ee..b980f9edc6d 100644
> --- a/strbuf.h
> +++ b/strbuf.h
> @@ -631,7 +631,7 @@ void strbuf_add_separated_string_list(struct strbuf *str,
>  void strbuf_list_free(struct strbuf **list);
>
>  /**
> - * Add the abbreviation, as generated by find_unique_abbrev, of `sha1` to
> + * Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
>   * the strbuf `sb`.
>   */
>  struct repository;
> @@ -706,14 +706,14 @@ static inline void strbuf_complete_line(struct strbuf *sb)
>
>  /*
>   * Copy "name" to "sb", expanding any special @-marks as handled by
> - * interpret_branch_name(). The result is a non-qualified branch name
> + * repo_interpret_branch_name(). The result is a non-qualified branch name
>   * (so "foo" or "origin/master" instead of "refs/heads/foo" or
>   * "refs/remotes/origin/master").
>   *
>   * Note that the resulting name may not be a syntactically valid refname.
>   *
>   * If "allowed" is non-zero, restrict the set of allowed expansions. See
> - * interpret_branch_name() for details.
> + * repo_interpret_branch_name() for details.
>   */
>  void strbuf_branchname(struct strbuf *sb, const char *name,
>                        unsigned allowed);
> --
> 2.40.0.rc1.1034.g5867a1b10c5

Looks good.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 17/17] libs: use "struct repository *" argument, not "the_repository"
  2023-03-17 15:35 ` [PATCH 17/17] libs: use "struct repository *" argument, not "the_repository" Ævar Arnfjörð Bjarmason
@ 2023-03-19  6:19   ` Elijah Newren
  2023-03-28 10:53     ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 60+ messages in thread
From: Elijah Newren @ 2023-03-19  6:19 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Junio C Hamano

On Fri, Mar 17, 2023 at 8:55 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> As can easily be seen from grepping in our sources, we had these uses
> of "the_repository" in various library code in cases where the
> function in question was already getting a "struct repository *"
> argument. Let's use that argument instead.
>
> Out of these changes only the changes to "cache-tree.c",
> "commit-reach.c", "shallow.c" and "upload-pack.c" would have cleanly
> applied before the migration away from the "repo_*()" wrapper macros
> in the preceding commits.
>
> The rest aren't new, as we'd previously implicitly refer to
> "the_repository", but it's now more obvious that we were doing the
> wrong thing all along, and should have used the parameter instead.

YES!  I love seeing fixes like this.  I noticed some a while back in
the merge code, and had some patches somewhere that I think I never
got around to submitting, but which have been in the back of my mind
bugging me.  Nice to see lots of these kinds of cases getting fixed.

> The change to change "get_index_format_default(the_repository)" in
> "read-cache.c" to use the "r" variable instead should arguably have
> been part of [1], or in the subsequent cleanup in [2]. Let's do it
> here, as can be seen from the initial code in [3] it's not important
> that we use "the_repository" there, but would prefer to always use the
> current repository.
>
> This change excludes the "the_repository" use in "upload-pack.c"'s
> upload_pack_advertise(), as the in-flight [4] makes that change.
>
> 1. ee1f0c242ef (read-cache: add index.skipHash config option,
>    2023-01-06)
> 2. 6269f8eaad0 (treewide: always have a valid "index_state.repo"
>    member, 2023-01-17)
> 3. 7211b9e7534 (repo-settings: consolidate some config settings,
>    2019-08-13)
> 4. <Y/hbUsGPVNAxTdmS@coredump.intra.peff.net>
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  add-interactive.c |   2 +-
>  branch.c          |   8 ++--
>  builtin/replace.c |   2 +-
>  cache-tree.c      |   4 +-
>  combine-diff.c    |   2 +-
>  commit-graph.c    |   2 +-
>  commit-reach.c    |   2 +-
>  merge-recursive.c |   2 +-

Doh, doesn't fix up the ones I had.  I don't remember the exact issue
and can't find the patches right now, but looking around a little I
see a write_object_file() which should be a repo_write_object_file(),
but it's in a function that doesn't take a repository argument.
However, the caller has access to a repository argument, in the form
of opt->repo, so we've got some low-hanging fruit that could be fixed
up.  Doesn't need to be part of your series, but it's nice that your
series has done some of the groundwork to make these issues more
obvious.

>  notes-cache.c     |   2 +-
>  notes-utils.c     |   2 +-
>  object-name.c     |   8 ++--
>  read-cache.c      |   4 +-
>  reset.c           |   2 +-
>  sequencer.c       | 102 ++++++++++++++++++++++------------------------
>  shallow.c         |   2 +-
>  tree.c            |   2 +-
>  wt-status.c       |  10 ++---
>  17 files changed, 76 insertions(+), 82 deletions(-)
>
> diff --git a/add-interactive.c b/add-interactive.c
> index 33f41d65a47..02bf6fc15cb 100644
> --- a/add-interactive.c
> +++ b/add-interactive.c
> @@ -551,7 +551,7 @@ static int get_modified_files(struct repository *r,
>                 opt.def = is_initial ?
>                         empty_tree_oid_hex() : oid_to_hex(&head_oid);
>
> -               repo_init_revisions(the_repository, &rev, NULL);
> +               repo_init_revisions(r, &rev, NULL);
>                 setup_revisions(0, NULL, &rev, &opt);
>
>                 rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
> diff --git a/branch.c b/branch.c
> index a01e465b114..2b266e6fcb9 100644
> --- a/branch.c
> +++ b/branch.c
> @@ -531,7 +531,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
>                 explicit_tracking = 1;
>
>         real_ref = NULL;
> -       if (repo_get_oid_mb(the_repository, start_name, &oid)) {
> +       if (repo_get_oid_mb(r, start_name, &oid)) {
>                 if (explicit_tracking) {
>                         int code = die_message(_(upstream_missing), start_name);
>                         advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
> @@ -541,8 +541,8 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
>                 die(_("not a valid object name: '%s'"), start_name);
>         }
>
> -       switch (repo_dwim_ref(the_repository, start_name, strlen(start_name),
> -                             &oid, &real_ref, 0)) {
> +       switch (repo_dwim_ref(r, start_name, strlen(start_name), &oid,
> +                             &real_ref, 0)) {
>         case 0:
>                 /* Not branching from any existing branch */
>                 if (explicit_tracking)
> @@ -773,7 +773,7 @@ void create_branches_recursively(struct repository *r, const char *name,
>                             name);
>         }
>
> -       create_branch(the_repository, name, start_commitish, force, 0, reflog, quiet,
> +       create_branch(r, name, start_commitish, force, 0, reflog, quiet,
>                       BRANCH_TRACK_NEVER, dry_run);
>         if (dry_run)
>                 return;
> diff --git a/builtin/replace.c b/builtin/replace.c
> index 85f0b79c924..bd67107a7c7 100644
> --- a/builtin/replace.c
> +++ b/builtin/replace.c
> @@ -54,7 +54,7 @@ static int show_reference(struct repository *r, const char *refname,
>                         struct object_id object;
>                         enum object_type obj_type, repl_type;
>
> -                       if (repo_get_oid(the_repository, refname, &object))
> +                       if (repo_get_oid(r, refname, &object))
>                                 return error(_("failed to resolve '%s' as a valid ref"), refname);
>
>                         obj_type = oid_object_info(r, &object, NULL);
> diff --git a/cache-tree.c b/cache-tree.c
> index ab2cc1edf29..b0e490b5aa4 100644
> --- a/cache-tree.c
> +++ b/cache-tree.c
> @@ -814,14 +814,14 @@ void prime_cache_tree(struct repository *r,
>  {
>         struct strbuf tree_path = STRBUF_INIT;
>
> -       trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
> +       trace2_region_enter("cache-tree", "prime_cache_tree", r);
>         cache_tree_free(&istate->cache_tree);
>         istate->cache_tree = cache_tree();
>
>         prime_cache_tree_rec(r, istate->cache_tree, tree, &tree_path);
>         strbuf_release(&tree_path);
>         istate->cache_changed |= CACHE_TREE_CHANGED;
> -       trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
> +       trace2_region_leave("cache-tree", "prime_cache_tree", r);
>  }
>
>  /*
> diff --git a/combine-diff.c b/combine-diff.c
> index 20f8a03924f..fa5967a5be6 100644
> --- a/combine-diff.c
> +++ b/combine-diff.c
> @@ -332,7 +332,7 @@ static char *grab_blob(struct repository *r,
>                 *size = fill_textconv(r, textconv, df, &blob);
>                 free_filespec(df);
>         } else {
> -               blob = repo_read_object_file(the_repository, oid, &type, size);
> +               blob = repo_read_object_file(r, oid, &type, size);
>                 if (type != OBJ_BLOB)
>                         die("object '%s' is not a blob!", oid_to_hex(oid));
>         }
> diff --git a/commit-graph.c b/commit-graph.c
> index 268410e913c..035816f4d8c 100644
> --- a/commit-graph.c
> +++ b/commit-graph.c
> @@ -2549,7 +2549,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
>
>                 graph_commit = lookup_commit(r, &cur_oid);
>                 odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
> -               if (repo_parse_commit_internal(the_repository, odb_commit, 0, 0)) {
> +               if (repo_parse_commit_internal(r, odb_commit, 0, 0)) {
>                         graph_report(_("failed to parse commit %s from object database for commit-graph"),
>                                      oid_to_hex(&cur_oid));
>                         continue;
> diff --git a/commit-reach.c b/commit-reach.c
> index c88faf7e7b2..01eb11b5957 100644
> --- a/commit-reach.c
> +++ b/commit-reach.c
> @@ -448,7 +448,7 @@ int repo_is_descendant_of(struct repository *r,
>         if (!with_commit)
>                 return 1;
>
> -       if (generation_numbers_enabled(the_repository)) {
> +       if (generation_numbers_enabled(r)) {
>                 struct commit_list *from_list = NULL;
>                 int result;
>                 commit_list_insert(commit, &from_list);
> diff --git a/merge-recursive.c b/merge-recursive.c
> index d83ce19bb1f..20aa18e2203 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -3798,7 +3798,7 @@ static struct commit *get_ref(struct repository *repo,
>                 return make_virtual_commit(repo, (struct tree*)object, name);
>         if (object->type != OBJ_COMMIT)
>                 return NULL;
> -       if (repo_parse_commit(the_repository, (struct commit *)object))
> +       if (repo_parse_commit(repo, (struct commit *)object))
>                 return NULL;
>         return (struct commit *)object;
>  }
> diff --git a/notes-cache.c b/notes-cache.c
> index e5e9092d367..1a6e214ea79 100644
> --- a/notes-cache.c
> +++ b/notes-cache.c
> @@ -23,7 +23,7 @@ static int notes_cache_match_validity(struct repository *r,
>                 return 0;
>
>         memset(&pretty_ctx, 0, sizeof(pretty_ctx));
> -       repo_format_commit_message(the_repository, commit, "%s", &msg,
> +       repo_format_commit_message(r, commit, "%s", &msg,
>                                    &pretty_ctx);
>         strbuf_trim(&msg);
>
> diff --git a/notes-utils.c b/notes-utils.c
> index 0550cfded86..4be0aaa6de9 100644
> --- a/notes-utils.c
> +++ b/notes-utils.c
> @@ -23,7 +23,7 @@ void create_notes_commit(struct repository *r,
>                 struct object_id parent_oid;
>                 if (!read_ref(t->ref, &parent_oid)) {
>                         struct commit *parent = lookup_commit(r, &parent_oid);
> -                       if (repo_parse_commit(the_repository, parent))
> +                       if (repo_parse_commit(r, parent))
>                                 die("Failed to find/parse commit %s", t->ref);
>                         commit_list_insert(parent, &parents);
>                 }
> diff --git a/object-name.c b/object-name.c
> index df31f192ce3..c7bc311dcef 100644
> --- a/object-name.c
> +++ b/object-name.c
> @@ -1038,7 +1038,7 @@ static enum get_oid_result get_parent(struct repository *r,
>         if (ret)
>                 return ret;
>         commit = lookup_commit_reference(r, &oid);
> -       if (repo_parse_commit(the_repository, commit))
> +       if (repo_parse_commit(r, commit))
>                 return MISSING_OBJECT;
>         if (!idx) {
>                 oidcpy(result, &commit->object.oid);
> @@ -1072,7 +1072,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r,
>                 return MISSING_OBJECT;
>
>         while (generation--) {
> -               if (repo_parse_commit(the_repository, commit) || !commit->parents)
> +               if (repo_parse_commit(r, commit) || !commit->parents)
>                         return MISSING_OBJECT;
>                 commit = commit->parents->item;
>         }
> @@ -1363,10 +1363,10 @@ static int get_oid_oneline(struct repository *r,
>                 commit = pop_most_recent_commit(&list, ONELINE_SEEN);
>                 if (!parse_object(r, &commit->object.oid))
>                         continue;
> -               buf = repo_get_commit_buffer(the_repository, commit, NULL);
> +               buf = repo_get_commit_buffer(r, commit, NULL);
>                 p = strstr(buf, "\n\n");
>                 matches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));
> -               repo_unuse_commit_buffer(the_repository, commit, buf);
> +               repo_unuse_commit_buffer(r, commit, buf);
>
>                 if (matches) {
>                         oidcpy(oid, &commit->object.oid);
> diff --git a/read-cache.c b/read-cache.c
> index 1548e886684..892fede6b41 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -2628,7 +2628,7 @@ int repo_index_has_changes(struct repository *repo,
>
>         if (tree)
>                 cmp = tree->object.oid;
> -       if (tree || !repo_get_oid_tree(the_repository, "HEAD", &cmp)) {
> +       if (tree || !repo_get_oid_tree(repo, "HEAD", &cmp)) {
>                 struct diff_options opt;
>
>                 repo_diff_setup(repo, &opt);
> @@ -2947,7 +2947,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
>         }
>
>         if (!istate->version)
> -               istate->version = get_index_format_default(the_repository);
> +               istate->version = get_index_format_default(r);
>
>         /* demote version 3 to version 2 when the latter suffices */
>         if (istate->version == 3 || istate->version == 2)
> diff --git a/reset.c b/reset.c
> index 3a9c6dfdd0a..65f8138c78b 100644
> --- a/reset.c
> +++ b/reset.c
> @@ -106,7 +106,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
>                 goto leave_reset_head;
>         }
>
> -       if (!repo_get_oid(the_repository, "HEAD", &head_oid)) {
> +       if (!repo_get_oid(r, "HEAD", &head_oid)) {
>                 head = &head_oid;
>         } else if (!oid || !reset_hard) {
>                 ret = error(_("could not determine HEAD revision"));
> diff --git a/sequencer.c b/sequencer.c
> index fb5a540fa04..f8f4e72112c 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -694,8 +694,8 @@ static int do_recursive_merge(struct repository *r,
>         o.show_rename_progress = 1;
>
>         head_tree = parse_tree_indirect(head);
> -       next_tree = next ? repo_get_commit_tree(the_repository, next) : empty_tree(r);
> -       base_tree = base ? repo_get_commit_tree(the_repository, base) : empty_tree(r);
> +       next_tree = next ? repo_get_commit_tree(r, next) : empty_tree(r);
> +       base_tree = base ? repo_get_commit_tree(r, base) : empty_tree(r);
>
>         for (i = 0; i < opts->xopts_nr; i++)
>                 parse_merge_opt(&o, opts->xopts[i]);
> @@ -773,7 +773,7 @@ static int is_index_unchanged(struct repository *r)
>          * the commit is invalid, repo_parse_commit() will complain.  So
>          * there is nothing for us to say here.  Just return failure.
>          */
> -       if (repo_parse_commit(the_repository, head_commit))
> +       if (repo_parse_commit(r, head_commit))
>                 return -1;
>
>         if (!(cache_tree_oid = get_cache_tree_oid(istate)))
> @@ -1338,15 +1338,15 @@ void print_commit_summary(struct repository *r,
>         commit = lookup_commit(r, oid);
>         if (!commit)
>                 die(_("couldn't look up newly created commit"));
> -       if (repo_parse_commit(the_repository, commit))
> +       if (repo_parse_commit(r, commit))
>                 die(_("could not parse newly created commit"));
>
>         strbuf_addstr(&format, "format:%h] %s");
>
> -       repo_format_commit_message(the_repository, commit, "%an <%ae>",
> -                                  &author_ident, &pctx);
> -       repo_format_commit_message(the_repository, commit, "%cn <%ce>",
> -                                  &committer_ident, &pctx);
> +       repo_format_commit_message(r, commit, "%an <%ae>", &author_ident,
> +                                  &pctx);
> +       repo_format_commit_message(r, commit, "%cn <%ce>", &committer_ident,
> +                                  &pctx);
>         if (strbuf_cmp(&author_ident, &committer_ident)) {
>                 strbuf_addstr(&format, "\n Author: ");
>                 strbuf_addbuf_percentquote(&format, &author_ident);
> @@ -1354,8 +1354,7 @@ void print_commit_summary(struct repository *r,
>         if (flags & SUMMARY_SHOW_AUTHOR_DATE) {
>                 struct strbuf date = STRBUF_INIT;
>
> -               repo_format_commit_message(the_repository, commit, "%ad",
> -                                          &date, &pctx);
> +               repo_format_commit_message(r, commit, "%ad", &date, &pctx);
>                 strbuf_addstr(&format, "\n Date: ");
>                 strbuf_addbuf_percentquote(&format, &date);
>                 strbuf_release(&date);
> @@ -1385,7 +1384,7 @@ void print_commit_summary(struct repository *r,
>         rev.diffopt.detect_rename = DIFF_DETECT_RENAME;
>         diff_setup_done(&rev.diffopt);
>
> -       refs = get_main_ref_store(the_repository);
> +       refs = get_main_ref_store(r);
>         head = refs_resolve_ref_unsafe(refs, "HEAD", 0, NULL, NULL);
>         if (!head)
>                 die(_("unable to resolve HEAD after creating commit"));
> @@ -1411,7 +1410,7 @@ static int parse_head(struct repository *r, struct commit **head)
>         struct commit *current_head;
>         struct object_id oid;
>
> -       if (repo_get_oid(the_repository, "HEAD", &oid)) {
> +       if (repo_get_oid(r, "HEAD", &oid)) {
>                 current_head = NULL;
>         } else {
>                 current_head = lookup_commit_reference(r, &oid);
> @@ -1421,7 +1420,7 @@ static int parse_head(struct repository *r, struct commit **head)
>                         warning(_("HEAD %s is not a commit!"),
>                                 oid_to_hex(&oid));
>                 }
> -               if (repo_parse_commit(the_repository, current_head))
> +               if (repo_parse_commit(r, current_head))
>                         return error(_("could not parse HEAD commit"));
>         }
>         *head = current_head;
> @@ -1464,9 +1463,8 @@ static int try_to_commit(struct repository *r,
>         if (flags & AMEND_MSG) {
>                 const char *exclude_gpgsig[] = { "gpgsig", "gpgsig-sha256", NULL };
>                 const char *out_enc = get_commit_output_encoding();
> -               const char *message = repo_logmsg_reencode(the_repository,
> -                                                          current_head, NULL,
> -                                                          out_enc);
> +               const char *message = repo_logmsg_reencode(r, current_head,
> +                                                          NULL, out_enc);
>
>                 if (!msg) {
>                         const char *orig_message = NULL;
> @@ -1477,7 +1475,7 @@ static int try_to_commit(struct repository *r,
>                         hook_commit = "HEAD";
>                 }
>                 author = amend_author = get_author(message);
> -               repo_unuse_commit_buffer(the_repository, current_head,
> +               repo_unuse_commit_buffer(r, current_head,
>                                          message);
>                 if (!author) {
>                         res = error(_("unable to parse commit author"));
> @@ -2004,18 +2002,18 @@ static int update_squash_messages(struct repository *r,
>                 struct commit *head_commit;
>                 const char *head_message, *body;
>
> -               if (repo_get_oid(the_repository, "HEAD", &head))
> +               if (repo_get_oid(r, "HEAD", &head))
>                         return error(_("need a HEAD to fixup"));
>                 if (!(head_commit = lookup_commit_reference(r, &head)))
>                         return error(_("could not read HEAD"));
> -               if (!(head_message = repo_logmsg_reencode(the_repository, head_commit, NULL, encoding)))
> +               if (!(head_message = repo_logmsg_reencode(r, head_commit, NULL,
> +                                                         encoding)))
>                         return error(_("could not read HEAD's commit message"));
>
>                 find_commit_subject(head_message, &body);
>                 if (command == TODO_FIXUP && !flag && write_message(body, strlen(body),
>                                                         rebase_path_fixup_msg(), 0) < 0) {
> -                       repo_unuse_commit_buffer(the_repository, head_commit,
> -                                                head_message);
> +                       repo_unuse_commit_buffer(r, head_commit, head_message);
>                         return error(_("cannot write '%s'"), rebase_path_fixup_msg());
>                 }
>                 strbuf_addf(&buf, "%c ", comment_line_char);
> @@ -2030,11 +2028,10 @@ static int update_squash_messages(struct repository *r,
>                 else
>                         strbuf_addstr(&buf, body);
>
> -               repo_unuse_commit_buffer(the_repository, head_commit,
> -                                        head_message);
> +               repo_unuse_commit_buffer(r, head_commit, head_message);
>         }
>
> -       if (!(message = repo_logmsg_reencode(the_repository, commit, NULL, encoding)))
> +       if (!(message = repo_logmsg_reencode(r, commit, NULL, encoding)))
>                 return error(_("could not read commit message of %s"),
>                              oid_to_hex(&commit->object.oid));
>         find_commit_subject(message, &body);
> @@ -2049,7 +2046,7 @@ static int update_squash_messages(struct repository *r,
>                 strbuf_add_commented_lines(&buf, body, strlen(body));
>         } else
>                 return error(_("unknown command: %d"), command);
> -       repo_unuse_commit_buffer(the_repository, commit, message);
> +       repo_unuse_commit_buffer(r, commit, message);
>
>         if (!res)
>                 res = write_message(buf.buf, buf.len, rebase_path_squash_msg(),
> @@ -2162,7 +2159,7 @@ static int do_pick_commit(struct repository *r,
>                 if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL))
>                         return error(_("your index file is unmerged."));
>         } else {
> -               unborn = repo_get_oid(the_repository, "HEAD", &head);
> +               unborn = repo_get_oid(r, "HEAD", &head);
>                 /* Do we want to generate a root commit? */
>                 if (is_pick_or_similar(command) && opts->have_squash_onto &&
>                     oideq(&head, &opts->squash_onto)) {
> @@ -2224,7 +2221,7 @@ static int do_pick_commit(struct repository *r,
>                 msg_file = NULL;
>                 goto fast_forward_edit;
>         }
> -       if (parent && repo_parse_commit(the_repository, parent) < 0)
> +       if (parent && repo_parse_commit(r, parent) < 0)
>                 /* TRANSLATORS: The first %s will be a "todo" command like
>                    "revert" or "pick", the second %s a SHA1. */
>                 return error(_("%s: cannot parse parent commit %s"),
> @@ -2616,7 +2613,7 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
>         end_of_object_name = (char *) bol + strcspn(bol, " \t\n");
>         saved = *end_of_object_name;
>         *end_of_object_name = '\0';
> -       status = repo_get_oid(the_repository, bol, &commit_oid);
> +       status = repo_get_oid(r, bol, &commit_oid);
>         if (status < 0)
>                 error(_("could not parse '%s'"), bol); /* return later */
>         *end_of_object_name = saved;
> @@ -3531,12 +3528,12 @@ static int make_patch(struct repository *r,
>         strbuf_addf(&buf, "%s/message", get_dir(opts));
>         if (!file_exists(buf.buf)) {
>                 const char *encoding = get_commit_output_encoding();
> -               const char *commit_buffer = repo_logmsg_reencode(the_repository,
> +               const char *commit_buffer = repo_logmsg_reencode(r,
>                                                                  commit, NULL,
>                                                                  encoding);
>                 find_commit_subject(commit_buffer, &subject);
>                 res |= write_message(subject, strlen(subject), buf.buf, 1);
> -               repo_unuse_commit_buffer(the_repository, commit,
> +               repo_unuse_commit_buffer(r, commit,
>                                          commit_buffer);
>         }
>         strbuf_release(&buf);
> @@ -3716,7 +3713,7 @@ static int do_label(struct repository *r, const char *name, int len)
>         if (!transaction) {
>                 error("%s", err.buf);
>                 ret = -1;
> -       } else if (repo_get_oid(the_repository, "HEAD", &head_oid)) {
> +       } else if (repo_get_oid(r, "HEAD", &head_oid)) {
>                 error(_("could not read HEAD"));
>                 ret = -1;
>         } else if (ref_transaction_update(transaction, ref_name.buf, &head_oid,
> @@ -4004,8 +4001,7 @@ static int do_merge(struct repository *r,
>
>         if (commit) {
>                 const char *encoding = get_commit_output_encoding();
> -               const char *message = repo_logmsg_reencode(the_repository,
> -                                                          commit, NULL,
> +               const char *message = repo_logmsg_reencode(r, commit, NULL,
>                                                            encoding);
>                 const char *body;
>                 int len;
> @@ -4019,7 +4015,7 @@ static int do_merge(struct repository *r,
>                 find_commit_subject(message, &body);
>                 len = strlen(body);
>                 ret = write_message(body, len, git_path_merge_msg(r), 0);
> -               repo_unuse_commit_buffer(the_repository, commit, message);
> +               repo_unuse_commit_buffer(r, commit, message);
>                 if (ret) {
>                         error_errno(_("could not write '%s'"),
>                                     git_path_merge_msg(r));
> @@ -4119,8 +4115,7 @@ static int do_merge(struct repository *r,
>         }
>
>         merge_commit = to_merge->item;
> -       bases = repo_get_merge_bases(the_repository, head_commit,
> -                                    merge_commit);
> +       bases = repo_get_merge_bases(r, head_commit, merge_commit);
>         if (bases && oideq(&merge_commit->object.oid,
>                            &bases->item->object.oid)) {
>                 ret = 0;
> @@ -4475,7 +4470,7 @@ void create_autostash(struct repository *r, const char *path)
>                 if (capture_command(&stash, &buf, GIT_MAX_HEXSZ))
>                         die(_("Cannot autostash"));
>                 strbuf_trim_trailing_newline(&buf);
> -               if (repo_get_oid(the_repository, buf.buf, &oid))
> +               if (repo_get_oid(r, buf.buf, &oid))
>                         die(_("Unexpected stash response: '%s'"),
>                             buf.buf);
>                 strbuf_reset(&buf);
> @@ -4600,9 +4595,9 @@ static int stopped_at_head(struct repository *r)
>         struct commit *commit;
>         struct commit_message message;
>
> -       if (repo_get_oid(the_repository, "HEAD", &head) ||
> +       if (repo_get_oid(r, "HEAD", &head) ||
>             !(commit = lookup_commit(r, &head)) ||
> -           repo_parse_commit(the_repository, commit) || get_message(commit, &message))
> +           repo_parse_commit(r, commit) || get_message(commit, &message))
>                 fprintf(stderr, _("Stopped at HEAD\n"));
>         else {
>                 fprintf(stderr, _("Stopped at %s\n"), message.label);
> @@ -4750,7 +4745,7 @@ static int pick_commits(struct repository *r,
>                                  * otherwise we do not.
>                                  */
>                                 if (item->command == TODO_REWORD &&
> -                                   !repo_get_oid(the_repository, "HEAD", &oid) &&
> +                                   !repo_get_oid(r, "HEAD", &oid) &&
>                                     (oideq(&item->commit->object.oid, &oid) ||
>                                      (opts->have_squash_onto &&
>                                       oideq(&opts->squash_onto, &oid))))
> @@ -4839,7 +4834,7 @@ static int pick_commits(struct repository *r,
>                         struct object_id head, orig;
>                         int res;
>
> -                       if (repo_get_oid(the_repository, "HEAD", &head)) {
> +                       if (repo_get_oid(r, "HEAD", &head)) {
>                                 res = error(_("cannot read HEAD"));
>  cleanup_head_ref:
>                                 strbuf_release(&head_ref);
> @@ -4886,8 +4881,8 @@ static int pick_commits(struct repository *r,
>                         log_tree_opt.disable_stdin = 1;
>
>                         if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
> -                           !repo_get_oid(the_repository, buf.buf, &orig) &&
> -                           !repo_get_oid(the_repository, "HEAD", &head)) {
> +                           !repo_get_oid(r, buf.buf, &orig) &&
> +                           !repo_get_oid(r, "HEAD", &head)) {
>                                 diff_tree_oid(&orig, &head, "",
>                                               &log_tree_opt.diffopt);
>                                 log_tree_diff_flush(&log_tree_opt);
> @@ -4979,7 +4974,7 @@ static int commit_staged_changes(struct repository *r,
>                 struct strbuf rev = STRBUF_INIT;
>                 struct object_id head, to_amend;
>
> -               if (repo_get_oid(the_repository, "HEAD", &head))
> +               if (repo_get_oid(r, "HEAD", &head))
>                         return error(_("cannot amend non-existing commit"));
>                 if (!read_oneliner(&rev, rebase_path_amend(), 0))
>                         return error(_("invalid file: '%s'"), rebase_path_amend());
> @@ -5059,14 +5054,13 @@ static int commit_staged_changes(struct repository *r,
>                                 const char *encoding = get_commit_output_encoding();
>
>                                 if (parse_head(r, &commit) ||
> -                                   !(p = repo_logmsg_reencode(the_repository, commit, NULL, encoding)) ||
> +                                   !(p = repo_logmsg_reencode(r, commit, NULL, encoding)) ||
>                                     write_message(p, strlen(p), path, 0)) {
> -                                       repo_unuse_commit_buffer(the_repository,
> -                                                                commit, p);
> +                                       repo_unuse_commit_buffer(r, commit, p);
>                                         return error(_("could not write file: "
>                                                        "'%s'"), path);
>                                 }
> -                               repo_unuse_commit_buffer(the_repository,
> +                               repo_unuse_commit_buffer(r,
>                                                          commit, p);
>                         }
>                 }
> @@ -5206,7 +5200,7 @@ int sequencer_pick_revisions(struct repository *r,
>                 if (!strlen(name))
>                         continue;
>
> -               if (!repo_get_oid(the_repository, name, &oid)) {
> +               if (!repo_get_oid(r, name, &oid)) {
>                         if (!lookup_commit_reference_gently(r, &oid, 1)) {
>                                 enum object_type type = oid_object_info(r,
>                                                                         &oid,
> @@ -5249,7 +5243,7 @@ int sequencer_pick_revisions(struct repository *r,
>         if (walk_revs_populate_todo(&todo_list, opts) ||
>                         create_seq_dir(r) < 0)
>                 return -1;
> -       if (repo_get_oid(the_repository, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
> +       if (repo_get_oid(r, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
>                 return error(_("can't revert as initial commit"));
>         if (save_head(oid_to_hex(&oid)))
>                 return -1;
> @@ -5944,7 +5938,7 @@ static int skip_unnecessary_picks(struct repository *r,
>                         continue;
>                 if (item->command != TODO_PICK)
>                         break;
> -               if (repo_parse_commit(the_repository, item->commit)) {
> +               if (repo_parse_commit(r, item->commit)) {
>                         return error(_("could not parse commit '%s'"),
>                                 oid_to_hex(&item->commit->object.oid));
>                 }
> @@ -6115,7 +6109,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
>         struct object_id oid = onto->object.oid;
>         int res;
>
> -       repo_find_unique_abbrev_r(the_repository, shortonto, &oid,
> +       repo_find_unique_abbrev_r(r, shortonto, &oid,
>                                   DEFAULT_ABBREV);
>
>         if (buf->len == 0) {
> @@ -6395,8 +6389,8 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
>                 if (file_exists(git_path_seq_dir()))
>                         *whence = FROM_CHERRY_PICK_MULTI;
>                 if (file_exists(rebase_path()) &&
> -                   !repo_get_oid(the_repository, "REBASE_HEAD", &rebase_head) &&
> -                   !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
> +                   !repo_get_oid(r, "REBASE_HEAD", &rebase_head) &&
> +                   !repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
>                     oideq(&rebase_head, &cherry_pick_head))
>                         *whence = FROM_REBASE_PICK;
>                 else
> diff --git a/shallow.c b/shallow.c
> index 07278467e47..fbafc4b30e9 100644
> --- a/shallow.c
> +++ b/shallow.c
> @@ -30,7 +30,7 @@ int register_shallow(struct repository *r, const struct object_id *oid)
>  {
>         struct commit_graft *graft =
>                 xmalloc(sizeof(struct commit_graft));
> -       struct commit *commit = lookup_commit(the_repository, oid);
> +       struct commit *commit = lookup_commit(r, oid);
>
>         oidcpy(&graft->oid, oid);
>         graft->nr_parent = -1;
> diff --git a/tree.c b/tree.c
> index 1b403c4b5ce..8643b734642 100644
> --- a/tree.c
> +++ b/tree.c
> @@ -58,7 +58,7 @@ int read_tree_at(struct repository *r,
>                                     oid_to_hex(&entry.oid),
>                                     base->buf, entry.path);
>
> -                       if (repo_parse_commit(the_repository, commit))
> +                       if (repo_parse_commit(r, commit))
>                                 die("Invalid commit %s in submodule path %s%s",
>                                     oid_to_hex(&entry.oid),
>                                     base->buf, entry.path);
> diff --git a/wt-status.c b/wt-status.c
> index dcd1d0cee4c..28e35a2165a 100644
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -1664,7 +1664,7 @@ static void wt_status_get_detached_from(struct repository *r,
>                 return;
>         }
>
> -       if (repo_dwim_ref(the_repository, cb.buf.buf, cb.buf.len, &oid, &ref,
> +       if (repo_dwim_ref(r, cb.buf.buf, cb.buf.len, &oid, &ref,
>                           1) == 1 &&
>             /* oid is a commit? match without further lookup */
>             (oideq(&cb.noid, &oid) ||
> @@ -1677,9 +1677,9 @@ static void wt_status_get_detached_from(struct repository *r,
>                 state->detached_from = xstrdup(from);
>         } else
>                 state->detached_from =
> -                       xstrdup(repo_find_unique_abbrev(the_repository, &cb.noid, DEFAULT_ABBREV));
> +                       xstrdup(repo_find_unique_abbrev(r, &cb.noid, DEFAULT_ABBREV));
>         oidcpy(&state->detached_oid, &cb.noid);
> -       state->detached_at = !repo_get_oid(the_repository, "HEAD", &oid) &&
> +       state->detached_at = !repo_get_oid(r, "HEAD", &oid) &&
>                              oideq(&oid, &state->detached_oid);
>
>         free(ref);
> @@ -1770,13 +1770,13 @@ void wt_status_get_state(struct repository *r,
>         } else if (wt_status_check_rebase(NULL, state)) {
>                 ;               /* all set */
>         } else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
> -                  !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &oid)) {
> +                  !repo_get_oid(r, "CHERRY_PICK_HEAD", &oid)) {
>                 state->cherry_pick_in_progress = 1;
>                 oidcpy(&state->cherry_pick_head_oid, &oid);
>         }
>         wt_status_check_bisect(NULL, state);
>         if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") &&
> -           !repo_get_oid(the_repository, "REVERT_HEAD", &oid)) {
> +           !repo_get_oid(r, "REVERT_HEAD", &oid)) {
>                 state->revert_in_progress = 1;
>                 oidcpy(&state->revert_head_oid, &oid);
>         }
> --
> 2.40.0.rc1.1034.g5867a1b10c5

I started looking through it closely, but after a bit I realized that
the only kind of error you would likely to be make here would be the
kind caught by the compiler, so then I started just skimming over it.
But I think that's safe for this kind of change.  I'm a big fan of
these kinds of cleanups and fixups, though.

I'm not sure I can give a Reviewed-by since I just don't know cocci,
but it all looked pretty logical.  You definitely have my Acked-by on
the series, though.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules
  2023-03-17 15:35 ` [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
  2023-03-19  5:55   ` Elijah Newren
@ 2023-03-22 22:46   ` Glen Choo
  2023-03-26  5:02     ` Ævar Arnfjörð Bjarmason
  1 sibling, 1 reply; 60+ messages in thread
From: Glen Choo @ 2023-03-22 22:46 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason, git
  Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason


Every time I try to read cocci and spatch docs, I'm impressed at how
impenetrable they are ;) Nevertheless, I'd still like to understand how
the pattern works. I'll take a stab in the dark, and perhaps you can
correct me.

Ævar Arnfjörð Bjarmason         <avarab@gmail.com> writes:

> +(
> +- read_object_file
> ++ repo_read_object_file
> +|
> +- has_object_file
> ++ repo_has_object_file
> +|
> +- has_object_file_with_flags
> ++ repo_has_object_file_with_flags
> +|
> +- parse_commit_internal
> ++ repo_parse_commit_internal
> +|
> +- parse_commit
> ++ repo_parse_commit
> +|
> +- get_merge_bases
> ++ repo_get_merge_bases
> +|
> +- get_merge_bases_many
> ++ repo_get_merge_bases_many
> +|
> +- get_merge_bases_many_dirty
> ++ repo_get_merge_bases_many_dirty
> +|
> +- in_merge_bases
> ++ repo_in_merge_bases
> +|
> +- in_merge_bases_many
> ++ repo_in_merge_bases_many
> +|
> +- get_commit_buffer
> ++ repo_get_commit_buffer
> +|
> +- unuse_commit_buffer
> ++ repo_unuse_commit_buffer
> +|
> +- logmsg_reencode
> ++ repo_logmsg_reencode
> +|
> +- format_commit_message
> ++ repo_format_commit_message
> +)

I assume that `|` characters in parentheses are a logical OR, and each
of the expressions checks for the `-` side in the original and replaces
it with the `+` side.

> +  (
> ++ the_repository,
> +  ...)

Then this is another expression that matches literal `()` after the
previous expression? `+the_repository` adds `the_repository` right after
the opening `(`, then leaves the uninteresting `...` in place.

If so, I don't know how cocci/spatch tells the difference between
literal `()` vs an expression in the syntax (preceding whitespace?).

Either way, as Elijah said, your plain explanation is clear enough that
I feel comfortable with this.

> -- 
> 2.40.0.rc1.1034.g5867a1b10c5

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 05/17] cocci: apply the "cache.h" part of "the_repository.pending"
  2023-03-17 15:35 ` [PATCH 05/17] cocci: apply the "cache.h" part of "the_repository.pending" Ævar Arnfjörð Bjarmason
  2023-03-19  6:06   ` Elijah Newren
@ 2023-03-22 23:17   ` Glen Choo
  1 sibling, 0 replies; 60+ messages in thread
From: Glen Choo @ 2023-03-22 23:17 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason, git
  Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Ævar Arnfjörð Bjarmason         <avarab@gmail.com> writes:

> Apply the part of "the_repository.pending.cocci" pertaining to
> "cache.h".

Like Elijah, I skimmed most of these "apply cocci" patches, since the
code correctness would be enfoced by the compiler anyway.

For reasonableness, I checked that each patch did the following...

>  cache.h                                       | 15 ------

Remove the macros/function definitions from the header file being
touched.

>  contrib/coccinelle/the_repository.cocci       | 44 ++++++++++++++++

Add the relevant lines to contrib/coccinelle/the_repository.cocci

>  .../coccinelle/the_repository.pending.cocci   | 37 --------------

Remove the relevant lines from
contrib/coccinelle/the_repository.pending.cocci.

And all the patches did this, so the patch organization looks good :)

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 15/17] cocci: apply the "revision.h" part of "the_repository.pending"
  2023-03-17 15:35 ` [PATCH 15/17] cocci: apply the "revision.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-22 23:38   ` Glen Choo
  2023-03-22 23:53     ` Glen Choo
  0 siblings, 1 reply; 60+ messages in thread
From: Glen Choo @ 2023-03-22 23:38 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason, git
  Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Ævar Arnfjörð Bjarmason         <avarab@gmail.com> writes:

> diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
> deleted file mode 100644
> index 1190a3312bd..00000000000
> --- a/contrib/coccinelle/the_repository.pending.cocci
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -// This file is used for the ongoing refactoring of
> -// bringing the index or repository struct in all of
> -// our code base.

Now that we've deleted this file, I wanted to get a sense of where this
series lands us in the the_repository migration. ISTR that we'd consider
ourselves "done" when we stop referencing "the_repository" in
non-builtins, so presumably we aren't there yet ;)

Inspecting all of the ".h" files, we can see that the only remaining
function/macro of this sort is "the_hash_algo". Because you expanded the
search to cover cases not in "NO_THE_REPOSITORY_COMPATIBILITY_MACROS",
you've actually achieved more than what your CL says. Hooray!

We can't go so far as to say that we've removed all implicit references
to "the_repository", though, since we still have functions that
reference "the_repository" in their implementations. But, I don't think
this ".cocci" file would help us with those cases anyway, since this was
targeted specifically at functions/macros that were passing
"the_repository" to functions that accepted a "struct repository" arg.

Thanks for the cleanup, this is great!

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 15/17] cocci: apply the "revision.h" part of "the_repository.pending"
  2023-03-22 23:38   ` Glen Choo
@ 2023-03-22 23:53     ` Glen Choo
  2023-03-26  4:59       ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 60+ messages in thread
From: Glen Choo @ 2023-03-22 23:53 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason, git
  Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason

Glen Choo <chooglen@google.com> writes:

> Ævar Arnfjörð Bjarmason         <avarab@gmail.com> writes:
>
>> diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
>> deleted file mode 100644
>> index 1190a3312bd..00000000000
>> --- a/contrib/coccinelle/the_repository.pending.cocci
>> +++ /dev/null
>> @@ -1,14 +0,0 @@
>> -// This file is used for the ongoing refactoring of
>> -// bringing the index or repository struct in all of
>> -// our code base.
> We can't go so far as to say that we've removed all implicit references
> to "the_repository", though, since we still have functions that
> reference "the_repository" in their implementations. But, I don't think
> this ".cocci" file would help us with those cases anyway, since this was
> targeted specifically at functions/macros that were passing
> "the_repository" to functions that accepted a "struct repository" arg.

For these implicitly-the_repository functions, (e.g. git_path) we'd
presumably refactor them into repo_* versions and then apply the same
sorts of changes we did in this series? I guess we'd make those changes
in contrib/coccinelle/the_repository.cocci, so we don't need the
*.pending* one.

On that note, I'm curious what contrib/coccinelle/the_repository.cocci
is doing for us after this series. By definition, all of the macros have
been fully migrated, so they're all a noop. Would this slow down `make
coccicheck`?

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 15/17] cocci: apply the "revision.h" part of "the_repository.pending"
  2023-03-22 23:53     ` Glen Choo
@ 2023-03-26  4:59       ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-26  4:59 UTC (permalink / raw)
  To: Glen Choo; +Cc: git, Junio C Hamano


On Wed, Mar 22 2023, Glen Choo wrote:

> Glen Choo <chooglen@google.com> writes:
>
>> Ævar Arnfjörð Bjarmason         <avarab@gmail.com> writes:
>>
>>> diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
>>> deleted file mode 100644
>>> index 1190a3312bd..00000000000
>>> --- a/contrib/coccinelle/the_repository.pending.cocci
>>> +++ /dev/null
>>> @@ -1,14 +0,0 @@
>>> -// This file is used for the ongoing refactoring of
>>> -// bringing the index or repository struct in all of
>>> -// our code base.
>> We can't go so far as to say that we've removed all implicit references
>> to "the_repository", though, since we still have functions that
>> reference "the_repository" in their implementations. But, I don't think
>> this ".cocci" file would help us with those cases anyway, since this was
>> targeted specifically at functions/macros that were passing
>> "the_repository" to functions that accepted a "struct repository" arg.
>
> For these implicitly-the_repository functions, (e.g. git_path) we'd
> presumably refactor them into repo_* versions and then apply the same
> sorts of changes we did in this series? I guess we'd make those changes
> in contrib/coccinelle/the_repository.cocci, so we don't need the
> *.pending* one.

Whether we add it to a "pending" or not is just a question of whether
the migration is done right away, or left for later.

> On that note, I'm curious what contrib/coccinelle/the_repository.cocci
> is doing for us after this series. By definition, all of the macros have
> been fully migrated, so they're all a noop.

I left them for the benefit of any in-flight conflicts, or semantic
conflicts with out-of-tree.

I.e. in such a case you'd keep the other side, then apply the cocci
rule, and the result is a semantically correct merge of the two.

> Would this slow down `make coccicheck`?

A bit. It doesn't slow it down by much, as these rules are the simplest
to execute, spatch can skip the file if the relevant tokens aren't found
in it.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules
  2023-03-22 22:46   ` Glen Choo
@ 2023-03-26  5:02     ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-26  5:02 UTC (permalink / raw)
  To: Glen Choo; +Cc: git, Junio C Hamano


On Wed, Mar 22 2023, Glen Choo wrote:

> Every time I try to read cocci and spatch docs, I'm impressed at how
> impenetrable they are ;)

FWIW you should ignore the manpage, which and instead read the
"Coccinelle User’s manual", and particularly "The SmPL Grammar", both of
which are available as PDFs on their website.

But their docs are rather terse, and sometimes even incomplete. I've
often resorted to grepping their own test cases to figure out how
something works.

> Nevertheless, I'd still like to understand how
> the pattern works. I'll take a stab in the dark, and perhaps you can
> correct me.
>
> Ævar Arnfjörð Bjarmason         <avarab@gmail.com> writes:
>
>> +(
>> +- read_object_file
>> ++ repo_read_object_file
>> +|
>> +- has_object_file
>> ++ repo_has_object_file
>> +|
>> +- has_object_file_with_flags
>> ++ repo_has_object_file_with_flags
>> +|
>> +- parse_commit_internal
>> ++ repo_parse_commit_internal
>> +|
>> +- parse_commit
>> ++ repo_parse_commit
>> +|
>> +- get_merge_bases
>> ++ repo_get_merge_bases
>> +|
>> +- get_merge_bases_many
>> ++ repo_get_merge_bases_many
>> +|
>> +- get_merge_bases_many_dirty
>> ++ repo_get_merge_bases_many_dirty
>> +|
>> +- in_merge_bases
>> ++ repo_in_merge_bases
>> +|
>> +- in_merge_bases_many
>> ++ repo_in_merge_bases_many
>> +|
>> +- get_commit_buffer
>> ++ repo_get_commit_buffer
>> +|
>> +- unuse_commit_buffer
>> ++ repo_unuse_commit_buffer
>> +|
>> +- logmsg_reencode
>> ++ repo_logmsg_reencode
>> +|
>> +- format_commit_message
>> ++ repo_format_commit_message
>> +)
>
> I assume that `|` characters in parentheses are a logical OR, and each
> of the expressions checks for the `-` side in the original and replaces
> it with the `+` side.

Yes, just a simple "replace A with B".

>> +  (
>> ++ the_repository,
>> +  ...)
>
> Then this is another expression that matches literal `()` after the
> previous expression? `+the_repository` adds `the_repository` right after
> the opening `(`, then leaves the uninteresting `...` in place.
>
> If so, I don't know how cocci/spatch tells the difference between
> literal `()` vs an expression in the syntax (preceding whitespace?).

Yes, whitespace is significant in the coccinelle syntax, generally its
own "()" grouping goes at the beginning of a line, wheras you indent
program text in the "diff" with whitespace.

E.g. our equals-null.cocci has two rules that use "(" and ")" in a way
that would be ambiguous if this whitespace-disambiguation weren't being
used.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 17/17] libs: use "struct repository *" argument, not "the_repository"
  2023-03-19  6:19   ` Elijah Newren
@ 2023-03-28 10:53     ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 10:53 UTC (permalink / raw)
  To: Elijah Newren; +Cc: git, Junio C Hamano


On Sat, Mar 18 2023, Elijah Newren wrote:

> On Fri, Mar 17, 2023 at 8:55 AM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>>
>> As can easily be seen from grepping in our sources, we had these uses
>> of "the_repository" in various library code in cases where the
>> function in question was already getting a "struct repository *"
>> argument. Let's use that argument instead.
>>
>> Out of these changes only the changes to "cache-tree.c",
>> "commit-reach.c", "shallow.c" and "upload-pack.c" would have cleanly
>> applied before the migration away from the "repo_*()" wrapper macros
>> in the preceding commits.
>>
>> The rest aren't new, as we'd previously implicitly refer to
>> "the_repository", but it's now more obvious that we were doing the
>> wrong thing all along, and should have used the parameter instead.
>
> YES!  I love seeing fixes like this.  I noticed some a while back in
> the merge code, and had some patches somewhere that I think I never
> got around to submitting, but which have been in the back of my mind
> bugging me.  Nice to see lots of these kinds of cases getting fixed.

Yeah, it will be nice to fix those...

>> The change to change "get_index_format_default(the_repository)" in
>> "read-cache.c" to use the "r" variable instead should arguably have
>> been part of [1], or in the subsequent cleanup in [2]. Let's do it
>> here, as can be seen from the initial code in [3] it's not important
>> that we use "the_repository" there, but would prefer to always use the
>> current repository.
>>
>> This change excludes the "the_repository" use in "upload-pack.c"'s
>> upload_pack_advertise(), as the in-flight [4] makes that change.
>>
>> 1. ee1f0c242ef (read-cache: add index.skipHash config option,
>>    2023-01-06)
>> 2. 6269f8eaad0 (treewide: always have a valid "index_state.repo"
>>    member, 2023-01-17)
>> 3. 7211b9e7534 (repo-settings: consolidate some config settings,
>>    2019-08-13)
>> 4. <Y/hbUsGPVNAxTdmS@coredump.intra.peff.net>
>>
>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>> ---
>>  add-interactive.c |   2 +-
>>  branch.c          |   8 ++--
>>  builtin/replace.c |   2 +-
>>  cache-tree.c      |   4 +-
>>  combine-diff.c    |   2 +-
>>  commit-graph.c    |   2 +-
>>  commit-reach.c    |   2 +-
>>  merge-recursive.c |   2 +-
>
> Doh, doesn't fix up the ones I had.  I don't remember the exact issue
> and can't find the patches right now, but looking around a little I
> see a write_object_file() which should be a repo_write_object_file(),
> but it's in a function that doesn't take a repository argument.
> However, the caller has access to a repository argument, in the form
> of opt->repo, so we've got some low-hanging fruit that could be fixed
> up.  Doesn't need to be part of your series, but it's nice that your
> series has done some of the groundwork to make these issues more
> obvious.

...yeah, I do have a WIP follow-up based on this topic which addresses
the sort of issues you're rasing here, i.e. in many cases we have
"the_repository", no "struct repository *" function argument, but we
have a "x->repo", where "x" is the "struct" state object we have in play
in that API.

My messy WIP follow-up for starting to fix those is at :
https://github.com/avar/git/compare/6f86a34bf8b...2072d685a56

I didn't get to the merge/object code you mentioned, but we should do
these sorts of changes as a follow-up.

I didn't do them as part of this topic, because this series was already
quite long, and this 17/17 is arguably scope-creep, but I could argue
for it on the basis of it being almost entirely a post-cleanup for the
preceding changes.

> [...]
> I started looking through it closely, but after a bit I realized that
> the only kind of error you would likely to be make here would be the
> kind caught by the compiler, so then I started just skimming over it.
> But I think that's safe for this kind of change.  I'm a big fan of
> these kinds of cleanups and fixups, though.
>
> I'm not sure I can give a Reviewed-by since I just don't know cocci,
> but it all looked pretty logical.  You definitely have my Acked-by on
> the series, though.

I won't add your Reviewed-by to a re-roll given that caveat, but FWIW I
think in general those not familiar with cocci should be comfortable
reviewing topics that modify code using the tool.

Even if you don't grok the patch lanugage, you can review the resulting
diff, as you've done here.

I think the exception to that is if the change itself is proposing to
institute a new cocci rule, that we can expect to apply going
forward. In those cases really understanding the rule matters, e.g. the
contrib/coccinelle/unused.cocci rule I added relatively recently is one
such example.

But here the rules are just a one-off, and are just an aid to reproduce
the changes.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros
  2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
                   ` (17 preceding siblings ...)
  2023-03-17 19:22 ` [PATCH 00/17] cocci: remove "the_index" wrapper macros Junio C Hamano
@ 2023-03-28 13:58 ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
                     ` (18 more replies)
  18 siblings, 19 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

A v2 of the removal of "the_repository" wrapper macros and adjacent
cleanups. The v1 subject for this said "the_index", sorry!

See v1 [1] for a more general overview. The changes since v1 are
trivial & best skimmed from the range-diff, just a rebasing,
clarification in a commit message, and a typo fix, thanks all!

As before this has a trivial conflict with "seen", but this time
around the conflict is different, but it's trivially solved as before,
the remerge-diff was:
	
	diff --git a/cache.h b/cache.h
	remerge CONFLICT (content): Merge conflict in cache.h
	index 25e002c488b..82d7b112b4e 100644
	--- a/cache.h
	+++ b/cache.h
	@@ -711,31 +711,6 @@ extern int quote_path_fully;
	  */
	 const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
	 int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
	-<<<<<<< 9f4013b4b9d (libs: use "struct repository *" argument, not "the_repository")
	-
	-/* set default permissions by passing mode arguments to open(2) */
	-int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
	-int git_mkstemp_mode(char *pattern, int mode);
	-
	-/*
	- * NOTE NOTE NOTE!!
	- *
	- * PERM_UMASK, OLD_PERM_GROUP and OLD_PERM_EVERYBODY enumerations must
	- * not be changed. Old repositories have core.sharedrepository written in
	- * numeric format, and therefore these values are preserved for compatibility
	- * reasons.
	- */
	-enum sharedrepo {
	-	PERM_UMASK          = 0,
	-	OLD_PERM_GROUP      = 1,
	-	OLD_PERM_EVERYBODY  = 2,
	-	PERM_GROUP          = 0660,
	-	PERM_EVERYBODY      = 0664
	-};
	-int git_config_perm(const char *var, const char *value);
	-int adjust_shared_perm(const char *path);
	-=======
	->>>>>>> 2bb680d6bbd (Merge branch 'kh/commentchar-config-error-message' into seen)
	 
	 /*
	  * Create the directory containing the named path, using care to be
	@@ -925,11 +900,6 @@ int repo_interpret_branch_name(struct repository *r,
	 			       const char *str, int len,
	 			       struct strbuf *buf,
	 			       const struct interpret_branch_name_options *options);
	-<<<<<<< 9f4013b4b9d (libs: use "struct repository *" argument, not "the_repository")
	-
	-int validate_headref(const char *ref);
	-=======
	->>>>>>> 2bb680d6bbd (Merge branch 'kh/commentchar-config-error-message' into seen)
	 
	 int base_name_compare(const char *name1, size_t len1, int mode1,
	 		      const char *name2, size_t len2, int mode2);
Branch & CI for this at:
https://github.com/avar/git/tree/avar/cocci-the-repository-from-pending-2

1. https://lore.kernel.org/git/cover-00.17-00000000000-20230317T152724Z-avarab@gmail.com/

Ævar Arnfjörð Bjarmason (17):
  cocci: remove dead rule from "the_repository.pending.cocci"
  cocci: fix incorrect & verbose "the_repository" rules
  cocci: sort "the_repository" rules by header
  cocci: add missing "the_repository" macros to "pending"
  cocci: apply the "cache.h" part of "the_repository.pending"
  cocci: apply the "commit-reach.h" part of "the_repository.pending"
  cocci: apply the "commit.h" part of "the_repository.pending"
  cocci: apply the "diff.h" part of "the_repository.pending"
  cocci: apply the "object-store.h" part of "the_repository.pending"
  cocci: apply the "pretty.h" part of "the_repository.pending"
  cocci: apply the "packfile.h" part of "the_repository.pending"
  cocci: apply the "promisor-remote.h" part of "the_repository.pending"
  cocci: apply the "refs.h" part of "the_repository.pending"
  cocci: apply the "rerere.h" part of "the_repository.pending"
  cocci: apply the "revision.h" part of "the_repository.pending"
  post-cocci: adjust comments for recent repo_* migration
  libs: use "struct repository *" argument, not "the_repository"

 add-interactive.c                             |   2 +-
 add-patch.c                                   |   2 +-
 apply.c                                       |  13 +-
 archive.c                                     |  12 +-
 bisect.c                                      |  11 +-
 blame.c                                       |  15 +-
 branch.c                                      |   7 +-
 builtin/am.c                                  |  23 +--
 builtin/bisect.c                              |  33 ++--
 builtin/blame.c                               |  15 +-
 builtin/branch.c                              |   9 +-
 builtin/cat-file.c                            |  25 +--
 builtin/checkout.c                            |  35 ++--
 builtin/clone.c                               |   6 +-
 builtin/commit-tree.c                         |   4 +-
 builtin/commit.c                              |  29 ++--
 builtin/describe.c                            |   9 +-
 builtin/diff.c                                |   3 +-
 builtin/difftool.c                            |   3 +-
 builtin/fast-export.c                         |  12 +-
 builtin/fast-import.c                         |  17 +-
 builtin/fetch.c                               |  21 +--
 builtin/fsck.c                                |   2 +-
 builtin/gc.c                                  |   8 +-
 builtin/grep.c                                |   6 +-
 builtin/index-pack.c                          |  11 +-
 builtin/log.c                                 |  30 ++--
 builtin/ls-files.c                            |   4 +-
 builtin/ls-tree.c                             |   9 +-
 builtin/merge-base.c                          |   9 +-
 builtin/merge-recursive.c                     |   6 +-
 builtin/merge-tree.c                          |  18 ++-
 builtin/merge.c                               |  23 +--
 builtin/mktag.c                               |   3 +-
 builtin/name-rev.c                            |  11 +-
 builtin/notes.c                               |  34 ++--
 builtin/pack-objects.c                        |  24 ++-
 builtin/prune.c                               |   2 +-
 builtin/pull.c                                |   4 +-
 builtin/range-diff.c                          |  12 +-
 builtin/read-tree.c                           |   2 +-
 builtin/rebase.c                              |  21 +--
 builtin/receive-pack.c                        |  14 +-
 builtin/remote.c                              |   2 +-
 builtin/repack.c                              |   2 +-
 builtin/replace.c                             |  20 +--
 builtin/reset.c                               |  22 +--
 builtin/rev-list.c                            |   2 +-
 builtin/rev-parse.c                           |  18 ++-
 builtin/rm.c                                  |   2 +-
 builtin/shortlog.c                            |  13 +-
 builtin/show-branch.c                         |  19 +--
 builtin/show-ref.c                            |   6 +-
 builtin/sparse-checkout.c                     |   2 +-
 builtin/stash.c                               |  26 +--
 builtin/submodule--helper.c                   |   6 +-
 builtin/tag.c                                 |  10 +-
 builtin/unpack-file.c                         |   4 +-
 builtin/unpack-objects.c                      |   5 +-
 builtin/update-ref.c                          |   8 +-
 builtin/verify-commit.c                       |   2 +-
 builtin/verify-tag.c                          |   2 +-
 builtin/worktree.c                            |   8 +-
 bulk-checkin.c                                |   2 +-
 bundle.c                                      |   5 +-
 cache-tree.c                                  |  16 +-
 cache.h                                       |  19 +--
 checkout.c                                    |   2 +-
 combine-diff.c                                |   8 +-
 commit-graph.c                                |   4 +-
 commit-reach.c                                |  21 +--
 commit-reach.h                                |   9 --
 commit.c                                      |  44 ++---
 commit.h                                      |  22 +--
 connected.c                                   |   4 +-
 contrib/coccinelle/the_repository.cocci       | 123 ++++++++++++++
 .../coccinelle/the_repository.pending.cocci   | 128 ---------------
 delta-islands.c                               |   5 +-
 diff-lib.c                                    |   2 +-
 diff.c                                        |   6 +-
 diff.h                                        |   5 +-
 diffcore-break.c                              |   2 +-
 diffcore-rename.c                             |   4 +-
 dir.c                                         |   2 +-
 entry.c                                       |   3 +-
 fetch-pack.c                                  |   8 +-
 fmt-merge-msg.c                               |  15 +-
 fsck.c                                        |   6 +-
 http-push.c                                   |  16 +-
 http-walker.c                                 |   4 +-
 list-objects-filter-options.c                 |   7 +-
 list-objects.c                                |  20 ++-
 log-tree.c                                    |  28 ++--
 mailmap.c                                     |   4 +-
 match-trees.c                                 |   4 +-
 merge-blobs.c                                 |   6 +-
 merge-ort.c                                   |   6 +-
 merge-recursive.c                             |   9 +-
 negotiator/default.c                          |   6 +-
 negotiator/skipping.c                         |   2 +-
 notes-cache.c                                 |   5 +-
 notes-merge.c                                 |  11 +-
 notes-utils.c                                 |   2 +-
 notes.c                                       |  18 ++-
 object-file.c                                 |   4 +-
 object-name.c                                 |  19 ++-
 object-store.h                                |  11 +-
 pack-bitmap-write.c                           |   3 +-
 packfile.c                                    |   2 +-
 packfile.h                                    |   1 -
 parse-options-cb.c                            |   8 +-
 pretty.c                                      |  10 +-
 pretty.h                                      |   4 -
 promisor-remote.h                             |  15 --
 range-diff.c                                  |  12 +-
 read-cache.c                                  |   9 +-
 rebase-interactive.c                          |   2 +-
 ref-filter.c                                  |   8 +-
 reflog.c                                      |   7 +-
 refs.c                                        |   2 +-
 refs.h                                        |   6 -
 remote.c                                      |  15 +-
 rerere.c                                      |   5 +-
 rerere.h                                      |   3 -
 reset.c                                       |   4 +-
 revision.c                                    |  27 ++--
 revision.h                                    |   3 -
 send-pack.c                                   |   6 +-
 sequencer.c                                   | 150 ++++++++++--------
 shallow.c                                     |  21 +--
 strbuf.h                                      |   6 +-
 submodule-config.c                            |   5 +-
 submodule.c                                   |   8 +-
 t/helper/test-fast-rebase.c                   |  19 ++-
 t/helper/test-match-trees.c                   |   4 +-
 t/helper/test-oidmap.c                        |   6 +-
 t/helper/test-reach.c                         |  12 +-
 t/helper/test-revision-walking.c              |   3 +-
 t/helper/test-submodule-config.c              |   2 +-
 tag.c                                         |   9 +-
 transport-helper.c                            |   2 +-
 transport.c                                   |   3 +-
 tree.c                                        |   5 +-
 unpack-trees.c                                |   2 +-
 upload-pack.c                                 |   8 +-
 walker.c                                      |   6 +-
 wt-status.c                                   |  21 +--
 xdiff-interface.c                             |   2 +-
 148 files changed, 958 insertions(+), 873 deletions(-)
 create mode 100644 contrib/coccinelle/the_repository.cocci
 delete mode 100644 contrib/coccinelle/the_repository.pending.cocci

Range-diff against v1:
 1:  c167bde3c0c !  1:  e1e27490d60 cocci: remove dead rule from "the_repository.pending.cocci"
    @@ Commit message
         cocci: remove dead rule from "the_repository.pending.cocci"
     
         The "parse_commit_gently" macro went away in [1], so we don't need to
    -    carry his for its migration.
    +    carry this for its migration.
     
         1. ea3f7e598c8 (revision: use repository from rev_info when parsing
            commits, 2020-06-23)
 2:  1b1fc5d41f5 =  2:  5ac9d5b8905 cocci: fix incorrect & verbose "the_repository" rules
 3:  34c6b8afd6c !  3:  a3fcd19d744 cocci: sort "the_repository" rules by header
    @@ Commit message
         rules. This will make subsequent commits easier to follow, as we'll be
         applying these rules on a header-by-header basis.
     
    +    Once we've fully applied "the_repository.pending.cocci" we'll keep
    +    this rules around for a while in "the_repository.cocci", to help any
    +    outstanding topics and out-of-tree code to resolve textual or semantic
    +    conflicts with these changes, but eventually we'll remove the
    +    "the_repository.cocci" as a follow-up.
    +
    +    So even if some of these functions are subsequently moved and/or split
    +    into other or new headers there's no risk of this becoming stale, if
    +    and when that happens the we should be removing these rules anyway.
    +
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
      ## contrib/coccinelle/the_repository.pending.cocci ##
 4:  4b62e9a35a9 =  4:  af8bdc2adec cocci: add missing "the_repository" macros to "pending"
 5:  36eae891341 !  5:  3e721fa5db0 cocci: apply the "cache.h" part of "the_repository.pending"
    @@ cache.h: void *read_object_with_reference(struct repository *r,
     -#define peel_to_type(name, namelen, obj, type) \
     -	repo_peel_to_type(the_repository, name, namelen, obj, type)
      
    - #define IDENT_STRICT	       1
    - #define IDENT_NO_DATE	       2
    + const char *git_editor(void);
    + const char *git_sequence_editor(void);
     
      ## checkout.c ##
     @@ checkout.c: static int check_tracking_name(struct remote *remote, void *cb_data)
 6:  b06ea9861fd =  6:  0f24a57b50b cocci: apply the "commit-reach.h" part of "the_repository.pending"
 7:  2e9cf3ca378 !  7:  7d64ace3551 cocci: apply the "commit.h" part of "the_repository.pending"
    @@ commit.h: void repo_unuse_commit_buffer(struct repository *r,
      
      /*
     @@ commit.h: void free_commit_list(struct commit_list *list);
    + 
      struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
      
    - int has_non_ascii(const char *text);
     -const char *logmsg_reencode(const struct commit *commit,
     -			    char **commit_encoding,
     -			    const char *output_encoding);
 8:  6c5f4861471 =  8:  f442e7b9acc cocci: apply the "diff.h" part of "the_repository.pending"
 9:  893684f135b =  9:  1866d473f1b cocci: apply the "object-store.h" part of "the_repository.pending"
10:  c4bf81a2892 = 10:  10e05c56231 cocci: apply the "pretty.h" part of "the_repository.pending"
11:  8cfc1c18878 = 11:  13955394126 cocci: apply the "packfile.h" part of "the_repository.pending"
12:  abd237009f9 = 12:  8336b0321a8 cocci: apply the "promisor-remote.h" part of "the_repository.pending"
13:  aae743233ab = 13:  a08d7f8eccf cocci: apply the "refs.h" part of "the_repository.pending"
14:  fb281b1ecdd = 14:  3d59dfe4186 cocci: apply the "rerere.h" part of "the_repository.pending"
15:  c8ff241844a = 15:  b7561c87ba5 cocci: apply the "revision.h" part of "the_repository.pending"
16:  86e24add191 = 16:  f947bb69dee post-cocci: adjust comments for recent repo_* migration
17:  6f86a34bf8b = 17:  9f4013b4b9d libs: use "struct repository *" argument, not "the_repository"
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH v2 01/17] cocci: remove dead rule from "the_repository.pending.cocci"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
                     ` (17 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

The "parse_commit_gently" macro went away in [1], so we don't need to
carry this for its migration.

1. ea3f7e598c8 (revision: use repository from rev_info when parsing
   commits, 2020-06-23)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 contrib/coccinelle/the_repository.pending.cocci | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 747d382ff5f..23b97536da5 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -34,14 +34,6 @@ expression G;
 + repo_parse_commit_internal(the_repository,
   E, F, G)
 
-@@
-expression E;
-expression F;
-@@
-- parse_commit_gently(
-+ repo_parse_commit_gently(the_repository,
-  E, F)
-
 @@
 expression E;
 @@
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 02/17] cocci: fix incorrect & verbose "the_repository" rules
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-29 20:35     ` Taylor Blau
  2023-03-28 13:58   ` [PATCH v2 03/17] cocci: sort "the_repository" rules by header Ævar Arnfjörð Bjarmason
                     ` (16 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

When these rules started being added in [1] they didn't use a ";"
after the ")", and would thus catch uses of these macros within
expressions. But as of [2] the new additions were broken in that
they'd only match a subset of the users of these macros.

Rather than narrowly fixing that, let's have these use the much less
verbose pattern introduced in my recent [3]: There's no need to
exhaustively enumerate arguments if we use the "..." syntax. This
means that we can fold all of these different rules into one.

1. afd69dcc219 (object-store: prepare read_object_file to deal with
   any repo, 2018-11-13)
2. 21a9651ba3f (commit-reach: prepare get_merge_bases to handle any
   repo, 2018-11-13)
3. 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci,
   2022-11-19)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 .../coccinelle/the_repository.pending.cocci   | 160 +++++-------------
 1 file changed, 46 insertions(+), 114 deletions(-)

diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 23b97536da5..99e192736ee 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -3,118 +3,50 @@
 // our code base.
 
 @@
-expression E;
-expression F;
-expression G;
 @@
-- read_object_file(
-+ repo_read_object_file(the_repository,
-  E, F, G)
-
-@@
-expression E;
-@@
-- has_object_file(
-+ repo_has_object_file(the_repository,
-  E)
-
-@@
-expression E;
-@@
-- has_object_file_with_flags(
-+ repo_has_object_file_with_flags(the_repository,
-  E)
-
-@@
-expression E;
-expression F;
-expression G;
-@@
-- parse_commit_internal(
-+ repo_parse_commit_internal(the_repository,
-  E, F, G)
-
-@@
-expression E;
-@@
-- parse_commit(
-+ repo_parse_commit(the_repository,
-  E)
-
-@@
-expression E;
-expression F;
-@@
-- get_merge_bases(
-+ repo_get_merge_bases(the_repository,
-  E, F);
-
-@@
-expression E;
-expression F;
-expression G;
-@@
-- get_merge_bases_many(
-+ repo_get_merge_bases_many(the_repository,
-  E, F, G);
-
-@@
-expression E;
-expression F;
-expression G;
-@@
-- get_merge_bases_many_dirty(
-+ repo_get_merge_bases_many_dirty(the_repository,
-  E, F, G);
-
-@@
-expression E;
-expression F;
-@@
-- in_merge_bases(
-+ repo_in_merge_bases(the_repository,
-  E, F);
-
-@@
-expression E;
-expression F;
-expression G;
-@@
-- in_merge_bases_many(
-+ repo_in_merge_bases_many(the_repository,
-  E, F, G);
-
-@@
-expression E;
-expression F;
-@@
-- get_commit_buffer(
-+ repo_get_commit_buffer(the_repository,
-  E, F);
-
-@@
-expression E;
-expression F;
-@@
-- unuse_commit_buffer(
-+ repo_unuse_commit_buffer(the_repository,
-  E, F);
-
-@@
-expression E;
-expression F;
-expression G;
-@@
-- logmsg_reencode(
-+ repo_logmsg_reencode(the_repository,
-  E, F, G);
-
-@@
-expression E;
-expression F;
-expression G;
-expression H;
-@@
-- format_commit_message(
-+ repo_format_commit_message(the_repository,
-  E, F, G, H);
+(
+- read_object_file
++ repo_read_object_file
+|
+- has_object_file
++ repo_has_object_file
+|
+- has_object_file_with_flags
++ repo_has_object_file_with_flags
+|
+- parse_commit_internal
++ repo_parse_commit_internal
+|
+- parse_commit
++ repo_parse_commit
+|
+- get_merge_bases
++ repo_get_merge_bases
+|
+- get_merge_bases_many
++ repo_get_merge_bases_many
+|
+- get_merge_bases_many_dirty
++ repo_get_merge_bases_many_dirty
+|
+- in_merge_bases
++ repo_in_merge_bases
+|
+- in_merge_bases_many
++ repo_in_merge_bases_many
+|
+- get_commit_buffer
++ repo_get_commit_buffer
+|
+- unuse_commit_buffer
++ repo_unuse_commit_buffer
+|
+- logmsg_reencode
++ repo_logmsg_reencode
+|
+- format_commit_message
++ repo_format_commit_message
+)
+  (
++ the_repository,
+  ...)
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 03/17] cocci: sort "the_repository" rules by header
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 04/17] cocci: add missing "the_repository" macros to "pending" Ævar Arnfjörð Bjarmason
                     ` (15 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Sort the "the_repository.pending.cocci" file by which header the
macros are in, and add a comment to that effect in front of the
rules. This will make subsequent commits easier to follow, as we'll be
applying these rules on a header-by-header basis.

Once we've fully applied "the_repository.pending.cocci" we'll keep
this rules around for a while in "the_repository.cocci", to help any
outstanding topics and out-of-tree code to resolve textual or semantic
conflicts with these changes, but eventually we'll remove the
"the_repository.cocci" as a follow-up.

So even if some of these functions are subsequently moved and/or split
into other or new headers there's no risk of this becoming stale, if
and when that happens the we should be removing these rules anyway.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 .../coccinelle/the_repository.pending.cocci   | 34 +++++++++++--------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 99e192736ee..84b79dce480 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,21 +5,7 @@
 @@
 @@
 (
-- read_object_file
-+ repo_read_object_file
-|
-- has_object_file
-+ repo_has_object_file
-|
-- has_object_file_with_flags
-+ repo_has_object_file_with_flags
-|
-- parse_commit_internal
-+ repo_parse_commit_internal
-|
-- parse_commit
-+ repo_parse_commit
-|
+// commit-reach.h
 - get_merge_bases
 + repo_get_merge_bases
 |
@@ -34,6 +20,13 @@
 |
 - in_merge_bases_many
 + repo_in_merge_bases_many
+// commit.h
+|
+- parse_commit_internal
++ repo_parse_commit_internal
+|
+- parse_commit
++ repo_parse_commit
 |
 - get_commit_buffer
 + repo_get_commit_buffer
@@ -43,6 +36,17 @@
 |
 - logmsg_reencode
 + repo_logmsg_reencode
+// object-store.h
+|
+- read_object_file
++ repo_read_object_file
+|
+- has_object_file
++ repo_has_object_file
+|
+- has_object_file_with_flags
++ repo_has_object_file_with_flags
+// pretty.h
 |
 - format_commit_message
 + repo_format_commit_message
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 04/17] cocci: add missing "the_repository" macros to "pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (2 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 03/17] cocci: sort "the_repository" rules by header Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 05/17] cocci: apply the "cache.h" part of "the_repository.pending" Ævar Arnfjörð Bjarmason
                     ` (14 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

In the case of diff.h, rerere.h and revision.h the macros were added
in [1], [2] and [3] when "the_repository.pending.cocci" didn't
exist. None of the subsequently added migration rules covered
them. Let's add those missing rules.

In the case of macros in "cache.h", "commit.h", "packfile.h",
"promisor-remote.h" and "refs.h" those aren't guarded by
"NO_THE_REPOSITORY_COMPATIBILITY_MACROS", but they're also macros that
add "the_repository" as the first argument, so we should migrate away
from them.

1. 2abf3503854 (revision.c: remove implicit dependency on the_index,
   2018-09-21)
2. e6757652350 (diff.c: remove implicit dependency on the_index,
   2018-09-21)
3. 35843b1123e (rerere.c: remove implicit dependency on the_index,
   2018-09-21)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 .../coccinelle/the_repository.pending.cocci   | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 84b79dce480..8b3f2580e6b 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,7 +5,44 @@
 @@
 @@
 (
+// cache.h
+- get_oid
++ repo_get_oid
+|
+- get_oid_commit
++ repo_get_oid_commit
+|
+- get_oid_committish
++ repo_get_oid_committish
+|
+- get_oid_tree
++ repo_get_oid_tree
+|
+- get_oid_treeish
++ repo_get_oid_treeish
+|
+- get_oid_blob
++ repo_get_oid_blob
+|
+- get_oid_mb
++ repo_get_oid_mb
+|
+- find_unique_abbrev
++ repo_find_unique_abbrev
+|
+- find_unique_abbrev_r
++ repo_find_unique_abbrev_r
+|
+- for_each_abbrev
++ repo_for_each_abbrev
+|
+- interpret_branch_name
++ repo_interpret_branch_name
+|
+- peel_to_type
++ repo_peel_to_type
 // commit-reach.h
+|
 - get_merge_bases
 + repo_get_merge_bases
 |
@@ -36,6 +73,13 @@
 |
 - logmsg_reencode
 + repo_logmsg_reencode
+|
+- get_commit_tree
++ repo_get_commit_tree
+// diff.h
+|
+- diff_setup
++ repo_diff_setup
 // object-store.h
 |
 - read_object_file
@@ -50,6 +94,32 @@
 |
 - format_commit_message
 + repo_format_commit_message
+// packfile.h
+|
+- approximate_object_count
++ repo_approximate_object_count
+// promisor-remote.h
+|
+- promisor_remote_reinit
++ repo_promisor_remote_reinit
+|
+- promisor_remote_find
++ repo_promisor_remote_find
+|
+- has_promisor_remote
++ repo_has_promisor_remote
+// refs.h
+|
+- dwim_ref
++ repo_dwim_ref
+// rerere.h
+|
+- rerere
++ repo_rerere
+// revision.h
+|
+- init_revisions
++ repo_init_revisions
 )
   (
 + the_repository,
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 05/17] cocci: apply the "cache.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (3 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 04/17] cocci: add missing "the_repository" macros to "pending" Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 06/17] cocci: apply the "commit-reach.h" " Ævar Arnfjörð Bjarmason
                     ` (13 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"cache.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 add-patch.c                                   |  2 +-
 apply.c                                       |  4 +-
 archive.c                                     |  2 +-
 branch.c                                      |  2 +-
 builtin/am.c                                  | 16 +++---
 builtin/bisect.c                              | 19 +++----
 builtin/blame.c                               |  9 ++--
 builtin/branch.c                              |  2 +-
 builtin/checkout.c                            | 16 +++---
 builtin/commit-tree.c                         |  4 +-
 builtin/commit.c                              |  8 +--
 builtin/describe.c                            |  5 +-
 builtin/fast-import.c                         |  8 +--
 builtin/fetch.c                               |  2 +-
 builtin/fsck.c                                |  2 +-
 builtin/log.c                                 |  8 +--
 builtin/ls-files.c                            |  4 +-
 builtin/ls-tree.c                             |  9 ++--
 builtin/merge-base.c                          |  4 +-
 builtin/merge-recursive.c                     |  6 +--
 builtin/merge.c                               | 10 ++--
 builtin/name-rev.c                            |  7 +--
 builtin/notes.c                               | 22 ++++----
 builtin/prune.c                               |  2 +-
 builtin/pull.c                                |  4 +-
 builtin/range-diff.c                          | 12 ++---
 builtin/read-tree.c                           |  2 +-
 builtin/rebase.c                              | 12 +++--
 builtin/receive-pack.c                        | 10 ++--
 builtin/replace.c                             | 16 +++---
 builtin/reset.c                               | 19 +++----
 builtin/rev-list.c                            |  2 +-
 builtin/rev-parse.c                           | 12 +++--
 builtin/rm.c                                  |  2 +-
 builtin/show-branch.c                         | 12 ++---
 builtin/show-ref.c                            |  4 +-
 builtin/sparse-checkout.c                     |  2 +-
 builtin/stash.c                               | 13 ++---
 builtin/submodule--helper.c                   |  4 +-
 builtin/tag.c                                 |  6 +--
 builtin/unpack-file.c                         |  2 +-
 builtin/update-ref.c                          |  8 +--
 builtin/verify-commit.c                       |  2 +-
 builtin/verify-tag.c                          |  2 +-
 builtin/worktree.c                            |  8 +--
 cache.h                                       | 15 ------
 checkout.c                                    |  2 +-
 combine-diff.c                                |  6 +--
 commit.c                                      | 10 ++--
 contrib/coccinelle/the_repository.cocci       | 44 ++++++++++++++++
 .../coccinelle/the_repository.pending.cocci   | 37 --------------
 diff-lib.c                                    |  2 +-
 diff.c                                        |  4 +-
 fmt-merge-msg.c                               |  4 +-
 log-tree.c                                    | 15 +++---
 mailmap.c                                     |  2 +-
 notes-merge.c                                 |  2 +-
 notes.c                                       |  6 +--
 object-name.c                                 |  5 +-
 parse-options-cb.c                            |  8 +--
 range-diff.c                                  |  8 +--
 read-cache.c                                  |  2 +-
 rebase-interactive.c                          |  2 +-
 ref-filter.c                                  |  8 +--
 remote.c                                      |  6 +--
 reset.c                                       |  4 +-
 revision.c                                    | 11 ++--
 sequencer.c                                   | 51 ++++++++++---------
 submodule-config.c                            |  2 +-
 submodule.c                                   |  8 +--
 t/helper/test-fast-rebase.c                   | 10 ++--
 t/helper/test-match-trees.c                   |  4 +-
 t/helper/test-oidmap.c                        |  6 +--
 t/helper/test-reach.c                         |  2 +-
 t/helper/test-submodule-config.c              |  2 +-
 tag.c                                         |  4 +-
 transport-helper.c                            |  2 +-
 transport.c                                   |  3 +-
 wt-status.c                                   | 18 +++----
 79 files changed, 332 insertions(+), 310 deletions(-)
 create mode 100644 contrib/coccinelle/the_repository.cocci

diff --git a/add-patch.c b/add-patch.c
index e6c34b9c381..6a32b49b29c 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -415,7 +415,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 		strvec_push(&args,
 			    /* could be on an unborn branch */
 			    !strcmp("HEAD", s->revision) &&
-			    get_oid("HEAD", &oid) ?
+			    repo_get_oid(the_repository, "HEAD", &oid) ?
 			    empty_tree_oid_hex() : s->revision);
 	}
 	color_arg_index = args.nr;
diff --git a/apply.c b/apply.c
index 8776ab939ad..ed6abc7722f 100644
--- a/apply.c
+++ b/apply.c
@@ -3612,7 +3612,7 @@ static int try_threeway(struct apply_state *state,
 	/* Preimage the patch was prepared for */
 	if (patch->is_new)
 		write_object_file("", 0, OBJ_BLOB, &pre_oid);
-	else if (get_oid(patch->old_oid_prefix, &pre_oid) ||
+	else if (repo_get_oid(the_repository, patch->old_oid_prefix, &pre_oid) ||
 		 read_blob_object(&buf, &pre_oid, patch->old_mode))
 		return error(_("repository lacks the necessary blob to perform 3-way merge."));
 
@@ -4129,7 +4129,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
 			else
 				return error(_("sha1 information is lacking or "
 					       "useless for submodule %s"), name);
-		} else if (!get_oid_blob(patch->old_oid_prefix, &oid)) {
+		} else if (!repo_get_oid_blob(the_repository, patch->old_oid_prefix, &oid)) {
 			; /* ok */
 		} else if (!patch->lines_added && !patch->lines_deleted) {
 			/* mode-only change: update the current */
diff --git a/archive.c b/archive.c
index 1c2ca78e52a..cb7ca69cce1 100644
--- a/archive.c
+++ b/archive.c
@@ -463,7 +463,7 @@ static void parse_treeish_arg(const char **argv,
 		dwim_ref(name, strlen(name), &oid, &ref, 0);
 	}
 
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		die(_("not a valid object name: %s"), name);
 
 	commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);
diff --git a/branch.c b/branch.c
index eacef62b7c9..efea29af1ac 100644
--- a/branch.c
+++ b/branch.c
@@ -532,7 +532,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
 		explicit_tracking = 1;
 
 	real_ref = NULL;
-	if (get_oid_mb(start_name, &oid)) {
+	if (repo_get_oid_mb(the_repository, start_name, &oid)) {
 		if (explicit_tracking) {
 			int code = die_message(_(upstream_missing), start_name);
 			advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
diff --git a/builtin/am.c b/builtin/am.c
index 5e6b237c424..775beac2a92 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1067,7 +1067,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
 	else
 		write_state_text(state, "applying", "");
 
-	if (!get_oid("HEAD", &curr_head)) {
+	if (!repo_get_oid(the_repository, "HEAD", &curr_head)) {
 		write_state_text(state, "abort-safety", oid_to_hex(&curr_head));
 		if (!state->rebasing)
 			update_ref("am", "ORIG_HEAD", &curr_head, NULL, 0,
@@ -1110,7 +1110,7 @@ static void am_next(struct am_state *state)
 	unlink(am_path(state, "original-commit"));
 	delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
 
-	if (!get_oid("HEAD", &head))
+	if (!repo_get_oid(the_repository, "HEAD", &head))
 		write_state_text(state, "abort-safety", oid_to_hex(&head));
 	else
 		write_state_text(state, "abort-safety", "");
@@ -1403,7 +1403,7 @@ static void write_index_patch(const struct am_state *state)
 	struct rev_info rev_info;
 	FILE *fp;
 
-	if (!get_oid("HEAD", &head)) {
+	if (!repo_get_oid(the_repository, "HEAD", &head)) {
 		struct commit *commit = lookup_commit_or_die(&head, "HEAD");
 		tree = get_commit_tree(commit);
 	} else
@@ -1557,7 +1557,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
 	struct commit *result;
 	char *their_tree_name;
 
-	if (get_oid("HEAD", &our_tree) < 0)
+	if (repo_get_oid(the_repository, "HEAD", &our_tree) < 0)
 		oidcpy(&our_tree, the_hash_algo->empty_tree);
 
 	if (build_fake_ancestor(state, index_path))
@@ -1647,7 +1647,7 @@ static void do_commit(const struct am_state *state)
 	if (write_index_as_tree(&tree, &the_index, get_index_file(), 0, NULL))
 		die(_("git write-tree failed to write a tree"));
 
-	if (!get_oid_commit("HEAD", &parent)) {
+	if (!repo_get_oid_commit(the_repository, "HEAD", &parent)) {
 		old_oid = &parent;
 		commit_list_insert(lookup_commit(the_repository, &parent),
 				   &parents);
@@ -2089,7 +2089,7 @@ static void am_skip(struct am_state *state)
 
 	am_rerere_clear();
 
-	if (get_oid("HEAD", &head))
+	if (repo_get_oid(the_repository, "HEAD", &head))
 		oidcpy(&head, the_hash_algo->empty_tree);
 
 	if (clean_index(&head, &head))
@@ -2131,7 +2131,7 @@ static int safe_to_abort(const struct am_state *state)
 		oidclr(&abort_safety);
 	strbuf_release(&sb);
 
-	if (get_oid("HEAD", &head))
+	if (repo_get_oid(the_repository, "HEAD", &head))
 		oidclr(&head);
 
 	if (oideq(&head, &abort_safety))
@@ -2164,7 +2164,7 @@ static void am_abort(struct am_state *state)
 	if (!has_curr_head)
 		oidcpy(&curr_head, the_hash_algo->empty_tree);
 
-	has_orig_head = !get_oid("ORIG_HEAD", &orig_head);
+	has_orig_head = !repo_get_oid(the_repository, "ORIG_HEAD", &orig_head);
 	if (!has_orig_head)
 		oidcpy(&orig_head, the_hash_algo->empty_tree);
 
diff --git a/builtin/bisect.c b/builtin/bisect.c
index c64c8d715a5..f925ceeb3c0 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -236,7 +236,7 @@ static int bisect_reset(const char *commit)
 	} else {
 		struct object_id oid;
 
-		if (get_oid_commit(commit, &oid))
+		if (repo_get_oid_commit(the_repository, commit, &oid))
 			return error(_("'%s' is not a valid commit"), commit);
 		strbuf_addstr(&branch, commit);
 	}
@@ -294,7 +294,7 @@ static int bisect_write(const char *state, const char *rev,
 		goto finish;
 	}
 
-	if (get_oid(rev, &oid)) {
+	if (repo_get_oid(the_repository, rev, &oid)) {
 		res = error(_("couldn't get the oid of the rev '%s'"), rev);
 		goto finish;
 	}
@@ -777,7 +777,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
 	 */
 	head = resolve_ref_unsafe("HEAD", 0, &head_oid, &flags);
 	if (!head)
-		if (get_oid("HEAD", &head_oid))
+		if (repo_get_oid(the_repository, "HEAD", &head_oid))
 			return error(_("bad HEAD - I need a HEAD"));
 
 	/*
@@ -803,11 +803,11 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
 		}
 	} else {
 		/* Get the rev from where we start. */
-		if (!get_oid(head, &head_oid) &&
+		if (!repo_get_oid(the_repository, head, &head_oid) &&
 		    !starts_with(head, "refs/heads/")) {
 			strbuf_reset(&start_head);
 			strbuf_addstr(&start_head, oid_to_hex(&head_oid));
-		} else if (!get_oid(head, &head_oid) &&
+		} else if (!repo_get_oid(the_repository, head, &head_oid) &&
 			   skip_prefix(head, "refs/heads/", &head)) {
 			strbuf_addstr(&start_head, head);
 		} else {
@@ -830,7 +830,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
 		write_file(git_path_bisect_first_parent(), "\n");
 
 	if (no_checkout) {
-		if (get_oid(start_head.buf, &oid) < 0) {
+		if (repo_get_oid(the_repository, start_head.buf, &oid) < 0) {
 			res = error(_("invalid ref: '%s'"), start_head.buf);
 			goto finish;
 		}
@@ -935,11 +935,12 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
 
 	if (argc == 0) {
 		const char *head = "BISECT_HEAD";
-		enum get_oid_result res_head = get_oid(head, &oid);
+		enum get_oid_result res_head = repo_get_oid(the_repository,
+							    head, &oid);
 
 		if (res_head == MISSING_OBJECT) {
 			head = "HEAD";
-			res_head = get_oid(head, &oid);
+			res_head = repo_get_oid(the_repository, head, &oid);
 		}
 
 		if (res_head)
@@ -955,7 +956,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
 	for (; argc; argc--, argv++) {
 		struct commit *commit;
 
-		if (get_oid(*argv, &oid)){
+		if (repo_get_oid(the_repository, *argv, &oid)){
 			error(_("Bad rev input: %s"), *argv);
 			oid_array_clear(&revs);
 			return BISECT_FAILED;
diff --git a/builtin/blame.c b/builtin/blame.c
index fdd9f0c0fc7..6c266019ebb 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -603,8 +603,9 @@ static int read_ancestry(const char *graft_file)
 
 static int update_auto_abbrev(int auto_abbrev, struct blame_origin *suspect)
 {
-	const char *uniq = find_unique_abbrev(&suspect->commit->object.oid,
-					      auto_abbrev);
+	const char *uniq = repo_find_unique_abbrev(the_repository,
+						   &suspect->commit->object.oid,
+						   auto_abbrev);
 	int len = strlen(uniq);
 	if (auto_abbrev < len)
 		return len;
@@ -804,7 +805,7 @@ static int is_a_rev(const char *name)
 {
 	struct object_id oid;
 
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return 0;
 	return OBJ_NONE < oid_object_info(the_repository, &oid, NULL);
 }
@@ -847,7 +848,7 @@ static void build_ignorelist(struct blame_scoreboard *sb,
 						    peel_to_commit_oid, sb);
 	}
 	for_each_string_list_item(i, ignore_rev_list) {
-		if (get_oid_committish(i->string, &oid) ||
+		if (repo_get_oid_committish(the_repository, i->string, &oid) ||
 		    peel_to_commit_oid(&oid, sb))
 			die(_("cannot find revision %s to ignore"), i->string);
 		oidset_insert(&sb->ignore_list, &oid);
diff --git a/builtin/branch.c b/builtin/branch.c
index f63fd45edb9..968ea03c059 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -280,7 +280,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
 		item = string_list_append(&refs_to_delete, name);
 		item->util = xstrdup((flags & REF_ISBROKEN) ? "broken"
 				    : (flags & REF_ISSYMREF) ? target
-				    : find_unique_abbrev(&oid, DEFAULT_ABBREV));
+				    : repo_find_unique_abbrev(the_repository, &oid, DEFAULT_ABBREV));
 
 	next:
 		free(target);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 734d730980c..18f3fc76ced 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -433,8 +433,8 @@ static int checkout_worktree(const struct checkout_opts *opts,
 					      "Updated %d paths from %s",
 					      nr_checkouts),
 				   nr_checkouts,
-				   find_unique_abbrev(&opts->source_tree->object.oid,
-						      DEFAULT_ABBREV));
+				   repo_find_unique_abbrev(the_repository, &opts->source_tree->object.oid,
+							   DEFAULT_ABBREV));
 		else if (!nr_unmerged || nr_checkouts)
 			fprintf_ln(stderr, Q_("Updated %d path from the index",
 					      "Updated %d paths from the index",
@@ -658,10 +658,12 @@ static void describe_detached_head(const char *msg, struct commit *commit)
 		pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
 	if (print_sha1_ellipsis()) {
 		fprintf(stderr, "%s %s... %s\n", msg,
-			find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
+			repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
+			sb.buf);
 	} else {
 		fprintf(stderr, "%s %s %s\n", msg,
-			find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
+			repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
+			sb.buf);
 	}
 	strbuf_release(&sb);
 }
@@ -1074,7 +1076,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
 			" git branch <new-branch-name> %s\n\n",
 			/* Give ngettext() the count */
 			lost),
-			find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
+			repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
 }
 
 /*
@@ -1336,7 +1338,7 @@ static int parse_branchname_arg(int argc, const char **argv,
 	if (!strcmp(arg, "-"))
 		arg = "@{-1}";
 
-	if (get_oid_mb(arg, rev)) {
+	if (repo_get_oid_mb(the_repository, arg, rev)) {
 		/*
 		 * Either case (3) or (4), with <something> not being
 		 * a commit, or an attempt to use case (1) with an
@@ -1762,7 +1764,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
 	} else if (!opts->accept_ref && opts->from_treeish) {
 		struct object_id rev;
 
-		if (get_oid_mb(opts->from_treeish, &rev))
+		if (repo_get_oid_mb(the_repository, opts->from_treeish, &rev))
 			die(_("could not resolve %s"), opts->from_treeish);
 
 		setup_new_branch_info_and_source_tree(new_branch_info,
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index e805da5bb1c..b046c193067 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -46,7 +46,7 @@ static int parse_parent_arg_callback(const struct option *opt,
 
 	BUG_ON_OPT_NEG_NOARG(unset, arg);
 
-	if (get_oid_commit(arg, &oid))
+	if (repo_get_oid_commit(the_repository, arg, &oid))
 		die(_("not a valid object name %s"), arg);
 
 	assert_oid_type(&oid, OBJ_COMMIT);
@@ -124,7 +124,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 	if (argc != 1)
 		die(_("must give exactly one tree"));
 
-	if (get_oid_tree(argv[0], &tree_oid))
+	if (repo_get_oid_tree(the_repository, argv[0], &tree_oid))
 		die(_("not a valid object name %s"), argv[0]);
 
 	if (!buffer.len) {
diff --git a/builtin/commit.c b/builtin/commit.c
index f71ed41bf59..95bca976a58 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -557,7 +557,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
 	s->index_file = index_file;
 	s->fp = fp;
 	s->nowarn = nowarn;
-	s->is_initial = get_oid(s->reference, &oid) ? 1 : 0;
+	s->is_initial = repo_get_oid(the_repository, s->reference, &oid) ? 1 : 0;
 	if (!s->is_initial)
 		oidcpy(&s->oid_commit, &oid);
 	s->status_format = status_format;
@@ -1000,7 +1000,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		if (amend)
 			parent = "HEAD^1";
 
-		if (get_oid(parent, &oid)) {
+		if (repo_get_oid(the_repository, parent, &oid)) {
 			int i, ita_nr = 0;
 
 			/* TODO: audit for interaction with sparse-index. */
@@ -1567,7 +1567,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
 	else
 		fd = -1;
 
-	s.is_initial = get_oid(s.reference, &oid) ? 1 : 0;
+	s.is_initial = repo_get_oid(the_repository, s.reference, &oid) ? 1 : 0;
 	if (!s.is_initial)
 		oidcpy(&s.oid_commit, &oid);
 
@@ -1710,7 +1710,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
 	s.colopts = 0;
 
-	if (get_oid("HEAD", &oid))
+	if (repo_get_oid(the_repository, "HEAD", &oid))
 		current_head = NULL;
 	else {
 		current_head = lookup_commit_or_die(&oid, "HEAD");
diff --git a/builtin/describe.c b/builtin/describe.c
index 5b5930f5c8c..de3743e803a 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -299,7 +299,8 @@ static void append_name(struct commit_name *n, struct strbuf *dst)
 
 static void append_suffix(int depth, const struct object_id *oid, struct strbuf *dst)
 {
-	strbuf_addf(dst, "-%d-g%s", depth, find_unique_abbrev(oid, abbrev));
+	strbuf_addf(dst, "-%d-g%s", depth,
+		    repo_find_unique_abbrev(the_repository, oid, abbrev));
 }
 
 static void describe_commit(struct object_id *oid, struct strbuf *dst)
@@ -532,7 +533,7 @@ static void describe(const char *arg, int last_one)
 	if (debug)
 		fprintf(stderr, _("describe %s\n"), arg);
 
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		die(_("Not a valid object name %s"), arg);
 	cmit = lookup_commit_reference_gently(the_repository, &oid, 1);
 
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index f7548ff4a35..7faedc9aa44 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -2487,7 +2487,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
 		if (commit_oe->type != OBJ_COMMIT)
 			die("Mark :%" PRIuMAX " not a commit", commit_mark);
 		oidcpy(&commit_oid, &commit_oe->idx.oid);
-	} else if (!get_oid(p, &commit_oid)) {
+	} else if (!repo_get_oid(the_repository, p, &commit_oid)) {
 		unsigned long size;
 		char *buf = read_object_with_reference(the_repository,
 						       &commit_oid,
@@ -2600,7 +2600,7 @@ static int parse_objectish(struct branch *b, const char *objectish)
 			} else
 				parse_from_existing(b);
 		}
-	} else if (!get_oid(objectish, &b->oid)) {
+	} else if (!repo_get_oid(the_repository, objectish, &b->oid)) {
 		parse_from_existing(b);
 		if (is_null_oid(&b->oid))
 			b->delete = 1;
@@ -2655,7 +2655,7 @@ static struct hash_list *parse_merge(unsigned int *count)
 			if (oe->type != OBJ_COMMIT)
 				die("Mark :%" PRIuMAX " not a commit", idnum);
 			oidcpy(&n->oid, &oe->idx.oid);
-		} else if (!get_oid(from, &n->oid)) {
+		} else if (!repo_get_oid(the_repository, from, &n->oid)) {
 			unsigned long size;
 			char *buf = read_object_with_reference(the_repository,
 							       &n->oid,
@@ -2828,7 +2828,7 @@ static void parse_new_tag(const char *arg)
 		oe = find_mark(marks, from_mark);
 		type = oe->type;
 		oidcpy(&oid, &oe->idx.oid);
-	} else if (!get_oid(from, &oid)) {
+	} else if (!repo_get_oid(the_repository, from, &oid)) {
 		struct object_entry *oe = find_object(&oid);
 		if (!oe) {
 			type = oid_object_info(the_repository, &oid, NULL);
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 7221e57f352..6bab662829f 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1490,7 +1490,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
 		int old_nr;
 		if (!has_glob_specials(s)) {
 			struct object_id oid;
-			if (get_oid(s, &oid))
+			if (repo_get_oid(the_repository, s, &oid))
 				die(_("%s is not a valid object"), s);
 			if (!has_object(the_repository, &oid, 0))
 				die(_("the object %s does not exist"), s);
diff --git a/builtin/fsck.c b/builtin/fsck.c
index c4a633c0329..4537d9f0f22 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -959,7 +959,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 	for (i = 0; i < argc; i++) {
 		const char *arg = argv[i];
 		struct object_id oid;
-		if (!get_oid(arg, &oid)) {
+		if (!repo_get_oid(the_repository, arg, &oid)) {
 			struct object *obj = lookup_object(the_repository,
 							   &oid);
 
diff --git a/builtin/log.c b/builtin/log.c
index 4693385e8ed..1e7bbedf5d2 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1656,7 +1656,7 @@ static struct commit *get_base_commit(const char *base_commit,
 			struct commit *commit;
 			struct object_id oid;
 
-			if (get_oid(upstream, &oid)) {
+			if (repo_get_oid(the_repository, upstream, &oid)) {
 				if (die_on_failure)
 					die(_("failed to resolve '%s' as a valid ref"), upstream);
 				else
@@ -2414,7 +2414,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
 {
 	struct object_id oid;
-	if (get_oid(arg, &oid) == 0) {
+	if (repo_get_oid(the_repository, arg, &oid) == 0) {
 		struct commit *commit = lookup_commit_reference(the_repository,
 								&oid);
 		if (commit) {
@@ -2436,12 +2436,12 @@ static void print_commit(char sign, struct commit *commit, int verbose,
 {
 	if (!verbose) {
 		fprintf(file, "%c %s\n", sign,
-		       find_unique_abbrev(&commit->object.oid, abbrev));
+		       repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev));
 	} else {
 		struct strbuf buf = STRBUF_INIT;
 		pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
 		fprintf(file, "%c %s %s\n", sign,
-		       find_unique_abbrev(&commit->object.oid, abbrev),
+		       repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev),
 		       buf.buf);
 		strbuf_release(&buf);
 	}
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 26e309f533a..7fc82d7f760 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -363,7 +363,7 @@ static void show_ru_info(struct index_state *istate)
 			if (!ui->mode[i])
 				continue;
 			printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
-			       find_unique_abbrev(&ui->oid[i], abbrev),
+			       repo_find_unique_abbrev(the_repository, &ui->oid[i], abbrev),
 			       i + 1);
 			write_name(path);
 		}
@@ -578,7 +578,7 @@ void overlay_tree_on_index(struct index_state *istate,
 	read_tree_fn_t fn = NULL;
 	int err;
 
-	if (get_oid(tree_name, &oid))
+	if (repo_get_oid(the_repository, tree_name, &oid))
 		die("tree-ish %s not found.", tree_name);
 	tree = parse_tree_indirect(&oid);
 	if (!tree)
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 64d8e54318c..568088b6d66 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -229,7 +229,7 @@ static int show_tree_default(const struct object_id *oid, struct strbuf *base,
 		return early;
 
 	printf("%06o %s %s\t", mode, type_name(object_type(mode)),
-	       find_unique_abbrev(oid, options->abbrev));
+	       repo_find_unique_abbrev(the_repository, oid, options->abbrev));
 	show_tree_common_default_long(options, base, pathname, base->len);
 	return recurse;
 }
@@ -260,7 +260,8 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,
 	}
 
 	printf("%06o %s %s %7s\t", mode, type_name(type),
-	       find_unique_abbrev(oid, options->abbrev), size_text);
+	       repo_find_unique_abbrev(the_repository, oid, options->abbrev),
+	       size_text);
 	show_tree_common_default_long(options, base, pathname, base->len);
 	return recurse;
 }
@@ -311,7 +312,7 @@ static int show_tree_object(const struct object_id *oid, struct strbuf *base,
 	if (early >= 0)
 		return early;
 
-	str = find_unique_abbrev(oid, options->abbrev);
+	str = repo_find_unique_abbrev(the_repository, oid, options->abbrev);
 	if (options->null_termination) {
 		fputs(str, stdout);
 		fputc('\0', stdout);
@@ -434,7 +435,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
 			ls_tree_usage, ls_tree_options);
 	if (argc < 1)
 		usage_with_options(ls_tree_usage, ls_tree_options);
-	if (get_oid(argv[0], &oid))
+	if (repo_get_oid(the_repository, argv[0], &oid))
 		die("Not a valid object name %s", argv[0]);
 
 	/*
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index be8f3b221c9..5b0ed0d2738 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -43,7 +43,7 @@ static struct commit *get_commit_reference(const char *arg)
 	struct object_id revkey;
 	struct commit *r;
 
-	if (get_oid(arg, &revkey))
+	if (repo_get_oid(the_repository, arg, &revkey))
 		die("Not a valid object name %s", arg);
 	r = lookup_commit_reference(the_repository, &revkey);
 	if (!r)
@@ -119,7 +119,7 @@ static int handle_fork_point(int argc, const char **argv)
 	const char *commitname;
 
 	commitname = (argc == 2) ? argv[1] : "HEAD";
-	if (get_oid(commitname, &oid))
+	if (repo_get_oid(the_repository, commitname, &oid))
 		die("Not a valid object name: '%s'", commitname);
 
 	derived = lookup_commit_reference(the_repository, &oid);
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index b9acbf5d342..a50b328d943 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -49,7 +49,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
 		}
 		if (bases_count < ARRAY_SIZE(bases)-1) {
 			struct object_id *oid = xmalloc(sizeof(struct object_id));
-			if (get_oid(argv[i], oid))
+			if (repo_get_oid(the_repository, argv[i], oid))
 				die(_("could not parse object '%s'"), argv[i]);
 			bases[bases_count++] = oid;
 		}
@@ -70,9 +70,9 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
 	o.branch1 = argv[++i];
 	o.branch2 = argv[++i];
 
-	if (get_oid(o.branch1, &h1))
+	if (repo_get_oid(the_repository, o.branch1, &h1))
 		die(_("could not resolve ref '%s'"), o.branch1);
-	if (get_oid(o.branch2, &h2))
+	if (repo_get_oid(the_repository, o.branch2, &h2))
 		die(_("could not resolve ref '%s'"), o.branch2);
 
 	o.branch1 = better1 = better_branch_name(o.branch1);
diff --git a/builtin/merge.c b/builtin/merge.c
index 19c31d4ff48..6a0519c39db 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -339,7 +339,7 @@ static int save_state(struct object_id *stash)
 	else if (!len)		/* no changes */
 		goto out;
 	strbuf_setlen(&buffer, buffer.len-1);
-	if (get_oid(buffer.buf, stash))
+	if (repo_get_oid(the_repository, buffer.buf, stash))
 		die(_("not a valid object: %s"), buffer.buf);
 	rc = 0;
 out:
@@ -1566,10 +1566,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 
 		if (verbosity >= 0) {
 			printf(_("Updating %s..%s\n"),
-			       find_unique_abbrev(&head_commit->object.oid,
-						  DEFAULT_ABBREV),
-			       find_unique_abbrev(&remoteheads->item->object.oid,
-						  DEFAULT_ABBREV));
+			       repo_find_unique_abbrev(the_repository, &head_commit->object.oid,
+						       DEFAULT_ABBREV),
+			       repo_find_unique_abbrev(the_repository, &remoteheads->item->object.oid,
+						       DEFAULT_ABBREV));
 		}
 		commit = remoteheads->item;
 		if (!commit) {
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 723ba616a88..cd9c000f56b 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -494,7 +494,8 @@ static void show_name(const struct object *obj,
 	else if (allow_undefined)
 		printf("undefined\n");
 	else if (always)
-		printf("%s\n", find_unique_abbrev(oid, DEFAULT_ABBREV));
+		printf("%s\n",
+		       repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
 	else
 		die("cannot describe '%s'", oid_to_hex(oid));
 	strbuf_release(&buf);
@@ -528,7 +529,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)
 			counter = 0;
 
 			*(p+1) = 0;
-			if (!get_oid(p - (hexsz - 1), &oid)) {
+			if (!repo_get_oid(the_repository, p - (hexsz - 1), &oid)) {
 				struct object *o =
 					lookup_object(the_repository, &oid);
 				if (o)
@@ -605,7 +606,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
 		struct object *object;
 		struct commit *commit;
 
-		if (get_oid(*argv, &oid)) {
+		if (repo_get_oid(the_repository, *argv, &oid)) {
 			fprintf(stderr, "Could not get sha1 for %s. Skipping.\n",
 					*argv);
 			continue;
diff --git a/builtin/notes.c b/builtin/notes.c
index 75ce7f3f574..73c9c691781 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -259,7 +259,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
 	if (d->buf.len)
 		strbuf_addch(&d->buf, '\n');
 
-	if (get_oid(arg, &object))
+	if (repo_get_oid(the_repository, arg, &object))
 		die(_("failed to resolve '%s' as a valid ref."), arg);
 	if (!(buf = read_object_file(&object, &type, &len)))
 		die(_("failed to read object '%s'."), arg);
@@ -309,9 +309,9 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
 			die(_("malformed input line: '%s'."), buf.buf);
 		strbuf_rtrim(split[0]);
 		strbuf_rtrim(split[1]);
-		if (get_oid(split[0]->buf, &from_obj))
+		if (repo_get_oid(the_repository, split[0]->buf, &from_obj))
 			die(_("failed to resolve '%s' as a valid ref."), split[0]->buf);
-		if (get_oid(split[1]->buf, &to_obj))
+		if (repo_get_oid(the_repository, split[1]->buf, &to_obj))
 			die(_("failed to resolve '%s' as a valid ref."), split[1]->buf);
 
 		if (rewrite_cmd)
@@ -379,7 +379,7 @@ static int list(int argc, const char **argv, const char *prefix)
 
 	t = init_notes_check("list", 0);
 	if (argc) {
-		if (get_oid(argv[0], &object))
+		if (repo_get_oid(the_repository, argv[0], &object))
 			die(_("failed to resolve '%s' as a valid ref."), argv[0]);
 		note = get_note(t, &object);
 		if (note) {
@@ -434,7 +434,7 @@ static int add(int argc, const char **argv, const char *prefix)
 
 	object_ref = argc > 1 ? argv[1] : "HEAD";
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		die(_("failed to resolve '%s' as a valid ref."), object_ref);
 
 	t = init_notes_check("add", NOTES_INIT_WRITABLE);
@@ -522,12 +522,12 @@ static int copy(int argc, const char **argv, const char *prefix)
 		usage_with_options(git_notes_copy_usage, options);
 	}
 
-	if (get_oid(argv[0], &from_obj))
+	if (repo_get_oid(the_repository, argv[0], &from_obj))
 		die(_("failed to resolve '%s' as a valid ref."), argv[0]);
 
 	object_ref = 1 < argc ? argv[1] : "HEAD";
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		die(_("failed to resolve '%s' as a valid ref."), object_ref);
 
 	t = init_notes_check("copy", NOTES_INIT_WRITABLE);
@@ -606,7 +606,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)
 
 	object_ref = 1 < argc ? argv[1] : "HEAD";
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		die(_("failed to resolve '%s' as a valid ref."), object_ref);
 
 	t = init_notes_check(argv[0], NOTES_INIT_WRITABLE);
@@ -668,7 +668,7 @@ static int show(int argc, const char **argv, const char *prefix)
 
 	object_ref = argc ? argv[0] : "HEAD";
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		die(_("failed to resolve '%s' as a valid ref."), object_ref);
 
 	t = init_notes_check("show", 0);
@@ -718,7 +718,7 @@ static int merge_commit(struct notes_merge_options *o)
 	 * and target notes ref from .git/NOTES_MERGE_REF.
 	 */
 
-	if (get_oid("NOTES_MERGE_PARTIAL", &oid))
+	if (repo_get_oid(the_repository, "NOTES_MERGE_PARTIAL", &oid))
 		die(_("failed to read ref NOTES_MERGE_PARTIAL"));
 	else if (!(partial = lookup_commit_reference(the_repository, &oid)))
 		die(_("could not find commit from NOTES_MERGE_PARTIAL."));
@@ -897,7 +897,7 @@ static int remove_one_note(struct notes_tree *t, const char *name, unsigned flag
 {
 	int status;
 	struct object_id oid;
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return error(_("Failed to resolve '%s' as a valid ref."), name);
 	status = remove_note(t, oid.hash);
 	if (status)
diff --git a/builtin/prune.c b/builtin/prune.c
index 119a253a2ad..202f7367746 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -172,7 +172,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
 		struct object_id oid;
 		const char *name = *argv++;
 
-		if (!get_oid(name, &oid)) {
+		if (!repo_get_oid(the_repository, name, &oid)) {
 			struct object *object = parse_object_or_die(&oid,
 								    name);
 			add_pending_object(&revs, object, "");
diff --git a/builtin/pull.c b/builtin/pull.c
index 56f679d94a0..bc0f29064b3 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -1031,7 +1031,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
 	if (file_exists(git_path_merge_head(the_repository)))
 		die_conclude_merge();
 
-	if (get_oid("HEAD", &orig_head))
+	if (repo_get_oid(the_repository, "HEAD", &orig_head))
 		oidclr(&orig_head);
 
 	if (opt_rebase) {
@@ -1056,7 +1056,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
 	if (opt_dry_run)
 		return 0;
 
-	if (get_oid("HEAD", &curr_head))
+	if (repo_get_oid(the_repository, "HEAD", &curr_head))
 		oidclr(&curr_head);
 
 	if (!is_null_oid(&orig_head) && !is_null_oid(&curr_head) &&
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index aecfae12d3a..556ee84b6d3 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -65,20 +65,20 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
 
 	if (dash_dash == 3 ||
 	    (dash_dash < 0 && argc > 2 &&
-	     !get_oid_committish(argv[0], &oid) &&
-	     !get_oid_committish(argv[1], &oid) &&
-	     !get_oid_committish(argv[2], &oid))) {
+	     !repo_get_oid_committish(the_repository, argv[0], &oid) &&
+	     !repo_get_oid_committish(the_repository, argv[1], &oid) &&
+	     !repo_get_oid_committish(the_repository, argv[2], &oid))) {
 		if (dash_dash < 0)
 			; /* already validated arguments */
-		else if (get_oid_committish(argv[0], &oid))
+		else if (repo_get_oid_committish(the_repository, argv[0], &oid))
 			usage_msg_optf(_("not a revision: '%s'"),
 				       builtin_range_diff_usage, options,
 				       argv[0]);
-		else if (get_oid_committish(argv[1], &oid))
+		else if (repo_get_oid_committish(the_repository, argv[1], &oid))
 			usage_msg_optf(_("not a revision: '%s'"),
 				       builtin_range_diff_usage, options,
 				       argv[1]);
-		else if (get_oid_committish(argv[2], &oid))
+		else if (repo_get_oid_committish(the_repository, argv[2], &oid))
 			usage_msg_optf(_("not a revision: '%s'"),
 				       builtin_range_diff_usage, options,
 				       argv[2]);
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 11759c415f3..fe19852634b 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -199,7 +199,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
 	for (i = 0; i < argc; i++) {
 		const char *arg = argv[i];
 
-		if (get_oid(arg, &oid))
+		if (repo_get_oid(the_repository, arg, &oid))
 			die("Not a valid object name %s", arg);
 		if (list_tree(&oid) < 0)
 			die("failed to unpack tree object %s", arg);
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 5b7b908b66b..55ecc2d5f33 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -219,13 +219,15 @@ static int get_revision_ranges(struct commit *upstream, struct commit *onto,
 	*revisions = xstrfmt("%s...%s", oid_to_hex(&base_rev->object.oid),
 			     oid_to_hex(orig_head));
 
-	shorthead = find_unique_abbrev(orig_head, DEFAULT_ABBREV);
+	shorthead = repo_find_unique_abbrev(the_repository, orig_head,
+					    DEFAULT_ABBREV);
 
 	if (upstream) {
 		const char *shortrev;
 
-		shortrev = find_unique_abbrev(&base_rev->object.oid,
-					      DEFAULT_ABBREV);
+		shortrev = repo_find_unique_abbrev(the_repository,
+						   &base_rev->object.oid,
+						   DEFAULT_ABBREV);
 
 		*shortrevisions = xstrfmt("%s..%s", shortrev, shorthead);
 	} else
@@ -1262,7 +1264,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		int fd;
 
 		/* Sanity check */
-		if (get_oid("HEAD", &head))
+		if (repo_get_oid(the_repository, "HEAD", &head))
 			die(_("Cannot read HEAD"));
 
 		fd = repo_hold_locked_index(the_repository, &lock_file, 0);
@@ -1681,7 +1683,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	} else if (!options.onto_name)
 		options.onto_name = options.upstream_name;
 	if (strstr(options.onto_name, "...")) {
-		if (get_oid_mb(options.onto_name, &branch_base) < 0) {
+		if (repo_get_oid_mb(the_repository, options.onto_name, &branch_base) < 0) {
 			if (keep_base)
 				die(_("'%s': need exactly one merge base with branch"),
 				    options.upstream_name);
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index cccdb73807c..c6ab537a44f 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1344,7 +1344,7 @@ static int head_has_history(void)
 {
 	struct object_id oid;
 
-	return !get_oid("HEAD", &oid);
+	return !repo_get_oid(the_repository, "HEAD", &oid);
 }
 
 static const char *push_to_deploy(unsigned char *sha1,
@@ -1680,11 +1680,11 @@ static void check_aliased_update_internal(struct command *cmd,
 	rp_error("refusing inconsistent update between symref '%s' (%s..%s) and"
 		 " its target '%s' (%s..%s)",
 		 cmd->ref_name,
-		 find_unique_abbrev(&cmd->old_oid, DEFAULT_ABBREV),
-		 find_unique_abbrev(&cmd->new_oid, DEFAULT_ABBREV),
+		 repo_find_unique_abbrev(the_repository, &cmd->old_oid, DEFAULT_ABBREV),
+		 repo_find_unique_abbrev(the_repository, &cmd->new_oid, DEFAULT_ABBREV),
 		 dst_cmd->ref_name,
-		 find_unique_abbrev(&dst_cmd->old_oid, DEFAULT_ABBREV),
-		 find_unique_abbrev(&dst_cmd->new_oid, DEFAULT_ABBREV));
+		 repo_find_unique_abbrev(the_repository, &dst_cmd->old_oid, DEFAULT_ABBREV),
+		 repo_find_unique_abbrev(the_repository, &dst_cmd->new_oid, DEFAULT_ABBREV));
 
 	cmd->error_string = dst_cmd->error_string =
 		"inconsistent aliased update";
diff --git a/builtin/replace.c b/builtin/replace.c
index 71d8e949e35..f765a3e2d75 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -56,7 +56,7 @@ static int show_reference(struct repository *r, const char *refname,
 			struct object_id object;
 			enum object_type obj_type, repl_type;
 
-			if (get_oid(refname, &object))
+			if (repo_get_oid(the_repository, refname, &object))
 				return error(_("failed to resolve '%s' as a valid ref"), refname);
 
 			obj_type = oid_object_info(r, &object, NULL);
@@ -114,7 +114,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)
 	base_len = ref.len;
 
 	for (p = argv; *p; p++) {
-		if (get_oid(*p, &oid)) {
+		if (repo_get_oid(the_repository, *p, &oid)) {
 			error("failed to resolve '%s' as a valid ref", *p);
 			had_error = 1;
 			continue;
@@ -208,10 +208,10 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
 {
 	struct object_id object, repl;
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		return error(_("failed to resolve '%s' as a valid ref"),
 			     object_ref);
-	if (get_oid(replace_ref, &repl))
+	if (repo_get_oid(the_repository, replace_ref, &repl))
 		return error(_("failed to resolve '%s' as a valid ref"),
 			     replace_ref);
 
@@ -322,7 +322,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
 	struct object_id old_oid, new_oid, prev;
 	struct strbuf ref = STRBUF_INIT;
 
-	if (get_oid(object_ref, &old_oid) < 0)
+	if (repo_get_oid(the_repository, object_ref, &old_oid) < 0)
 		return error(_("not a valid object name: '%s'"), object_ref);
 
 	type = oid_object_info(the_repository, &old_oid, NULL);
@@ -377,7 +377,7 @@ static int replace_parents(struct strbuf *buf, int argc, const char **argv)
 		struct object_id oid;
 		struct commit *commit;
 
-		if (get_oid(argv[i], &oid) < 0) {
+		if (repo_get_oid(the_repository, argv[i], &oid) < 0) {
 			strbuf_release(&new_parents);
 			return error(_("not a valid object name: '%s'"),
 				     argv[i]);
@@ -424,7 +424,7 @@ static int check_one_mergetag(struct commit *commit,
 	/* iterate over new parents */
 	for (i = 1; i < mergetag_data->argc; i++) {
 		struct object_id oid;
-		if (get_oid(mergetag_data->argv[i], &oid) < 0)
+		if (repo_get_oid(the_repository, mergetag_data->argv[i], &oid) < 0)
 			return error(_("not a valid object name: '%s'"),
 				     mergetag_data->argv[i]);
 		if (oideq(get_tagged_oid(tag), &oid))
@@ -454,7 +454,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
 	const char *buffer;
 	unsigned long size;
 
-	if (get_oid(old_ref, &old_oid) < 0)
+	if (repo_get_oid(the_repository, old_ref, &old_oid) < 0)
 		return error(_("not a valid object name: '%s'"), old_ref);
 	commit = lookup_commit_reference(the_repository, &old_oid);
 	if (!commit)
diff --git a/builtin/reset.c b/builtin/reset.c
index 24b04aeecb9..cd4165537c5 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -90,7 +90,7 @@ static int reset_index(const char *ref, const struct object_id *oid, int reset_t
 
 	if (reset_type == KEEP) {
 		struct object_id head_oid;
-		if (get_oid("HEAD", &head_oid))
+		if (repo_get_oid(the_repository, "HEAD", &head_oid))
 			return error(_("You do not have a valid HEAD."));
 		if (!fill_tree_descriptor(the_repository, desc + nr, &head_oid))
 			return error(_("Failed to find tree of HEAD."));
@@ -125,7 +125,7 @@ static void print_new_head_line(struct commit *commit)
 	struct strbuf buf = STRBUF_INIT;
 
 	printf(_("HEAD is now at %s"),
-		find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
+		repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
 
 	pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
 	if (buf.len > 0)
@@ -261,8 +261,8 @@ static void parse_args(struct pathspec *pathspec,
 		 * has to be unambiguous. If there is a single argument, it
 		 * can not be a tree
 		 */
-		else if ((!argv[1] && !get_oid_committish(argv[0], &unused)) ||
-			 (argv[1] && !get_oid_treeish(argv[0], &unused))) {
+		else if ((!argv[1] && !repo_get_oid_committish(the_repository, argv[0], &unused)) ||
+			 (argv[1] && !repo_get_oid_treeish(the_repository, argv[0], &unused))) {
 			/*
 			 * Ok, argv[0] looks like a commit/tree; it should not
 			 * be a filename.
@@ -289,9 +289,9 @@ static int reset_refs(const char *rev, const struct object_id *oid)
 	struct object_id *orig = NULL, oid_orig,
 		*old_orig = NULL, oid_old_orig;
 
-	if (!get_oid("ORIG_HEAD", &oid_old_orig))
+	if (!repo_get_oid(the_repository, "ORIG_HEAD", &oid_old_orig))
 		old_orig = &oid_old_orig;
-	if (!get_oid("HEAD", &oid_orig)) {
+	if (!repo_get_oid(the_repository, "HEAD", &oid_orig)) {
 		orig = &oid_orig;
 		set_reflog_message(&msg, "updating ORIG_HEAD", NULL);
 		update_ref(msg.buf, "ORIG_HEAD", orig, old_orig, 0,
@@ -367,13 +367,14 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 		die(_("the option '%s' requires '%s'"), "--pathspec-file-nul", "--pathspec-from-file");
 	}
 
-	unborn = !strcmp(rev, "HEAD") && get_oid("HEAD", &oid);
+	unborn = !strcmp(rev, "HEAD") && repo_get_oid(the_repository, "HEAD",
+						      &oid);
 	if (unborn) {
 		/* reset on unborn branch: treat as reset to empty tree */
 		oidcpy(&oid, the_hash_algo->empty_tree);
 	} else if (!pathspec.nr && !patch_mode) {
 		struct commit *commit;
-		if (get_oid_committish(rev, &oid))
+		if (repo_get_oid_committish(the_repository, rev, &oid))
 			die(_("Failed to resolve '%s' as a valid revision."), rev);
 		commit = lookup_commit_reference(the_repository, &oid);
 		if (!commit)
@@ -381,7 +382,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 		oidcpy(&oid, &commit->object.oid);
 	} else {
 		struct tree *tree;
-		if (get_oid_treeish(rev, &oid))
+		if (repo_get_oid_treeish(the_repository, rev, &oid))
 			die(_("Failed to resolve '%s' as a valid tree."), rev);
 		tree = parse_tree_indirect(&oid);
 		if (!tree)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 85e522dff8a..e88affc2764 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -135,7 +135,7 @@ static void show_commit(struct commit *commit, void *data)
 		if (!revs->graph)
 			fputs(get_revision_mark(revs, commit), stdout);
 		if (revs->abbrev_commit && revs->abbrev)
-			fputs(find_unique_abbrev(&commit->object.oid, revs->abbrev),
+			fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, revs->abbrev),
 			      stdout);
 		else
 			fputs(oid_to_hex(&commit->object.oid), stdout);
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index e1fa9c6348c..5db9d6ad518 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -164,7 +164,8 @@ static void show_rev(int type, const struct object_id *oid, const char *name)
 		}
 	}
 	else if (abbrev)
-		show_with_type(type, find_unique_abbrev(oid, abbrev));
+		show_with_type(type,
+			       repo_find_unique_abbrev(the_repository, oid, abbrev));
 	else
 		show_with_type(type, oid_to_hex(oid));
 }
@@ -189,7 +190,7 @@ static int show_default(void)
 		struct object_id oid;
 
 		def = NULL;
-		if (!get_oid(s, &oid)) {
+		if (!repo_get_oid(the_repository, s, &oid)) {
 			show_rev(NORMAL, &oid, s);
 			return 1;
 		}
@@ -281,7 +282,7 @@ static int try_difference(const char *arg)
 		return 0;
 	}
 
-	if (!get_oid_committish(start, &start_oid) && !get_oid_committish(end, &end_oid)) {
+	if (!repo_get_oid_committish(the_repository, start, &start_oid) && !repo_get_oid_committish(the_repository, end, &end_oid)) {
 		show_rev(NORMAL, &end_oid, end);
 		show_rev(symmetric ? NORMAL : REVERSED, &start_oid, start);
 		if (symmetric) {
@@ -339,7 +340,7 @@ static int try_parent_shorthands(const char *arg)
 		return 0;
 
 	*dotdot = 0;
-	if (get_oid_committish(arg, &oid) ||
+	if (repo_get_oid_committish(the_repository, arg, &oid) ||
 	    !(commit = lookup_commit_reference(the_repository, &oid))) {
 		*dotdot = '^';
 		return 0;
@@ -870,7 +871,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 				continue;
 			}
 			if (skip_prefix(arg, "--disambiguate=", &arg)) {
-				for_each_abbrev(arg, show_abbrev, NULL);
+				repo_for_each_abbrev(the_repository, arg,
+						     show_abbrev, NULL);
 				continue;
 			}
 			if (!strcmp(arg, "--bisect")) {
diff --git a/builtin/rm.c b/builtin/rm.c
index dc198f79082..e093cb99966 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -371,7 +371,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 	 */
 	if (!force) {
 		struct object_id oid;
-		if (get_oid("HEAD", &oid))
+		if (repo_get_oid(the_repository, "HEAD", &oid))
 			oidclr(&oid);
 		if (check_local_mod(&oid, index_only))
 			exit(1);
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 8342b68aef7..9d208db3b43 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -313,8 +313,8 @@ static void show_one_commit(struct commit *commit, int no_name)
 		}
 		else
 			printf("[%s] ",
-			       find_unique_abbrev(&commit->object.oid,
-						  DEFAULT_ABBREV));
+			       repo_find_unique_abbrev(the_repository, &commit->object.oid,
+						       DEFAULT_ABBREV));
 	}
 	puts(pretty_str);
 	strbuf_release(&pretty);
@@ -415,7 +415,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
 	/* If both heads/foo and tags/foo exists, get_sha1 would
 	 * get confused.
 	 */
-	if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
+	if (repo_get_oid(the_repository, refname + ofs, &tmp) || !oideq(&tmp, oid))
 		ofs = 5;
 	return append_ref(refname + ofs, oid, 0);
 }
@@ -430,7 +430,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,
 	/* If both heads/foo and tags/foo exists, get_sha1 would
 	 * get confused.
 	 */
-	if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
+	if (repo_get_oid(the_repository, refname + ofs, &tmp) || !oideq(&tmp, oid))
 		ofs = 5;
 	return append_ref(refname + ofs, oid, 0);
 }
@@ -534,7 +534,7 @@ static int show_independent(struct commit **rev,
 static void append_one_rev(const char *av)
 {
 	struct object_id revkey;
-	if (!get_oid(av, &revkey)) {
+	if (!repo_get_oid(the_repository, av, &revkey)) {
 		append_ref(av, &revkey, 0);
 		return;
 	}
@@ -837,7 +837,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 			die(Q_("cannot handle more than %d rev.",
 			       "cannot handle more than %d revs.",
 			       MAX_REVS), MAX_REVS);
-		if (get_oid(ref_name[num_rev], &revkey))
+		if (repo_get_oid(the_repository, ref_name[num_rev], &revkey))
 			die(_("'%s' is not a valid ref."), ref_name[num_rev]);
 		commit = lookup_commit_reference(the_repository, &revkey);
 		if (!commit)
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 1f28d7fe4b9..b5a68e23e65 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -34,7 +34,7 @@ static void show_one(const char *refname, const struct object_id *oid)
 	if (quiet)
 		return;
 
-	hex = find_unique_abbrev(oid, abbrev);
+	hex = repo_find_unique_abbrev(the_repository, oid, abbrev);
 	if (hash_only)
 		printf("%s\n", hex);
 	else
@@ -44,7 +44,7 @@ static void show_one(const char *refname, const struct object_id *oid)
 		return;
 
 	if (!peel_iterated_oid(oid, &peeled)) {
-		hex = find_unique_abbrev(&peeled, abbrev);
+		hex = repo_find_unique_abbrev(the_repository, &peeled, abbrev);
 		printf("%s %s^{}\n", hex, refname);
 	}
 }
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 8d5ae6f2a60..d73d3d2d825 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -469,7 +469,7 @@ static int sparse_checkout_init(int argc, const char **argv, const char *prefix)
 		return update_working_directory(NULL);
 	}
 
-	if (get_oid("HEAD", &oid)) {
+	if (repo_get_oid(the_repository, "HEAD", &oid)) {
 		FILE *fp;
 
 		/* assume we are in a fresh repo, but update the sparse-checkout file */
diff --git a/builtin/stash.c b/builtin/stash.c
index 6a12fed2713..dd5f67e7e6e 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -202,7 +202,7 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
 
 	revision = info->revision.buf;
 
-	if (get_oid(revision, &info->w_commit))
+	if (repo_get_oid(the_repository, revision, &info->w_commit))
 		return error(_("%s is not a valid reference"), revision);
 
 	assert_stash_like(info, revision);
@@ -232,7 +232,7 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
 static int do_clear_stash(void)
 {
 	struct object_id obj;
-	if (get_oid(ref_stash, &obj))
+	if (repo_get_oid(the_repository, ref_stash, &obj))
 		return 0;
 
 	return delete_ref(NULL, ref_stash, &obj, 0);
@@ -1084,7 +1084,7 @@ static int check_changes_tracked_files(const struct pathspec *ps)
 	int ret = 0;
 
 	/* No initial commit. */
-	if (get_oid("HEAD", &dummy))
+	if (repo_get_oid(the_repository, "HEAD", &dummy))
 		return -1;
 
 	if (repo_read_index(the_repository) < 0)
@@ -1356,7 +1356,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
 		goto done;
 	}
 
-	if (get_oid("HEAD", &info->b_commit)) {
+	if (repo_get_oid(the_repository, "HEAD", &info->b_commit)) {
 		if (!quiet)
 			fprintf_ln(stderr, _("You do not have "
 					     "the initial commit yet"));
@@ -1374,8 +1374,9 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
 	branch_ref = resolve_ref_unsafe("HEAD", 0, NULL, &flags);
 	if (flags & REF_ISSYMREF)
 		skip_prefix(branch_ref, "refs/heads/", &branch_name);
-	head_short_sha1 = find_unique_abbrev(&head_commit->object.oid,
-					     DEFAULT_ABBREV);
+	head_short_sha1 = repo_find_unique_abbrev(the_repository,
+						  &head_commit->object.oid,
+						  DEFAULT_ABBREV);
 	strbuf_addf(&msg, "%s: %s ", branch_name, head_short_sha1);
 	pp_commit_easy(CMIT_FMT_ONELINE, head_commit, &msg);
 
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index d05d1a84623..b21857479de 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1176,7 +1176,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
 	if (!summary_limit)
 		return 0;
 
-	if (!get_oid(argc ? argv[0] : "HEAD", &head_oid)) {
+	if (!repo_get_oid(the_repository, argc ? argv[0] : "HEAD", &head_oid)) {
 		if (argc) {
 			argv++;
 			argc--;
@@ -1189,7 +1189,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
 			argc--;
 		}
 	} else {
-		if (get_oid("HEAD", &head_oid))
+		if (repo_get_oid(the_repository, "HEAD", &head_oid))
 			die(_("could not fetch a revision for HEAD"));
 	}
 
diff --git a/builtin/tag.c b/builtin/tag.c
index adcaa547b0d..7af7eaa4139 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -138,7 +138,7 @@ static int delete_tags(const char **argv)
 		if (!ref_exists(name))
 			printf(_("Deleted tag '%s' (was %s)\n"),
 				item->string + 10,
-				find_unique_abbrev(oid, DEFAULT_ABBREV));
+				repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
 
 		free(oid);
 	}
@@ -590,7 +590,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 	if (argc > 2)
 		die(_("too many arguments"));
 
-	if (get_oid(object_ref, &object))
+	if (repo_get_oid(the_repository, object_ref, &object))
 		die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
 	if (strbuf_check_tag_ref(&ref, tag))
@@ -631,7 +631,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 	ref_transaction_free(transaction);
 	if (force && !is_null_oid(&prev) && !oideq(&prev, &object))
 		printf(_("Updated tag '%s' (was %s)\n"), tag,
-		       find_unique_abbrev(&prev, DEFAULT_ABBREV));
+		       repo_find_unique_abbrev(the_repository, &prev, DEFAULT_ABBREV));
 
 cleanup:
 	ref_sorting_release(sorting);
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index e9b105a5397..b9e258a553f 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -30,7 +30,7 @@ int cmd_unpack_file(int argc, const char **argv, const char *prefix)
 
 	if (argc != 2 || !strcmp(argv[1], "-h"))
 		usage("git unpack-file <blob>");
-	if (get_oid(argv[1], &oid))
+	if (repo_get_oid(the_repository, argv[1], &oid))
 		die("Not a valid object name %s", argv[1]);
 
 	git_config(git_default_config, NULL);
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index a84e7b47a20..1ba0727ba77 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -116,7 +116,7 @@ static int parse_next_oid(const char **next, const char *end,
 		(*next)++;
 		*next = parse_arg(*next, &arg);
 		if (arg.len) {
-			if (get_oid(arg.buf, oid))
+			if (repo_get_oid(the_repository, arg.buf, oid))
 				goto invalid;
 		} else {
 			/* Without -z, an empty value means all zeros: */
@@ -134,7 +134,7 @@ static int parse_next_oid(const char **next, const char *end,
 		*next += arg.len;
 
 		if (arg.len) {
-			if (get_oid(arg.buf, oid))
+			if (repo_get_oid(the_repository, arg.buf, oid))
 				goto invalid;
 		} else if (flags & PARSE_SHA1_ALLOW_EMPTY) {
 			/* With -z, treat an empty value as all zeros: */
@@ -549,7 +549,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
 		refname = argv[0];
 		value = argv[1];
 		oldval = argv[2];
-		if (get_oid(value, &oid))
+		if (repo_get_oid(the_repository, value, &oid))
 			die("%s: not a valid SHA1", value);
 	}
 
@@ -560,7 +560,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
 			 * must not already exist:
 			 */
 			oidclr(&oldoid);
-		else if (get_oid(oldval, &oldoid))
+		else if (repo_get_oid(the_repository, oldval, &oldoid))
 			die("%s: not a valid old SHA1", oldval);
 	}
 
diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c
index 7aedf10e856..2a0c927ee93 100644
--- a/builtin/verify-commit.c
+++ b/builtin/verify-commit.c
@@ -39,7 +39,7 @@ static int verify_commit(const char *name, unsigned flags)
 	struct object_id oid;
 	struct object *obj;
 
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return error("commit '%s' not found.", name);
 
 	obj = parse_object(the_repository, &oid);
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 5c00b0b0f77..2a9aac43b85 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -52,7 +52,7 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)
 		struct object_id oid;
 		const char *name = argv[i++];
 
-		if (get_oid(name, &oid)) {
+		if (repo_get_oid(the_repository, name, &oid)) {
 			had_error = !!error("tag '%s' not found.", name);
 			continue;
 		}
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 80d05e246d8..62c02fe2dee 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -553,7 +553,7 @@ static void print_preparing_worktree_line(int detach,
 		else
 			fprintf_ln(stderr, _("Preparing worktree (resetting branch '%s'; was at %s)"),
 				  new_branch,
-				  find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
+				  repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
 	} else if (new_branch) {
 		fprintf_ln(stderr, _("Preparing worktree (new branch '%s')"), new_branch);
 	} else {
@@ -567,7 +567,7 @@ static void print_preparing_worktree_line(int detach,
 			if (!commit)
 				die(_("invalid reference: %s"), branch);
 			fprintf_ln(stderr, _("Preparing worktree (detached HEAD %s)"),
-				  find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
+				  repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
 		}
 		strbuf_release(&s);
 	}
@@ -757,7 +757,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)
 		strbuf_addstr(&sb, "(bare)");
 	else {
 		strbuf_addf(&sb, "%-*s ", abbrev_len,
-				find_unique_abbrev(&wt->head_oid, DEFAULT_ABBREV));
+				repo_find_unique_abbrev(the_repository, &wt->head_oid, DEFAULT_ABBREV));
 		if (wt->is_detached)
 			strbuf_addstr(&sb, "(detached HEAD)");
 		else if (wt->head_ref) {
@@ -794,7 +794,7 @@ static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)
 
 		if (path_len > *maxlen)
 			*maxlen = path_len;
-		sha1_len = strlen(find_unique_abbrev(&wt[i]->head_oid, *abbrev));
+		sha1_len = strlen(repo_find_unique_abbrev(the_repository, &wt[i]->head_oid, *abbrev));
 		if (sha1_len > *abbrev)
 			*abbrev = sha1_len;
 	}
diff --git a/cache.h b/cache.h
index 5a736a2b7e7..1d05a8e945f 100644
--- a/cache.h
+++ b/cache.h
@@ -1103,9 +1103,7 @@ void check_repository_format(struct repository_format *fmt);
  * reentrant, as it calls into other non-reentrant git code.
  */
 const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
-#define find_unique_abbrev(oid, len) repo_find_unique_abbrev(the_repository, oid, len)
 int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
-#define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
 
 /* set default permissions by passing mode arguments to open(2) */
 int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
@@ -1330,17 +1328,8 @@ enum get_oid_result get_oid_with_context(struct repository *repo, const char *st
 					 unsigned flags, struct object_id *oid,
 					 struct object_context *oc);
 
-#define get_oid(str, oid)		repo_get_oid(the_repository, str, oid)
-#define get_oid_commit(str, oid)	repo_get_oid_commit(the_repository, str, oid)
-#define get_oid_committish(str, oid)	repo_get_oid_committish(the_repository, str, oid)
-#define get_oid_tree(str, oid)		repo_get_oid_tree(the_repository, str, oid)
-#define get_oid_treeish(str, oid)	repo_get_oid_treeish(the_repository, str, oid)
-#define get_oid_blob(str, oid)		repo_get_oid_blob(the_repository, str, oid)
-#define get_oid_mb(str, oid) 		repo_get_oid_mb(the_repository, str, oid)
-
 typedef int each_abbrev_fn(const struct object_id *oid, void *);
 int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
-#define for_each_abbrev(prefix, fn, data) repo_for_each_abbrev(the_repository, prefix, fn, data)
 
 int set_disambiguate_hint_config(const char *var, const char *value);
 
@@ -1388,8 +1377,6 @@ int repo_interpret_branch_name(struct repository *r,
 			       const char *str, int len,
 			       struct strbuf *buf,
 			       const struct interpret_branch_name_options *options);
-#define interpret_branch_name(str, len, buf, options) \
-	repo_interpret_branch_name(the_repository, str, len, buf, options)
 
 int validate_headref(const char *ref);
 
@@ -1409,8 +1396,6 @@ void *read_object_with_reference(struct repository *r,
 struct object *repo_peel_to_type(struct repository *r,
 				 const char *name, int namelen,
 				 struct object *o, enum object_type);
-#define peel_to_type(name, namelen, obj, type) \
-	repo_peel_to_type(the_repository, name, namelen, obj, type)
 
 const char *git_editor(void);
 const char *git_sequence_editor(void);
diff --git a/checkout.c b/checkout.c
index 2e39dae684f..1247b882248 100644
--- a/checkout.c
+++ b/checkout.c
@@ -23,7 +23,7 @@ static int check_tracking_name(struct remote *remote, void *cb_data)
 	memset(&query, 0, sizeof(struct refspec_item));
 	query.src = cb->src_ref;
 	if (remote_find_tracking(remote, &query) ||
-	    get_oid(query.dst, cb->dst_oid)) {
+	    repo_get_oid(the_repository, query.dst, cb->dst_oid)) {
 		free(query.dst);
 		return 0;
 	}
diff --git a/combine-diff.c b/combine-diff.c
index 91051dc3258..e917362faf7 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -949,11 +949,11 @@ static void show_combined_header(struct combine_diff_path *elem,
 			 "", elem->path, line_prefix, c_meta, c_reset);
 	printf("%s%sindex ", line_prefix, c_meta);
 	for (i = 0; i < num_parent; i++) {
-		abb = find_unique_abbrev(&elem->parent[i].oid,
-					 abbrev);
+		abb = repo_find_unique_abbrev(the_repository,
+					      &elem->parent[i].oid, abbrev);
 		printf("%s%s", i ? "," : "", abb);
 	}
-	abb = find_unique_abbrev(&elem->oid, abbrev);
+	abb = repo_find_unique_abbrev(the_repository, &elem->oid, abbrev);
 	printf("..%s%s\n", abb, c_reset);
 
 	if (mode_differs) {
diff --git a/commit.c b/commit.c
index 7b63d3b0e1c..c0b1db3d3e1 100644
--- a/commit.c
+++ b/commit.c
@@ -81,7 +81,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
 	struct object_id oid;
 	struct commit *commit;
 
-	if (get_oid_committish(name, &oid))
+	if (repo_get_oid_committish(the_repository, name, &oid))
 		return NULL;
 	commit = lookup_commit_reference(the_repository, &oid);
 	if (parse_commit(commit))
@@ -1274,7 +1274,8 @@ void verify_merge_signature(struct commit *commit, int verbosity,
 
 	ret = check_commit_signature(commit, &signature_check);
 
-	find_unique_abbrev_r(hex, &commit->object.oid, DEFAULT_ABBREV);
+	repo_find_unique_abbrev_r(the_repository, hex, &commit->object.oid,
+				  DEFAULT_ABBREV);
 	switch (signature_check.result) {
 	case 'G':
 		if (ret || (check_trust && signature_check.trust_level < TRUST_MARGINAL))
@@ -1635,10 +1636,11 @@ struct commit *get_merge_parent(const char *name)
 	struct object *obj;
 	struct commit *commit;
 	struct object_id oid;
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return NULL;
 	obj = parse_object(the_repository, &oid);
-	commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
+	commit = (struct commit *)repo_peel_to_type(the_repository, name, 0,
+						    obj, OBJ_COMMIT);
 	if (commit && !merge_remote_util(commit))
 		set_merge_remote_desc(commit, name, obj);
 	return commit;
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
new file mode 100644
index 00000000000..dcdba314fc2
--- /dev/null
+++ b/contrib/coccinelle/the_repository.cocci
@@ -0,0 +1,44 @@
+// Fully migrated "the_repository" additions
+@@
+@@
+(
+// cache.h
+- get_oid
++ repo_get_oid
+|
+- get_oid_commit
++ repo_get_oid_commit
+|
+- get_oid_committish
++ repo_get_oid_committish
+|
+- get_oid_tree
++ repo_get_oid_tree
+|
+- get_oid_treeish
++ repo_get_oid_treeish
+|
+- get_oid_blob
++ repo_get_oid_blob
+|
+- get_oid_mb
++ repo_get_oid_mb
+|
+- find_unique_abbrev
++ repo_find_unique_abbrev
+|
+- find_unique_abbrev_r
++ repo_find_unique_abbrev_r
+|
+- for_each_abbrev
++ repo_for_each_abbrev
+|
+- interpret_branch_name
++ repo_interpret_branch_name
+|
+- peel_to_type
++ repo_peel_to_type
+)
+  (
++ the_repository,
+  ...)
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 8b3f2580e6b..2d200ab83e7 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,44 +5,7 @@
 @@
 @@
 (
-// cache.h
-- get_oid
-+ repo_get_oid
-|
-- get_oid_commit
-+ repo_get_oid_commit
-|
-- get_oid_committish
-+ repo_get_oid_committish
-|
-- get_oid_tree
-+ repo_get_oid_tree
-|
-- get_oid_treeish
-+ repo_get_oid_treeish
-|
-- get_oid_blob
-+ repo_get_oid_blob
-|
-- get_oid_mb
-+ repo_get_oid_mb
-|
-- find_unique_abbrev
-+ repo_find_unique_abbrev
-|
-- find_unique_abbrev_r
-+ repo_find_unique_abbrev_r
-|
-- for_each_abbrev
-+ repo_for_each_abbrev
-|
-- interpret_branch_name
-+ repo_interpret_branch_name
-|
-- peel_to_type
-+ repo_peel_to_type
 // commit-reach.h
-|
 - get_merge_bases
 + repo_get_merge_bases
 |
diff --git a/diff-lib.c b/diff-lib.c
index 70b3578b907..628e13c8b03 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -582,7 +582,7 @@ void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb)
 	if (revs->pending.nr == 1) {
 		struct object_id oid;
 
-		if (get_oid("HEAD", &oid))
+		if (repo_get_oid(the_repository, "HEAD", &oid))
 			die(_("unable to get HEAD"));
 
 		mb_child[1] = lookup_commit_reference(the_repository, &oid);
diff --git a/diff.c b/diff.c
index 1617aa50a98..81f115d32c9 100644
--- a/diff.c
+++ b/diff.c
@@ -4364,7 +4364,7 @@ static int similarity_index(struct diff_filepair *p)
 static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)
 {
 	if (startup_info->have_repository)
-		return find_unique_abbrev(oid, abbrev);
+		return repo_find_unique_abbrev(the_repository, oid, abbrev);
 	else {
 		char *hex = oid_to_hex(oid);
 		if (abbrev < 0)
@@ -5000,7 +5000,7 @@ static int diff_opt_find_object(const struct option *option,
 	struct object_id oid;
 
 	BUG_ON_OPT_NEG(unset);
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		return error(_("unable to resolve '%s'"), arg);
 
 	if (!opt->objfind)
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 24cc44bdbc9..bb56d957a64 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -603,7 +603,9 @@ static void find_merge_parents(struct merge_parents *result,
 		 * util field yet.
 		 */
 		obj = parse_object(the_repository, &oid);
-		parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);
+		parent = (struct commit *)repo_peel_to_type(the_repository,
+							    NULL, 0, obj,
+							    OBJ_COMMIT);
 		if (!parent)
 			continue;
 		commit_list_insert(parent, &parents);
diff --git a/log-tree.c b/log-tree.c
index 3adcb576e4c..49411c5c6a6 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -236,7 +236,8 @@ static void show_parents(struct commit *commit, int abbrev, FILE *file)
 	struct commit_list *p;
 	for (p = commit->parents; p ; p = p->next) {
 		struct commit *parent = p->item;
-		fprintf(file, " %s", find_unique_abbrev(&parent->object.oid, abbrev));
+		fprintf(file, " %s",
+			repo_find_unique_abbrev(the_repository, &parent->object.oid, abbrev));
 	}
 }
 
@@ -244,7 +245,8 @@ static void show_children(struct rev_info *opt, struct commit *commit, int abbre
 {
 	struct commit_list *p = lookup_decoration(&opt->children, &commit->object);
 	for ( ; p; p = p->next) {
-		fprintf(opt->diffopt.file, " %s", find_unique_abbrev(&p->item->object.oid, abbrev));
+		fprintf(opt->diffopt.file, " %s",
+			repo_find_unique_abbrev(the_repository, &p->item->object.oid, abbrev));
 	}
 }
 
@@ -647,7 +649,8 @@ void show_log(struct rev_info *opt)
 
 		if (!opt->graph)
 			put_revision_mark(opt, commit);
-		fputs(find_unique_abbrev(&commit->object.oid, abbrev_commit), opt->diffopt.file);
+		fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev_commit),
+		      opt->diffopt.file);
 		if (opt->print_parents)
 			show_parents(commit, abbrev_commit, opt->diffopt.file);
 		if (opt->children.name)
@@ -709,8 +712,8 @@ void show_log(struct rev_info *opt)
 
 		if (!opt->graph)
 			put_revision_mark(opt, commit);
-		fputs(find_unique_abbrev(&commit->object.oid,
-					 abbrev_commit),
+		fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid,
+					      abbrev_commit),
 		      opt->diffopt.file);
 		if (opt->print_parents)
 			show_parents(commit, abbrev_commit, opt->diffopt.file);
@@ -718,7 +721,7 @@ void show_log(struct rev_info *opt)
 			show_children(opt, commit, abbrev_commit);
 		if (parent)
 			fprintf(opt->diffopt.file, " (from %s)",
-			       find_unique_abbrev(&parent->object.oid, abbrev_commit));
+			       repo_find_unique_abbrev(the_repository, &parent->object.oid, abbrev_commit));
 		fputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file);
 		show_decorations(opt, commit);
 		if (opt->commit_format == CMIT_FMT_ONELINE) {
diff --git a/mailmap.c b/mailmap.c
index da2589b0822..ed8289aea58 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -213,7 +213,7 @@ static int read_mailmap_blob(struct string_list *map, const char *name)
 
 	if (!name)
 		return 0;
-	if (get_oid(name, &oid) < 0)
+	if (repo_get_oid(the_repository, name, &oid) < 0)
 		return 0;
 
 	buf = read_object_file(&oid, &type, &size);
diff --git a/notes-merge.c b/notes-merge.c
index 5b1a9ff13f7..f9137ec768f 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -567,7 +567,7 @@ int notes_merge(struct notes_merge_options *o,
 	trace_printf("\tlocal commit: %.7s\n", oid_to_hex(&local_oid));
 
 	/* Dereference o->remote_ref into remote_oid */
-	if (get_oid(o->remote_ref, &remote_oid)) {
+	if (repo_get_oid(the_repository, o->remote_ref, &remote_oid)) {
 		/*
 		 * Failed to get remote_oid. If o->remote_ref looks like an
 		 * unborn ref, perform the merge using an empty notes tree.
diff --git a/notes.c b/notes.c
index a7187236e98..427cfdac294 100644
--- a/notes.c
+++ b/notes.c
@@ -946,7 +946,7 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
 		for_each_glob_ref(string_list_add_one_ref, glob, list);
 	} else {
 		struct object_id oid;
-		if (get_oid(glob, &oid))
+		if (repo_get_oid(the_repository, glob, &oid))
 			warning("notes ref %s is invalid", glob);
 		if (!unsorted_string_list_has_string(list, glob))
 			string_list_append(list, glob);
@@ -1023,7 +1023,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
 	t->dirty = 0;
 
 	if (flags & NOTES_INIT_EMPTY || !notes_ref ||
-	    get_oid_treeish(notes_ref, &object_oid))
+	    repo_get_oid_treeish(the_repository, notes_ref, &object_oid))
 		return;
 	if (flags & NOTES_INIT_WRITABLE && read_ref(notes_ref, &object_oid))
 		die("Cannot use notes ref %s", notes_ref);
@@ -1350,7 +1350,7 @@ void expand_loose_notes_ref(struct strbuf *sb)
 {
 	struct object_id object;
 
-	if (get_oid(sb->buf, &object)) {
+	if (repo_get_oid(the_repository, sb->buf, &object)) {
 		/* fallback to expand_notes_ref */
 		expand_notes_ref(sb);
 	}
diff --git a/object-name.c b/object-name.c
index 69db1ec498a..19ba23216a5 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1667,7 +1667,8 @@ void strbuf_branchname(struct strbuf *sb, const char *name, unsigned allowed)
 	struct interpret_branch_name_options options = {
 		.allowed = allowed
 	};
-	int used = interpret_branch_name(name, len, sb, &options);
+	int used = repo_interpret_branch_name(the_repository, name, len, sb,
+					      &options);
 
 	if (used < 0)
 		used = 0;
@@ -1720,7 +1721,7 @@ int get_oidf(struct object_id *oid, const char *fmt, ...)
 	strbuf_vaddf(&sb, fmt, ap);
 	va_end(ap);
 
-	ret = get_oid(sb.buf, oid);
+	ret = repo_get_oid(the_repository, sb.buf, oid);
 	strbuf_release(&sb);
 
 	return ret;
diff --git a/parse-options-cb.c b/parse-options-cb.c
index d346dbe2100..0f7b40d0c08 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -91,7 +91,7 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset)
 
 	if (!arg)
 		return -1;
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		return error("malformed object name %s", arg);
 	commit = lookup_commit_reference(the_repository, &oid);
 	if (!commit)
@@ -110,7 +110,7 @@ int parse_opt_commit(const struct option *opt, const char *arg, int unset)
 
 	if (!arg)
 		return -1;
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		return error("malformed object name %s", arg);
 	commit = lookup_commit_reference(the_repository, &oid);
 	if (!commit)
@@ -129,7 +129,7 @@ int parse_opt_object_name(const struct option *opt, const char *arg, int unset)
 	}
 	if (!arg)
 		return -1;
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		return error(_("malformed object name '%s'"), arg);
 	oid_array_append(opt->value, &oid);
 	return 0;
@@ -146,7 +146,7 @@ int parse_opt_object_id(const struct option *opt, const char *arg, int unset)
 	}
 	if (!arg)
 		return -1;
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		return error(_("malformed object name '%s'"), arg);
 	*target = oid;
 	return 0;
diff --git a/range-diff.c b/range-diff.c
index 4bd65ab7496..5bcf966f6c5 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -94,7 +94,7 @@ static int read_patches(const char *range, struct string_list *list,
 				strbuf_reset(&buf);
 			}
 			CALLOC_ARRAY(util, 1);
-			if (get_oid(p, &util->oid)) {
+			if (repo_get_oid(the_repository, p, &util->oid)) {
 				error(_("could not parse commit '%s'"), p);
 				FREE_AND_NULL(util);
 				string_list_clear(list, 1);
@@ -390,7 +390,7 @@ static void output_pair_header(struct diff_options *diffopt,
 
 	if (!dashes->len)
 		strbuf_addchars(dashes, '-',
-				strlen(find_unique_abbrev(oid, abbrev)));
+				strlen(repo_find_unique_abbrev(the_repository, oid, abbrev)));
 
 	if (!b_util) {
 		color = color_old;
@@ -412,7 +412,7 @@ static void output_pair_header(struct diff_options *diffopt,
 		strbuf_addf(buf, "%*s:  %s ", patch_no_width, "-", dashes->buf);
 	else
 		strbuf_addf(buf, "%*d:  %s ", patch_no_width, a_util->i + 1,
-			    find_unique_abbrev(&a_util->oid, abbrev));
+			    repo_find_unique_abbrev(the_repository, &a_util->oid, abbrev));
 
 	if (status == '!')
 		strbuf_addf(buf, "%s%s", color_reset, color);
@@ -424,7 +424,7 @@ static void output_pair_header(struct diff_options *diffopt,
 		strbuf_addf(buf, " %*s:  %s", patch_no_width, "-", dashes->buf);
 	else
 		strbuf_addf(buf, " %*d:  %s", patch_no_width, b_util->i + 1,
-			    find_unique_abbrev(&b_util->oid, abbrev));
+			    repo_find_unique_abbrev(the_repository, &b_util->oid, abbrev));
 
 	commit = lookup_commit_reference(the_repository, oid);
 	if (commit) {
diff --git a/read-cache.c b/read-cache.c
index 1bcf6732718..c1d47b9fc83 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2630,7 +2630,7 @@ int repo_index_has_changes(struct repository *repo,
 
 	if (tree)
 		cmp = tree->object.oid;
-	if (tree || !get_oid_tree("HEAD", &cmp)) {
+	if (tree || !repo_get_oid_tree(the_repository, "HEAD", &cmp)) {
 		struct diff_options opt;
 
 		repo_diff_setup(repo, &opt);
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 7407c593191..c151db0ad2f 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -187,7 +187,7 @@ int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo)
 		struct commit *commit = item->commit;
 		if (commit && !*commit_seen_at(&commit_seen, commit)) {
 			strbuf_addf(&missing, " - %s %.*s\n",
-				    find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV),
+				    repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
 				    item->arg_len,
 				    todo_item_get_arg(old_todo, item));
 			*commit_seen_at(&commit_seen, commit) = 1;
diff --git a/ref-filter.c b/ref-filter.c
index ed802778da7..4982841b3da 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1093,9 +1093,11 @@ static const char *do_grab_oid(const char *field, const struct object_id *oid,
 	case O_FULL:
 		return oid_to_hex(oid);
 	case O_LENGTH:
-		return find_unique_abbrev(oid, atom->u.oid.length);
+		return repo_find_unique_abbrev(the_repository, oid,
+					       atom->u.oid.length);
 	case O_SHORT:
-		return find_unique_abbrev(oid, DEFAULT_ABBREV);
+		return repo_find_unique_abbrev(the_repository, oid,
+					       DEFAULT_ABBREV);
 	default:
 		BUG("unknown %%(%s) option", field);
 	}
@@ -2783,7 +2785,7 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
 
 	BUG_ON_OPT_NEG(unset);
 
-	if (get_oid(arg, &oid))
+	if (repo_get_oid(the_repository, arg, &oid))
 		die(_("malformed object name %s"), arg);
 
 	merge_commit = lookup_commit_reference_gently(the_repository, &oid, 0);
diff --git a/remote.c b/remote.c
index b04e5da3383..a0f22c8751e 100644
--- a/remote.c
+++ b/remote.c
@@ -1165,7 +1165,7 @@ static int try_explicit_object_name(const char *name,
 		return 0;
 	}
 
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return -1;
 
 	if (match) {
@@ -1253,7 +1253,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,
 	if (!advice_enabled(ADVICE_PUSH_UNQUALIFIED_REF_NAME))
 		return;
 
-	if (get_oid(matched_src_name, &oid))
+	if (repo_get_oid(the_repository, matched_src_name, &oid))
 		BUG("'%s' is not a valid object, "
 		    "match_explicit_lhs() should catch this!",
 		    matched_src_name);
@@ -2507,7 +2507,7 @@ static int parse_push_cas_option(struct push_cas_option *cas, const char *arg, i
 		entry->use_tracking = 1;
 	else if (!colon[1])
 		oidclr(&entry->expect);
-	else if (get_oid(colon + 1, &entry->expect))
+	else if (repo_get_oid(the_repository, colon + 1, &entry->expect))
 		return error(_("cannot parse expected object name '%s'"),
 			     colon + 1);
 	return 0;
diff --git a/reset.c b/reset.c
index 58b3829ff73..8c471e22d99 100644
--- a/reset.c
+++ b/reset.c
@@ -39,7 +39,7 @@ static int update_refs(const struct reset_head_opts *opts,
 	prefix_len = msg.len;
 
 	if (update_orig_head) {
-		if (!get_oid("ORIG_HEAD", &oid_old_orig))
+		if (!repo_get_oid(the_repository, "ORIG_HEAD", &oid_old_orig))
 			old_orig = &oid_old_orig;
 		if (head) {
 			if (!reflog_orig_head) {
@@ -107,7 +107,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
 		goto leave_reset_head;
 	}
 
-	if (!get_oid("HEAD", &head_oid)) {
+	if (!repo_get_oid(the_repository, "HEAD", &head_oid)) {
 		head = &head_oid;
 	} else if (!oid || !reset_hard) {
 		ret = error(_("could not determine HEAD revision"));
diff --git a/revision.c b/revision.c
index e4c066e90b7..e08f697c47c 100644
--- a/revision.c
+++ b/revision.c
@@ -326,7 +326,8 @@ static void add_pending_object_with_path(struct rev_info *revs,
 	if (revs->reflog_info && obj->type == OBJ_COMMIT) {
 		struct strbuf buf = STRBUF_INIT;
 		size_t namelen = strlen(name);
-		int len = interpret_branch_name(name, namelen, &buf, &options);
+		int len = repo_interpret_branch_name(the_repository, name,
+						     namelen, &buf, &options);
 
 		if (0 < len && len < namelen && buf.len)
 			strbuf_addstr(&buf, name + len);
@@ -356,7 +357,7 @@ void add_head_to_pending(struct rev_info *revs)
 {
 	struct object_id oid;
 	struct object *obj;
-	if (get_oid("HEAD", &oid))
+	if (repo_get_oid(the_repository, "HEAD", &oid))
 		return;
 	obj = parse_object(revs->repo, &oid);
 	if (!obj)
@@ -1870,7 +1871,7 @@ static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,
 		flags ^= UNINTERESTING | BOTTOM;
 		arg++;
 	}
-	if (get_oid_committish(arg, &oid))
+	if (repo_get_oid_committish(the_repository, arg, &oid))
 		return 0;
 	while (1) {
 		it = get_reference(revs, arg, &oid, 0);
@@ -1951,10 +1952,10 @@ static void prepare_show_merge(struct rev_info *revs)
 	int i, prune_num = 1; /* counting terminating NULL */
 	struct index_state *istate = revs->repo->index;
 
-	if (get_oid("HEAD", &oid))
+	if (repo_get_oid(the_repository, "HEAD", &oid))
 		die("--merge without HEAD?");
 	head = lookup_commit_or_die(&oid, "HEAD");
-	if (get_oid("MERGE_HEAD", &oid))
+	if (repo_get_oid(the_repository, "MERGE_HEAD", &oid))
 		die("--merge without MERGE_HEAD?");
 	other = lookup_commit_or_die(&oid, "MERGE_HEAD");
 	add_pending_object(revs, &head->object, "HEAD");
diff --git a/sequencer.c b/sequencer.c
index 3be23d7ca20..d73827632d8 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -417,7 +417,8 @@ struct commit_message {
 
 static const char *short_commit_name(struct commit *commit)
 {
-	return find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV);
+	return repo_find_unique_abbrev(the_repository, &commit->object.oid,
+				       DEFAULT_ABBREV);
 }
 
 static int get_message(struct commit *commit, struct commit_message *out)
@@ -559,7 +560,7 @@ static void update_abort_safety_file(void)
 	if (!file_exists(git_path_seq_dir()))
 		return;
 
-	if (!get_oid("HEAD", &head))
+	if (!repo_get_oid(the_repository, "HEAD", &head))
 		write_file(git_path_abort_safety_file(), "%s", oid_to_hex(&head));
 	else
 		write_file(git_path_abort_safety_file(), "%s", "");
@@ -1404,7 +1405,7 @@ static int parse_head(struct repository *r, struct commit **head)
 	struct commit *current_head;
 	struct object_id oid;
 
-	if (get_oid("HEAD", &oid)) {
+	if (repo_get_oid(the_repository, "HEAD", &oid)) {
 		current_head = NULL;
 	} else {
 		current_head = lookup_commit_reference(r, &oid);
@@ -1995,7 +1996,7 @@ static int update_squash_messages(struct repository *r,
 		struct commit *head_commit;
 		const char *head_message, *body;
 
-		if (get_oid("HEAD", &head))
+		if (repo_get_oid(the_repository, "HEAD", &head))
 			return error(_("need a HEAD to fixup"));
 		if (!(head_commit = lookup_commit_reference(r, &head)))
 			return error(_("could not read HEAD"));
@@ -2065,7 +2066,7 @@ static void flush_rewritten_pending(void)
 	FILE *out;
 
 	if (strbuf_read_file(&buf, rebase_path_rewritten_pending(), (GIT_MAX_HEXSZ + 1) * 2) > 0 &&
-	    !get_oid("HEAD", &newoid) &&
+	    !repo_get_oid(the_repository, "HEAD", &newoid) &&
 	    (out = fopen_or_warn(rebase_path_rewritten_list(), "a"))) {
 		char *bol = buf.buf, *eol;
 
@@ -2150,7 +2151,7 @@ static int do_pick_commit(struct repository *r,
 		if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL))
 			return error(_("your index file is unmerged."));
 	} else {
-		unborn = get_oid("HEAD", &head);
+		unborn = repo_get_oid(the_repository, "HEAD", &head);
 		/* Do we want to generate a root commit? */
 		if (is_pick_or_similar(command) && opts->have_squash_onto &&
 		    oideq(&head, &opts->squash_onto)) {
@@ -2604,7 +2605,7 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
 	end_of_object_name = (char *) bol + strcspn(bol, " \t\n");
 	saved = *end_of_object_name;
 	*end_of_object_name = '\0';
-	status = get_oid(bol, &commit_oid);
+	status = repo_get_oid(the_repository, bol, &commit_oid);
 	if (status < 0)
 		error(_("could not parse '%s'"), bol); /* return later */
 	*end_of_object_name = saved;
@@ -3025,7 +3026,7 @@ static int read_populate_opts(struct replay_opts *opts)
 		}
 
 		if (read_oneliner(&buf, rebase_path_squash_onto(), 0)) {
-			if (get_oid_committish(buf.buf, &opts->squash_onto) < 0) {
+			if (repo_get_oid_committish(the_repository, buf.buf, &opts->squash_onto) < 0) {
 				ret = error(_("unusable squash-onto"));
 				goto done_rebase_i;
 			}
@@ -3226,7 +3227,7 @@ static int rollback_is_safe(void)
 	else
 		die_errno(_("could not read '%s'"), git_path_abort_safety_file());
 
-	if (get_oid("HEAD", &actual_head))
+	if (repo_get_oid(the_repository, "HEAD", &actual_head))
 		oidclr(&actual_head);
 
 	return oideq(&actual_head, &expected_head);
@@ -3537,7 +3538,7 @@ static int intend_to_amend(void)
 	struct object_id head;
 	char *p;
 
-	if (get_oid("HEAD", &head))
+	if (repo_get_oid(the_repository, "HEAD", &head))
 		return error(_("cannot read HEAD"));
 
 	p = oid_to_hex(&head);
@@ -3703,7 +3704,7 @@ static int do_label(struct repository *r, const char *name, int len)
 	if (!transaction) {
 		error("%s", err.buf);
 		ret = -1;
-	} else if (get_oid("HEAD", &head_oid)) {
+	} else if (repo_get_oid(the_repository, "HEAD", &head_oid)) {
 		error(_("could not read HEAD"));
 		ret = -1;
 	} else if (ref_transaction_update(transaction, ref_name.buf, &head_oid,
@@ -4459,7 +4460,7 @@ void create_autostash(struct repository *r, const char *path)
 		if (capture_command(&stash, &buf, GIT_MAX_HEXSZ))
 			die(_("Cannot autostash"));
 		strbuf_trim_trailing_newline(&buf);
-		if (get_oid(buf.buf, &oid))
+		if (repo_get_oid(the_repository, buf.buf, &oid))
 			die(_("Unexpected stash response: '%s'"),
 			    buf.buf);
 		strbuf_reset(&buf);
@@ -4584,7 +4585,7 @@ static int stopped_at_head(struct repository *r)
 	struct commit *commit;
 	struct commit_message message;
 
-	if (get_oid("HEAD", &head) ||
+	if (repo_get_oid(the_repository, "HEAD", &head) ||
 	    !(commit = lookup_commit(r, &head)) ||
 	    parse_commit(commit) || get_message(commit, &message))
 		fprintf(stderr, _("Stopped at HEAD\n"));
@@ -4734,7 +4735,7 @@ static int pick_commits(struct repository *r,
 				 * otherwise we do not.
 				 */
 				if (item->command == TODO_REWORD &&
-				    !get_oid("HEAD", &oid) &&
+				    !repo_get_oid(the_repository, "HEAD", &oid) &&
 				    (oideq(&item->commit->object.oid, &oid) ||
 				     (opts->have_squash_onto &&
 				      oideq(&opts->squash_onto, &oid))))
@@ -4823,7 +4824,7 @@ static int pick_commits(struct repository *r,
 			struct object_id head, orig;
 			int res;
 
-			if (get_oid("HEAD", &head)) {
+			if (repo_get_oid(the_repository, "HEAD", &head)) {
 				res = error(_("cannot read HEAD"));
 cleanup_head_ref:
 				strbuf_release(&head_ref);
@@ -4870,8 +4871,8 @@ static int pick_commits(struct repository *r,
 			log_tree_opt.disable_stdin = 1;
 
 			if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
-			    !get_oid(buf.buf, &orig) &&
-			    !get_oid("HEAD", &head)) {
+			    !repo_get_oid(the_repository, buf.buf, &orig) &&
+			    !repo_get_oid(the_repository, "HEAD", &head)) {
 				diff_tree_oid(&orig, &head, "",
 					      &log_tree_opt.diffopt);
 				log_tree_diff_flush(&log_tree_opt);
@@ -4963,7 +4964,7 @@ static int commit_staged_changes(struct repository *r,
 		struct strbuf rev = STRBUF_INIT;
 		struct object_id head, to_amend;
 
-		if (get_oid("HEAD", &head))
+		if (repo_get_oid(the_repository, "HEAD", &head))
 			return error(_("cannot amend non-existing commit"));
 		if (!read_oneliner(&rev, rebase_path_amend(), 0))
 			return error(_("invalid file: '%s'"), rebase_path_amend());
@@ -5188,7 +5189,7 @@ int sequencer_pick_revisions(struct repository *r,
 		if (!strlen(name))
 			continue;
 
-		if (!get_oid(name, &oid)) {
+		if (!repo_get_oid(the_repository, name, &oid)) {
 			if (!lookup_commit_reference_gently(r, &oid, 1)) {
 				enum object_type type = oid_object_info(r,
 									&oid,
@@ -5231,7 +5232,7 @@ int sequencer_pick_revisions(struct repository *r,
 	if (walk_revs_populate_todo(&todo_list, opts) ||
 			create_seq_dir(r) < 0)
 		return -1;
-	if (get_oid("HEAD", &oid) && (opts->action == REPLAY_REVERT))
+	if (repo_get_oid(the_repository, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
 		return error(_("can't revert as initial commit"));
 	if (save_head(oid_to_hex(&oid)))
 		return -1;
@@ -5363,7 +5364,8 @@ static const char *label_oid(struct object_id *oid, const char *label,
 		strbuf_grow(&state->buf, GIT_MAX_HEXSZ);
 		label = p = state->buf.buf;
 
-		find_unique_abbrev_r(p, oid, default_abbrev);
+		repo_find_unique_abbrev_r(the_repository, p, oid,
+					  default_abbrev);
 
 		/*
 		 * We may need to extend the abbreviated hash so that there is
@@ -6096,7 +6098,8 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
 	struct object_id oid = onto->object.oid;
 	int res;
 
-	find_unique_abbrev_r(shortonto, &oid, DEFAULT_ABBREV);
+	repo_find_unique_abbrev_r(the_repository, shortonto, &oid,
+				  DEFAULT_ABBREV);
 
 	if (buf->len == 0) {
 		struct todo_item *item = append_new_todo(todo_list);
@@ -6372,8 +6375,8 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
 		if (file_exists(git_path_seq_dir()))
 			*whence = FROM_CHERRY_PICK_MULTI;
 		if (file_exists(rebase_path()) &&
-		    !get_oid("REBASE_HEAD", &rebase_head) &&
-		    !get_oid("CHERRY_PICK_HEAD", &cherry_pick_head) &&
+		    !repo_get_oid(the_repository, "REBASE_HEAD", &rebase_head) &&
+		    !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
 		    oideq(&rebase_head, &cherry_pick_head))
 			*whence = FROM_REBASE_PICK;
 		else
diff --git a/submodule-config.c b/submodule-config.c
index 89a7bf0a93d..57972c3e131 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -537,7 +537,7 @@ static int gitmodule_oid_from_commit(const struct object_id *treeish_name,
 	}
 
 	strbuf_addf(rev, "%s:.gitmodules", oid_to_hex(treeish_name));
-	if (get_oid(rev->buf, gitmodules_oid) >= 0)
+	if (repo_get_oid(the_repository, rev->buf, gitmodules_oid) >= 0)
 		ret = 1;
 
 	return ret;
diff --git a/submodule.c b/submodule.c
index 2a057c35b74..f028044e2dc 100644
--- a/submodule.c
+++ b/submodule.c
@@ -66,7 +66,7 @@ int is_writing_gitmodules_ok(void)
 {
 	struct object_id oid;
 	return file_exists(GITMODULES_FILE) ||
-		(get_oid(GITMODULES_INDEX, &oid) < 0 && get_oid(GITMODULES_HEAD, &oid) < 0);
+		(repo_get_oid(the_repository, GITMODULES_INDEX, &oid) < 0 && repo_get_oid(the_repository, GITMODULES_HEAD, &oid) < 0);
 }
 
 /*
@@ -1626,7 +1626,7 @@ get_fetch_task_from_changed(struct submodule_parallel_fetch *spf,
 		if (!task->repo) {
 			strbuf_addf(err, _("Could not access submodule '%s' at commit %s\n"),
 				    cs_data->path,
-				    find_unique_abbrev(cs_data->super_oid, DEFAULT_ABBREV));
+				    repo_find_unique_abbrev(the_repository, cs_data->super_oid, DEFAULT_ABBREV));
 
 			fetch_task_release(task);
 			free(task);
@@ -1637,8 +1637,8 @@ get_fetch_task_from_changed(struct submodule_parallel_fetch *spf,
 			strbuf_addf(err,
 				    _("Fetching submodule %s%s at commit %s\n"),
 				    spf->prefix, task->sub->path,
-				    find_unique_abbrev(cs_data->super_oid,
-						       DEFAULT_ABBREV));
+				    repo_find_unique_abbrev(the_repository, cs_data->super_oid,
+							    DEFAULT_ABBREV));
 
 		spf->changed_count++;
 		/*
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index b1edb92a032..3f8d5761780 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -26,7 +26,8 @@
 
 static const char *short_commit_name(struct commit *commit)
 {
-	return find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV);
+	return repo_find_unique_abbrev(the_repository, &commit->object.oid,
+				       DEFAULT_ABBREV);
 }
 
 static struct commit *peel_committish(const char *name)
@@ -34,10 +35,11 @@ static struct commit *peel_committish(const char *name)
 	struct object *obj;
 	struct object_id oid;
 
-	if (get_oid(name, &oid))
+	if (repo_get_oid(the_repository, name, &oid))
 		return NULL;
 	obj = parse_object(the_repository, &oid);
-	return (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
+	return (struct commit *)repo_peel_to_type(the_repository, name, 0, obj,
+						  OBJ_COMMIT);
 }
 
 static char *get_author(const char *message)
@@ -120,7 +122,7 @@ int cmd__fast_rebase(int argc, const char **argv)
 	strbuf_addf(&branch_name, "refs/heads/%s", argv[4]);
 
 	/* Sanity check */
-	if (get_oid("HEAD", &head))
+	if (repo_get_oid(the_repository, "HEAD", &head))
 		die(_("Cannot read HEAD"));
 	assert(oideq(&onto->object.oid, &head));
 
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 04bc2563f3e..f2ae92ca2c8 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -10,9 +10,9 @@ int cmd__match_trees(int ac, const char **av)
 
 	setup_git_directory();
 
-	if (get_oid(av[1], &hash1))
+	if (repo_get_oid(the_repository, av[1], &hash1))
 		die("cannot parse %s as an object name", av[1]);
-	if (get_oid(av[2], &hash2))
+	if (repo_get_oid(the_repository, av[2], &hash2))
 		die("cannot parse %s as an object name", av[2]);
 	one = parse_tree_indirect(&hash1);
 	if (!one)
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index 883d40efd45..8c9b6e7f695 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -50,7 +50,7 @@ int cmd__oidmap(int argc, const char **argv)
 
 		if (!strcmp("put", cmd) && p1 && p2) {
 
-			if (get_oid(p1, &oid)) {
+			if (repo_get_oid(the_repository, p1, &oid)) {
 				printf("Unknown oid: %s\n", p1);
 				continue;
 			}
@@ -68,7 +68,7 @@ int cmd__oidmap(int argc, const char **argv)
 
 		} else if (!strcmp("get", cmd) && p1) {
 
-			if (get_oid(p1, &oid)) {
+			if (repo_get_oid(the_repository, p1, &oid)) {
 				printf("Unknown oid: %s\n", p1);
 				continue;
 			}
@@ -81,7 +81,7 @@ int cmd__oidmap(int argc, const char **argv)
 
 		} else if (!strcmp("remove", cmd) && p1) {
 
-			if (get_oid(p1, &oid)) {
+			if (repo_get_oid(the_repository, p1, &oid)) {
 				printf("Unknown oid: %s\n", p1);
 				continue;
 			}
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index de8f26639d4..afb9bb3189f 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -58,7 +58,7 @@ int cmd__reach(int ac, const char **av)
 		if (buf.len < 3)
 			continue;
 
-		if (get_oid_committish(buf.buf + 2, &oid))
+		if (repo_get_oid_committish(the_repository, buf.buf + 2, &oid))
 			die("failed to resolve %s", buf.buf + 2);
 
 		orig = parse_object(r, &oid);
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 22a41c40926..91c82d4159d 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -42,7 +42,7 @@ int cmd__submodule_config(int argc, const char **argv)
 
 		if (commit[0] == '\0')
 			oidclr(&commit_oid);
-		else if (get_oid(commit, &commit_oid) < 0)
+		else if (repo_get_oid(the_repository, commit, &commit_oid) < 0)
 			die_usage(argc, argv, "Commit not found.");
 
 		if (lookup_name) {
diff --git a/tag.c b/tag.c
index 18b718cca66..85c348ad824 100644
--- a/tag.c
+++ b/tag.c
@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
 		return error("%s: cannot verify a non-tag object of type %s.",
 				name_to_report ?
 				name_to_report :
-				find_unique_abbrev(oid, DEFAULT_ABBREV),
+				repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
 				type_name(type));
 
 	buf = read_object_file(oid, &type, &size);
@@ -60,7 +60,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
 		return error("%s: unable to read file.",
 				name_to_report ?
 				name_to_report :
-				find_unique_abbrev(oid, DEFAULT_ABBREV));
+				repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
 
 	ret = run_gpg_verify(buf, size, flags);
 
diff --git a/transport-helper.c b/transport-helper.c
index 82ac63e2609..1939763ab5d 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1082,7 +1082,7 @@ static int push_refs_with_export(struct transport *transport,
 		struct object_id oid;
 
 		private = apply_refspecs(&data->rs, ref->name);
-		if (private && !get_oid(private, &oid)) {
+		if (private && !repo_get_oid(the_repository, private, &oid)) {
 			strbuf_addf(&buf, "^%s", private);
 			string_list_append_nodup(&revlist_args,
 						 strbuf_detach(&buf, NULL));
diff --git a/transport.c b/transport.c
index 906dbad5a08..dbbfeb8d010 100644
--- a/transport.c
+++ b/transport.c
@@ -779,7 +779,8 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count,
 static int measure_abbrev(const struct object_id *oid, int sofar)
 {
 	char hex[GIT_MAX_HEXSZ + 1];
-	int w = find_unique_abbrev_r(hex, oid, DEFAULT_ABBREV);
+	int w = repo_find_unique_abbrev_r(the_repository, hex, oid,
+					  DEFAULT_ABBREV);
 
 	return (w < sofar) ? sofar : w;
 }
diff --git a/wt-status.c b/wt-status.c
index 90525bd26fd..0f0b92eece4 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1338,7 +1338,7 @@ static void abbrev_oid_in_line(struct strbuf *line)
 		 * it after abbreviation.
 		 */
 		strbuf_trim(split[1]);
-		if (!get_oid(split[1]->buf, &oid)) {
+		if (!repo_get_oid(the_repository, split[1]->buf, &oid)) {
 			strbuf_reset(split[1]);
 			strbuf_add_unique_abbrev(split[1], &oid,
 						 DEFAULT_ABBREV);
@@ -1504,8 +1504,8 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
 	else
 		status_printf_ln(s, color,
 			_("You are currently cherry-picking commit %s."),
-			find_unique_abbrev(&s->state.cherry_pick_head_oid,
-					   DEFAULT_ABBREV));
+			repo_find_unique_abbrev(the_repository, &s->state.cherry_pick_head_oid,
+						DEFAULT_ABBREV));
 
 	if (s->hints) {
 		if (has_unmerged(s))
@@ -1534,8 +1534,8 @@ static void show_revert_in_progress(struct wt_status *s,
 	else
 		status_printf_ln(s, color,
 			_("You are currently reverting commit %s."),
-			find_unique_abbrev(&s->state.revert_head_oid,
-					   DEFAULT_ABBREV));
+			repo_find_unique_abbrev(the_repository, &s->state.revert_head_oid,
+						DEFAULT_ABBREV));
 	if (s->hints) {
 		if (has_unmerged(s))
 			status_printf_ln(s, color,
@@ -1677,9 +1677,9 @@ static void wt_status_get_detached_from(struct repository *r,
 		state->detached_from = xstrdup(from);
 	} else
 		state->detached_from =
-			xstrdup(find_unique_abbrev(&cb.noid, DEFAULT_ABBREV));
+			xstrdup(repo_find_unique_abbrev(the_repository, &cb.noid, DEFAULT_ABBREV));
 	oidcpy(&state->detached_oid, &cb.noid);
-	state->detached_at = !get_oid("HEAD", &oid) &&
+	state->detached_at = !repo_get_oid(the_repository, "HEAD", &oid) &&
 			     oideq(&oid, &state->detached_oid);
 
 	free(ref);
@@ -1770,13 +1770,13 @@ void wt_status_get_state(struct repository *r,
 	} else if (wt_status_check_rebase(NULL, state)) {
 		;		/* all set */
 	} else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
-		   !get_oid("CHERRY_PICK_HEAD", &oid)) {
+		   !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &oid)) {
 		state->cherry_pick_in_progress = 1;
 		oidcpy(&state->cherry_pick_head_oid, &oid);
 	}
 	wt_status_check_bisect(NULL, state);
 	if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") &&
-	    !get_oid("REVERT_HEAD", &oid)) {
+	    !repo_get_oid(the_repository, "REVERT_HEAD", &oid)) {
 		state->revert_in_progress = 1;
 		oidcpy(&state->revert_head_oid, &oid);
 	}
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 06/17] cocci: apply the "commit-reach.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (4 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 05/17] cocci: apply the "cache.h" part of "the_repository.pending" Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 07/17] cocci: apply the "commit.h" " Ævar Arnfjörð Bjarmason
                     ` (12 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"commit-reach.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 bisect.c                                        |  3 ++-
 builtin/branch.c                                |  5 +++--
 builtin/fast-import.c                           |  2 +-
 builtin/fetch.c                                 |  3 ++-
 builtin/log.c                                   | 10 +++++++---
 builtin/merge-base.c                            |  5 +++--
 builtin/merge-tree.c                            |  3 ++-
 builtin/merge.c                                 |  7 +++++--
 builtin/rebase.c                                |  5 +++--
 builtin/receive-pack.c                          |  2 +-
 builtin/rev-parse.c                             |  2 +-
 commit-reach.c                                  |  3 ++-
 commit-reach.h                                  |  9 ---------
 commit.c                                        |  3 ++-
 contrib/coccinelle/the_repository.cocci         | 16 ++++++++++++++++
 contrib/coccinelle/the_repository.pending.cocci | 16 ----------------
 http-push.c                                     |  2 +-
 log-tree.c                                      |  2 +-
 merge-ort.c                                     |  2 +-
 merge-recursive.c                               |  2 +-
 notes-merge.c                                   |  2 +-
 remote.c                                        |  2 +-
 revision.c                                      |  4 ++--
 sequencer.c                                     |  3 ++-
 shallow.c                                       |  9 +++++----
 t/helper/test-reach.c                           | 10 +++++++---
 26 files changed, 72 insertions(+), 60 deletions(-)

diff --git a/bisect.c b/bisect.c
index 1409150c5c3..b1639a9de7f 100644
--- a/bisect.c
+++ b/bisect.c
@@ -847,7 +847,8 @@ static enum bisect_error check_merge_bases(int rev_nr, struct commit **rev, int
 	enum bisect_error res = BISECT_OK;
 	struct commit_list *result;
 
-	result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
+	result = repo_get_merge_bases_many(the_repository, rev[0], rev_nr - 1,
+					   rev + 1);
 
 	for (; result; result = result->next) {
 		const struct object_id *mb = &result->item->object.oid;
diff --git a/builtin/branch.c b/builtin/branch.c
index 968ea03c059..bbcfb34b3c6 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -150,7 +150,8 @@ static int branch_merged(int kind, const char *name,
 	if (!reference_rev)
 		reference_rev = head_rev;
 
-	merged = reference_rev ? in_merge_bases(rev, reference_rev) : 0;
+	merged = reference_rev ? repo_in_merge_bases(the_repository, rev,
+						     reference_rev) : 0;
 
 	/*
 	 * After the safety valve is fully redefined to "check with
@@ -160,7 +161,7 @@ static int branch_merged(int kind, const char *name,
 	 * a gentle reminder is in order.
 	 */
 	if ((head_rev != reference_rev) &&
-	    (head_rev ? in_merge_bases(rev, head_rev) : 0) != merged) {
+	    (head_rev ? repo_in_merge_bases(the_repository, rev, head_rev) : 0) != merged) {
 		if (merged)
 			warning(_("deleting branch '%s' that has been merged to\n"
 				"         '%s', but not yet merged to HEAD."),
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 7faedc9aa44..e4566490d91 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -1626,7 +1626,7 @@ static int update_branch(struct branch *b)
 		if (!old_cmit || !new_cmit)
 			return error("Branch %s is missing commits.", b->name);
 
-		if (!in_merge_bases(old_cmit, new_cmit)) {
+		if (!repo_in_merge_bases(the_repository, old_cmit, new_cmit)) {
 			warning("Not updating %s"
 				" (new tip %s does not contain %s)",
 				b->name, oid_to_hex(&b->oid),
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 6bab662829f..16dc2a33cac 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -966,7 +966,8 @@ static int update_local_ref(struct ref *ref,
 
 	if (fetch_show_forced_updates) {
 		uint64_t t_before = getnanotime();
-		fast_forward = in_merge_bases(current, updated);
+		fast_forward = repo_in_merge_bases(the_repository, current,
+						   updated);
 		forced_updates_ms += (getnanotime() - t_before) / 1000000;
 	} else {
 		fast_forward = 1;
diff --git a/builtin/log.c b/builtin/log.c
index 1e7bbedf5d2..e16bda87ba3 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1663,7 +1663,9 @@ static struct commit *get_base_commit(const char *base_commit,
 					return NULL;
 			}
 			commit = lookup_commit_or_die(&oid, "upstream base");
-			base_list = get_merge_bases_many(commit, total, list);
+			base_list = repo_get_merge_bases_many(the_repository,
+							      commit, total,
+							      list);
 			/* There should be one and only one merge base. */
 			if (!base_list || base_list->next) {
 				if (die_on_failure) {
@@ -1697,7 +1699,9 @@ static struct commit *get_base_commit(const char *base_commit,
 	while (rev_nr > 1) {
 		for (i = 0; i < rev_nr / 2; i++) {
 			struct commit_list *merge_base;
-			merge_base = get_merge_bases(rev[2 * i], rev[2 * i + 1]);
+			merge_base = repo_get_merge_bases(the_repository,
+							  rev[2 * i],
+							  rev[2 * i + 1]);
 			if (!merge_base || merge_base->next) {
 				if (die_on_failure) {
 					die(_("failed to find exact merge base"));
@@ -1715,7 +1719,7 @@ static struct commit *get_base_commit(const char *base_commit,
 		rev_nr = DIV_ROUND_UP(rev_nr, 2);
 	}
 
-	if (!in_merge_bases(base, rev[0])) {
+	if (!repo_in_merge_bases(the_repository, base, rev[0])) {
 		if (die_on_failure) {
 			die(_("base commit should be the ancestor of revision list"));
 		} else {
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 5b0ed0d2738..671e424c26c 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -14,7 +14,8 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
 {
 	struct commit_list *result, *r;
 
-	result = get_merge_bases_many_dirty(rev[0], rev_nr - 1, rev + 1);
+	result = repo_get_merge_bases_many_dirty(the_repository, rev[0],
+						 rev_nr - 1, rev + 1);
 
 	if (!result)
 		return 1;
@@ -106,7 +107,7 @@ static int handle_is_ancestor(int argc, const char **argv)
 		die("--is-ancestor takes exactly two commits");
 	one = get_commit_reference(argv[0]);
 	two = get_commit_reference(argv[1]);
-	if (in_merge_bases(one, two))
+	if (repo_in_merge_bases(the_repository, one, two))
 		return 0;
 	else
 		return 1;
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index e7825181648..234db21548b 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -453,7 +453,8 @@ static int real_merge(struct merge_tree_options *o,
 		 * Get the merge bases, in reverse order; see comment above
 		 * merge_incore_recursive in merge-ort.h
 		 */
-		merge_bases = get_merge_bases(parent1, parent2);
+		merge_bases = repo_get_merge_bases(the_repository, parent1,
+						   parent2);
 		if (!merge_bases && !o->allow_unrelated_histories)
 			die(_("refusing to merge unrelated histories"));
 		merge_bases = reverse_commit_list(merge_bases);
diff --git a/builtin/merge.c b/builtin/merge.c
index 6a0519c39db..5dfc650a7bc 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1530,7 +1530,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 	if (!remoteheads)
 		; /* already up-to-date */
 	else if (!remoteheads->next)
-		common = get_merge_bases(head_commit, remoteheads->item);
+		common = repo_get_merge_bases(the_repository, head_commit,
+					      remoteheads->item);
 	else {
 		struct commit_list *list = remoteheads;
 		commit_list_insert(head_commit, &list);
@@ -1648,7 +1649,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 			 * merge_bases again, otherwise "git merge HEAD^
 			 * HEAD^^" would be missed.
 			 */
-			common_one = get_merge_bases(head_commit, j->item);
+			common_one = repo_get_merge_bases(the_repository,
+							  head_commit,
+							  j->item);
 			if (!oideq(&common_one->item->object.oid, &j->item->object.oid)) {
 				up_to_date = 0;
 				break;
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 55ecc2d5f33..6390dd2fcc1 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -883,7 +883,7 @@ static int can_fast_forward(struct commit *onto, struct commit *upstream,
 	if (!upstream)
 		goto done;
 
-	merge_bases = get_merge_bases(upstream, head);
+	merge_bases = repo_get_merge_bases(the_repository, upstream, head);
 	if (!merge_bases || merge_bases->next)
 		goto done;
 
@@ -902,7 +902,8 @@ static void fill_branch_base(struct rebase_options *options,
 {
 	struct commit_list *merge_bases = NULL;
 
-	merge_bases = get_merge_bases(options->onto, options->orig_head);
+	merge_bases = repo_get_merge_bases(the_repository, options->onto,
+					   options->orig_head);
 	if (!merge_bases || merge_bases->next)
 		oidcpy(branch_base, null_oid());
 	else
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index c6ab537a44f..e2b7202b04c 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1547,7 +1547,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
 		}
 		old_commit = (struct commit *)old_object;
 		new_commit = (struct commit *)new_object;
-		if (!in_merge_bases(old_commit, new_commit)) {
+		if (!repo_in_merge_bases(the_repository, old_commit, new_commit)) {
 			rp_error("denying non-fast-forward %s"
 				 " (you should pull first)", name);
 			ret = "non-fast-forward";
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 5db9d6ad518..4969815ca79 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -294,7 +294,7 @@ static int try_difference(const char *arg)
 				*dotdot = '.';
 				return 0;
 			}
-			exclude = get_merge_bases(a, b);
+			exclude = repo_get_merge_bases(the_repository, a, b);
 			while (exclude) {
 				struct commit *commit = pop_commit(&exclude);
 				show_rev(REVERSED, &commit->object.oid, NULL);
diff --git a/commit-reach.c b/commit-reach.c
index 7c0c39fd286..4a2ea9ca1f7 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -164,7 +164,8 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)
 
 		for (j = ret; j; j = j->next) {
 			struct commit_list *bases;
-			bases = get_merge_bases(i->item, j->item);
+			bases = repo_get_merge_bases(the_repository, i->item,
+						     j->item);
 			if (!new_commits)
 				new_commits = bases;
 			else
diff --git a/commit-reach.h b/commit-reach.h
index 148b56fea50..94a96e03299 100644
--- a/commit-reach.h
+++ b/commit-reach.h
@@ -19,11 +19,6 @@ struct commit_list *repo_get_merge_bases_many(struct repository *r,
 struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,
 						    struct commit *one, int n,
 						    struct commit **twos);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define get_merge_bases(r1, r2)           repo_get_merge_bases(the_repository, r1, r2)
-#define get_merge_bases_many(one, n, two) repo_get_merge_bases_many(the_repository, one, n, two)
-#define get_merge_bases_many_dirty(one, n, twos) repo_get_merge_bases_many_dirty(the_repository, one, n, twos)
-#endif
 
 struct commit_list *get_octopus_merge_bases(struct commit_list *in);
 
@@ -36,10 +31,6 @@ int repo_in_merge_bases(struct repository *r,
 int repo_in_merge_bases_many(struct repository *r,
 			     struct commit *commit,
 			     int nr_reference, struct commit **reference);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define in_merge_bases(c1, c2) repo_in_merge_bases(the_repository, c1, c2)
-#define in_merge_bases_many(c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs)
-#endif
 
 /*
  * Takes a list of commits and returns a new list where those
diff --git a/commit.c b/commit.c
index c0b1db3d3e1..aa2e58ea207 100644
--- a/commit.c
+++ b/commit.c
@@ -1017,7 +1017,8 @@ struct commit *get_fork_point(const char *refname, struct commit *commit)
 	for (i = 0; i < revs.nr; i++)
 		revs.commit[i]->object.flags &= ~TMP_MARK;
 
-	bases = get_merge_bases_many(commit, revs.nr, revs.commit);
+	bases = repo_get_merge_bases_many(the_repository, commit, revs.nr,
+					  revs.commit);
 
 	/*
 	 * There should be one and only one merge base, when we found
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index dcdba314fc2..1ab63f0196b 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -38,6 +38,22 @@
 |
 - peel_to_type
 + repo_peel_to_type
+// commit-reach.h
+|
+- get_merge_bases
++ repo_get_merge_bases
+|
+- get_merge_bases_many
++ repo_get_merge_bases_many
+|
+- get_merge_bases_many_dirty
++ repo_get_merge_bases_many_dirty
+|
+- in_merge_bases
++ repo_in_merge_bases
+|
+- in_merge_bases_many
++ repo_in_merge_bases_many
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 2d200ab83e7..e9209fc0cc4 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,23 +5,7 @@
 @@
 @@
 (
-// commit-reach.h
-- get_merge_bases
-+ repo_get_merge_bases
-|
-- get_merge_bases_many
-+ repo_get_merge_bases_many
-|
-- get_merge_bases_many_dirty
-+ repo_get_merge_bases_many_dirty
-|
-- in_merge_bases
-+ repo_in_merge_bases
-|
-- in_merge_bases_many
-+ repo_in_merge_bases_many
 // commit.h
-|
 - parse_commit_internal
 + repo_parse_commit_internal
 |
diff --git a/http-push.c b/http-push.c
index 88aa045ecba..2693d73cf9a 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1571,7 +1571,7 @@ static int verify_merge_base(struct object_id *head_oid, struct ref *remote)
 	struct commit *branch = lookup_commit_or_die(&remote->old_oid,
 						     remote->name);
 
-	return in_merge_bases(branch, head);
+	return repo_in_merge_bases(the_repository, branch, head);
 }
 
 static int delete_remote_branch(const char *pattern, int force)
diff --git a/log-tree.c b/log-tree.c
index 49411c5c6a6..97d374c76d6 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -996,7 +996,7 @@ static int do_remerge_diff(struct rev_info *opt,
 	/* Parse the relevant commits and get the merge bases */
 	parse_commit_or_die(parent1);
 	parse_commit_or_die(parent2);
-	bases = get_merge_bases(parent1, parent2);
+	bases = repo_get_merge_bases(the_repository, parent1, parent2);
 
 	/* Re-merge the parents */
 	merge_incore_recursive(&o, bases, parent1, parent2, &res);
diff --git a/merge-ort.c b/merge-ort.c
index 4c5be8ed910..186e26d90a0 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -5018,7 +5018,7 @@ static void merge_ort_internal(struct merge_options *opt,
 	struct strbuf merge_base_abbrev = STRBUF_INIT;
 
 	if (!merge_bases) {
-		merge_bases = get_merge_bases(h1, h2);
+		merge_bases = repo_get_merge_bases(the_repository, h1, h2);
 		/* See merge-ort.h:merge_incore_recursive() declaration NOTE */
 		merge_bases = reverse_commit_list(merge_bases);
 	}
diff --git a/merge-recursive.c b/merge-recursive.c
index 89731f40908..cfb201d682b 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3592,7 +3592,7 @@ static int merge_recursive_internal(struct merge_options *opt,
 	}
 
 	if (!merge_bases) {
-		merge_bases = get_merge_bases(h1, h2);
+		merge_bases = repo_get_merge_bases(the_repository, h1, h2);
 		merge_bases = reverse_commit_list(merge_bases);
 	}
 
diff --git a/notes-merge.c b/notes-merge.c
index f9137ec768f..699edcfe105 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -601,7 +601,7 @@ int notes_merge(struct notes_merge_options *o,
 	assert(local && remote);
 
 	/* Find merge bases */
-	bases = get_merge_bases(local, remote);
+	bases = repo_get_merge_bases(the_repository, local, remote);
 	if (!bases) {
 		base_oid = null_oid();
 		base_tree_oid = the_hash_algo->empty_tree;
diff --git a/remote.c b/remote.c
index a0f22c8751e..37cb5213795 100644
--- a/remote.c
+++ b/remote.c
@@ -2664,7 +2664,7 @@ static int is_reachable_in_reflog(const char *local, const struct ref *remote)
 		if (MERGE_BASES_BATCH_SIZE < size)
 			size = MERGE_BASES_BATCH_SIZE;
 
-		if ((ret = in_merge_bases_many(commit, size, chunk)))
+		if ((ret = repo_in_merge_bases_many(the_repository, commit, size, chunk)))
 			break;
 	}
 
diff --git a/revision.c b/revision.c
index e08f697c47c..b6a1b47c306 100644
--- a/revision.c
+++ b/revision.c
@@ -1960,7 +1960,7 @@ static void prepare_show_merge(struct rev_info *revs)
 	other = lookup_commit_or_die(&oid, "MERGE_HEAD");
 	add_pending_object(revs, &head->object, "HEAD");
 	add_pending_object(revs, &other->object, "MERGE_HEAD");
-	bases = get_merge_bases(head, other);
+	bases = repo_get_merge_bases(the_repository, head, other);
 	add_rev_cmdline_list(revs, bases, REV_CMD_MERGE_BASE, UNINTERESTING | BOTTOM);
 	add_pending_commit_list(revs, bases, UNINTERESTING | BOTTOM);
 	free_commit_list(bases);
@@ -2055,7 +2055,7 @@ static int handle_dotdot_1(const char *arg, char *dotdot,
 		if (!a || !b)
 			return dotdot_missing(arg, dotdot, revs, symmetric);
 
-		exclude = get_merge_bases(a, b);
+		exclude = repo_get_merge_bases(the_repository, a, b);
 		add_rev_cmdline_list(revs, exclude, REV_CMD_MERGE_BASE,
 				     flags_exclude);
 		add_pending_commit_list(revs, exclude, flags_exclude);
diff --git a/sequencer.c b/sequencer.c
index d73827632d8..3578dc25510 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4105,7 +4105,8 @@ static int do_merge(struct repository *r,
 	}
 
 	merge_commit = to_merge->item;
-	bases = get_merge_bases(head_commit, merge_commit);
+	bases = repo_get_merge_bases(the_repository, head_commit,
+				     merge_commit);
 	if (bases && oideq(&merge_commit->object.oid,
 			   &bases->item->object.oid)) {
 		ret = 0;
diff --git a/shallow.c b/shallow.c
index 1cbb05ba0e4..db9856ef8ad 100644
--- a/shallow.c
+++ b/shallow.c
@@ -793,7 +793,7 @@ static void post_assign_shallow(struct shallow_info *info,
 		for (j = 0; j < bitmap_nr; j++)
 			if (bitmap[0][j] &&
 			    /* Step 7, reachability test at commit level */
-			    !in_merge_bases_many(c, ca.nr, ca.commits)) {
+			    !repo_in_merge_bases_many(the_repository, c, ca.nr, ca.commits)) {
 				update_refstatus(ref_status, info->ref->nr, *bitmap);
 				dst++;
 				break;
@@ -821,9 +821,10 @@ int delayed_reachability_test(struct shallow_info *si, int c)
 			si->nr_commits = ca.nr;
 		}
 
-		si->reachable[c] = in_merge_bases_many(commit,
-						       si->nr_commits,
-						       si->commits);
+		si->reachable[c] = repo_in_merge_bases_many(the_repository,
+							    commit,
+							    si->nr_commits,
+							    si->commits);
 		si->need_reachability_test[c] = 0;
 	}
 	return si->reachable[c];
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index afb9bb3189f..d08c3ffa3ba 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -107,13 +107,17 @@ int cmd__reach(int ac, const char **av)
 	if (!strcmp(av[1], "ref_newer"))
 		printf("%s(A,B):%d\n", av[1], ref_newer(&oid_A, &oid_B));
 	else if (!strcmp(av[1], "in_merge_bases"))
-		printf("%s(A,B):%d\n", av[1], in_merge_bases(A, B));
+		printf("%s(A,B):%d\n", av[1],
+		       repo_in_merge_bases(the_repository, A, B));
 	else if (!strcmp(av[1], "in_merge_bases_many"))
-		printf("%s(A,X):%d\n", av[1], in_merge_bases_many(A, X_nr, X_array));
+		printf("%s(A,X):%d\n", av[1],
+		       repo_in_merge_bases_many(the_repository, A, X_nr, X_array));
 	else if (!strcmp(av[1], "is_descendant_of"))
 		printf("%s(A,X):%d\n", av[1], repo_is_descendant_of(r, A, X));
 	else if (!strcmp(av[1], "get_merge_bases_many")) {
-		struct commit_list *list = get_merge_bases_many(A, X_nr, X_array);
+		struct commit_list *list = repo_get_merge_bases_many(the_repository,
+								     A, X_nr,
+								     X_array);
 		printf("%s(A,X):\n", av[1]);
 		print_sorted_commit_ids(list);
 	} else if (!strcmp(av[1], "reduce_heads")) {
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 07/17] cocci: apply the "commit.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (5 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 06/17] cocci: apply the "commit-reach.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 08/17] cocci: apply the "diff.h" " Ævar Arnfjörð Bjarmason
                     ` (11 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"commit.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 blame.c                                       |  4 +-
 builtin/am.c                                  |  7 +-
 builtin/blame.c                               |  6 +-
 builtin/checkout.c                            | 13 +--
 builtin/commit.c                              |  8 +-
 builtin/describe.c                            |  4 +-
 builtin/diff.c                                |  3 +-
 builtin/fast-export.c                         |  4 +-
 builtin/gc.c                                  |  4 +-
 builtin/log.c                                 |  5 +-
 builtin/merge-tree.c                          |  6 +-
 builtin/merge.c                               |  3 +-
 builtin/name-rev.c                            |  4 +-
 builtin/notes.c                               |  2 +-
 builtin/rebase.c                              |  2 +-
 builtin/replace.c                             |  4 +-
 builtin/shortlog.c                            |  5 +-
 builtin/show-branch.c                         |  4 +-
 commit-graph.c                                |  2 +-
 commit-reach.c                                | 16 ++--
 commit.c                                      | 25 +++---
 commit.h                                      | 18 ----
 contrib/coccinelle/the_repository.cocci       | 19 +++++
 .../coccinelle/the_repository.pending.cocci   | 19 -----
 delta-islands.c                               |  5 +-
 fmt-merge-msg.c                               |  5 +-
 fsck.c                                        |  4 +-
 http-push.c                                   |  3 +-
 list-objects.c                                | 18 ++--
 merge-recursive.c                             |  2 +-
 negotiator/default.c                          |  6 +-
 negotiator/skipping.c                         |  2 +-
 notes-merge.c                                 |  5 +-
 notes-utils.c                                 |  2 +-
 object-name.c                                 |  8 +-
 pack-bitmap-write.c                           |  3 +-
 pretty.c                                      |  5 +-
 reflog.c                                      |  2 +-
 revision.c                                    | 12 +--
 sequencer.c                                   | 82 +++++++++++--------
 shallow.c                                     |  4 +-
 t/helper/test-fast-rebase.c                   |  9 +-
 tree.c                                        |  2 +-
 walker.c                                      |  4 +-
 44 files changed, 196 insertions(+), 174 deletions(-)

diff --git a/blame.c b/blame.c
index e45d8a3bf92..0f2751de83b 100644
--- a/blame.c
+++ b/blame.c
@@ -2430,7 +2430,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
 
 			if (sg_origin[i])
 				continue;
-			if (parse_commit(p))
+			if (repo_parse_commit(the_repository, p))
 				continue;
 			porigin = find(sb->repo, p, origin, sb->bloom_data);
 			if (!porigin)
@@ -2593,7 +2593,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)
 		 * so hold onto it in the meantime.
 		 */
 		blame_origin_incref(suspect);
-		parse_commit(commit);
+		repo_parse_commit(the_repository, commit);
 		if (sb->reverse ||
 		    (!(commit->object.flags & UNINTERESTING) &&
 		     !(revs->max_age != -1 && commit->date < revs->max_age)))
diff --git a/builtin/am.c b/builtin/am.c
index 775beac2a92..d89660d138d 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1330,7 +1330,8 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
 	size_t ident_len;
 	struct ident_split id;
 
-	buffer = logmsg_reencode(commit, NULL, get_commit_output_encoding());
+	buffer = repo_logmsg_reencode(the_repository, commit, NULL,
+				      get_commit_output_encoding());
 
 	ident_line = find_commit_header(buffer, "author", &ident_len);
 	if (!ident_line)
@@ -1362,7 +1363,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
 		die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid));
 	state->msg = xstrdup(msg + 2);
 	state->msg_len = strlen(state->msg);
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
 /**
@@ -1405,7 +1406,7 @@ static void write_index_patch(const struct am_state *state)
 
 	if (!repo_get_oid(the_repository, "HEAD", &head)) {
 		struct commit *commit = lookup_commit_or_die(&head, "HEAD");
-		tree = get_commit_tree(commit);
+		tree = repo_get_commit_tree(the_repository, commit);
 	} else
 		tree = lookup_tree(the_repository,
 				   the_repository->hash_algo->empty_tree);
diff --git a/builtin/blame.c b/builtin/blame.c
index 6c266019ebb..7f92f9c1d39 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -201,13 +201,13 @@ static void get_commit_info(struct commit *commit,
 	const char *message;
 
 	encoding = get_log_output_encoding();
-	message = logmsg_reencode(commit, NULL, encoding);
+	message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
 	get_ac_line(message, "\nauthor ",
 		    &ret->author, &ret->author_mail,
 		    &ret->author_time, &ret->author_tz);
 
 	if (!detailed) {
-		unuse_commit_buffer(commit, message);
+		repo_unuse_commit_buffer(the_repository, commit, message);
 		return;
 	}
 
@@ -221,7 +221,7 @@ static void get_commit_info(struct commit *commit,
 	else
 		strbuf_addf(&ret->summary, "(%s)", oid_to_hex(&commit->object.oid));
 
-	unuse_commit_buffer(commit, message);
+	repo_unuse_commit_buffer(the_repository, commit, message);
 }
 
 /*
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 18f3fc76ced..ad6d5304b64 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -654,7 +654,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)
 {
 	struct strbuf sb = STRBUF_INIT;
 
-	if (!parse_commit(commit))
+	if (!repo_parse_commit(the_repository, commit))
 		pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
 	if (print_sha1_ellipsis()) {
 		fprintf(stderr, "%s %s... %s\n", msg,
@@ -769,7 +769,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
 			BUG("'switch --orphan' should never accept a commit as starting point");
 		new_tree = parse_tree_indirect(the_hash_algo->empty_tree);
 	} else
-		new_tree = get_commit_tree(new_branch_info->commit);
+		new_tree = repo_get_commit_tree(the_repository,
+						new_branch_info->commit);
 	if (opts->discard_changes) {
 		ret = reset_tree(new_tree, opts, 1, writeout_error, new_branch_info);
 		if (ret)
@@ -831,7 +832,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
 			 */
 			if (!old_branch_info->commit)
 				return 1;
-			old_tree = get_commit_tree(old_branch_info->commit);
+			old_tree = repo_get_commit_tree(the_repository,
+							old_branch_info->commit);
 
 			if (repo_index_has_changes(the_repository, old_tree, &sb))
 				die(_("cannot continue with staged changes in "
@@ -1020,7 +1022,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
 	strbuf_addstr(sb, "  ");
 	strbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);
 	strbuf_addch(sb, ' ');
-	if (!parse_commit(commit))
+	if (!repo_parse_commit(the_repository, commit))
 		pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
 	strbuf_addch(sb, '\n');
 }
@@ -1220,7 +1222,8 @@ static void setup_new_branch_info_and_source_tree(
 		*source_tree = parse_tree_indirect(rev);
 	} else {
 		parse_commit_or_die(new_branch_info->commit);
-		*source_tree = get_commit_tree(new_branch_info->commit);
+		*source_tree = repo_get_commit_tree(the_repository,
+						    new_branch_info->commit);
 	}
 }
 
diff --git a/builtin/commit.c b/builtin/commit.c
index 95bca976a58..c64fc50e923 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -712,7 +712,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
 {
 	const char *buffer, *subject, *fmt;
 
-	buffer = get_commit_buffer(commit, NULL);
+	buffer = repo_get_commit_buffer(the_repository, commit, NULL);
 	find_commit_subject(buffer, &subject);
 	/*
 	 * If we amend the 'amend!' commit then we don't want to
@@ -720,7 +720,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
 	 */
 	fmt = starts_with(subject, "amend!") ? "%b" : "%B";
 	format_commit_message(commit, fmt, sb, ctx);
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
 static int prepare_to_commit(const char *index_file, const char *prefix,
@@ -1183,7 +1183,7 @@ static const char *read_commit_message(const char *name)
 	if (!commit)
 		die(_("could not lookup commit %s"), name);
 	out_enc = get_commit_output_encoding();
-	return logmsg_reencode(commit, NULL, out_enc);
+	return repo_logmsg_reencode(the_repository, commit, NULL, out_enc);
 }
 
 /*
@@ -1714,7 +1714,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		current_head = NULL;
 	else {
 		current_head = lookup_commit_or_die(&oid, "HEAD");
-		if (parse_commit(current_head))
+		if (repo_parse_commit(the_repository, current_head))
 			die(_("could not parse HEAD commit"));
 	}
 	verbose = -1; /* unspecified */
diff --git a/builtin/describe.c b/builtin/describe.c
index de3743e803a..3e5595e0ed3 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -262,7 +262,7 @@ static unsigned long finish_depth_computation(
 			best->depth++;
 		while (parents) {
 			struct commit *p = parents->item;
-			parse_commit(p);
+			repo_parse_commit(the_repository, p);
 			if (!(p->object.flags & SEEN))
 				commit_list_insert_by_date(p, list);
 			p->object.flags |= c->object.flags;
@@ -405,7 +405,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
 		}
 		while (parents) {
 			struct commit *p = parents->item;
-			parse_commit(p);
+			repo_parse_commit(the_repository, p);
 			if (!(p->object.flags & SEEN))
 				commit_list_insert_by_date(p, &list);
 			p->object.flags |= c->object.flags;
diff --git a/builtin/diff.c b/builtin/diff.c
index 26f1e532c66..1091c377af7 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -548,7 +548,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 		if (!obj)
 			die(_("invalid object '%s' given."), name);
 		if (obj->type == OBJ_COMMIT)
-			obj = &get_commit_tree(((struct commit *)obj))->object;
+			obj = &repo_get_commit_tree(the_repository,
+						    ((struct commit *)obj))->object;
 
 		if (obj->type == OBJ_TREE) {
 			if (sdiff.skip && bitmap_get(sdiff.skip, i))
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 78493c6d2bf..fc5859dc9fa 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -619,7 +619,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
 	rev->diffopt.output_format = DIFF_FORMAT_CALLBACK;
 
 	parse_commit_or_die(commit);
-	commit_buffer = get_commit_buffer(commit, NULL);
+	commit_buffer = repo_get_commit_buffer(the_repository, commit, NULL);
 	author = strstr(commit_buffer, "\nauthor ");
 	if (!author)
 		die("could not find author in commit %s",
@@ -700,7 +700,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
 			  ? strlen(message) : 0),
 	       reencoded ? reencoded : message ? message : "");
 	free(reencoded);
-	unuse_commit_buffer(commit, commit_buffer);
+	repo_unuse_commit_buffer(the_repository, commit, commit_buffer);
 
 	for (i = 0, p = commit->parents; p; p = p->next) {
 		struct object *obj = &p->item->object;
diff --git a/builtin/gc.c b/builtin/gc.c
index c58fe8c936c..9dc80344b64 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -821,7 +821,7 @@ static int dfs_on_ref(const char *refname UNUSED,
 	commit = lookup_commit(the_repository, oid);
 	if (!commit)
 		return 0;
-	if (parse_commit(commit) ||
+	if (repo_parse_commit(the_repository, commit) ||
 	    commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH)
 		return 0;
 
@@ -838,7 +838,7 @@ static int dfs_on_ref(const char *refname UNUSED,
 		commit = pop_commit(&stack);
 
 		for (parent = commit->parents; parent; parent = parent->next) {
-			if (parse_commit(parent->item) ||
+			if (repo_parse_commit(the_repository, parent->item) ||
 			    commit_graph_position(parent->item) != COMMIT_NOT_FROM_GRAPH ||
 			    parent->item->object.flags & SEEN)
 				continue;
diff --git a/builtin/log.c b/builtin/log.c
index e16bda87ba3..a55325025a4 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1328,10 +1328,11 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
 	log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte, 0);
 
 	for (i = 0; !need_8bit_cte && i < nr; i++) {
-		const char *buf = get_commit_buffer(list[i], NULL);
+		const char *buf = repo_get_commit_buffer(the_repository,
+							 list[i], NULL);
 		if (has_non_ascii(buf))
 			need_8bit_cte = 1;
-		unuse_commit_buffer(list[i], buf);
+		repo_unuse_commit_buffer(the_repository, list[i], buf);
 	}
 
 	if (!branch_name)
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 234db21548b..dd23ee684c7 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -444,9 +444,9 @@ static int real_merge(struct merge_tree_options *o,
 			die(_("could not lookup commit %s"), merge_base);
 
 		opt.ancestor = merge_base;
-		base_tree = get_commit_tree(base_commit);
-		parent1_tree = get_commit_tree(parent1);
-		parent2_tree = get_commit_tree(parent2);
+		base_tree = repo_get_commit_tree(the_repository, base_commit);
+		parent1_tree = repo_get_commit_tree(the_repository, parent1);
+		parent2_tree = repo_get_commit_tree(the_repository, parent2);
 		merge_incore_nonrecursive(&opt, base_tree, parent1_tree, parent2_tree, &result);
 	} else {
 		/*
diff --git a/builtin/merge.c b/builtin/merge.c
index 5dfc650a7bc..559aab1c380 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1610,7 +1610,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 			 * Must first ensure that index matches HEAD before
 			 * attempting a trivial merge.
 			 */
-			struct tree *head_tree = get_commit_tree(head_commit);
+			struct tree *head_tree = repo_get_commit_tree(the_repository,
+								      head_commit);
 			struct strbuf sb = STRBUF_INIT;
 
 			if (repo_index_has_changes(the_repository, head_tree,
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index cd9c000f56b..9d0dd0ad017 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -182,7 +182,7 @@ static void name_rev(struct commit *start_commit,
 	size_t parents_to_queue_nr, parents_to_queue_alloc = 0;
 	struct rev_name *start_name;
 
-	parse_commit(start_commit);
+	repo_parse_commit(the_repository, start_commit);
 	if (commit_is_before_cutoff(start_commit))
 		return;
 
@@ -212,7 +212,7 @@ static void name_rev(struct commit *start_commit,
 			struct rev_name *parent_name;
 			int generation, distance;
 
-			parse_commit(parent);
+			repo_parse_commit(the_repository, parent);
 			if (commit_is_before_cutoff(parent))
 				continue;
 
diff --git a/builtin/notes.c b/builtin/notes.c
index 73c9c691781..9aea5a4b27b 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -722,7 +722,7 @@ static int merge_commit(struct notes_merge_options *o)
 		die(_("failed to read ref NOTES_MERGE_PARTIAL"));
 	else if (!(partial = lookup_commit_reference(the_repository, &oid)))
 		die(_("could not find commit from NOTES_MERGE_PARTIAL."));
-	else if (parse_commit(partial))
+	else if (repo_parse_commit(the_repository, partial))
 		die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
 
 	if (partial->parents)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 6390dd2fcc1..3e2cdabfda5 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -854,7 +854,7 @@ static int checkout_up_to_date(struct rebase_options *options)
 static int is_linear_history(struct commit *from, struct commit *to)
 {
 	while (to && to != from) {
-		parse_commit(to);
+		repo_parse_commit(the_repository, to);
 		if (!to->parents)
 			return 1;
 		if (to->parents->next)
diff --git a/builtin/replace.c b/builtin/replace.c
index f765a3e2d75..ef70f2d1005 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -460,9 +460,9 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
 	if (!commit)
 		return error(_("could not parse %s"), old_ref);
 
-	buffer = get_commit_buffer(commit, &size);
+	buffer = repo_get_commit_buffer(the_repository, commit, &size);
 	strbuf_add(&buf, buffer, size);
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 
 	if (replace_parents(&buf, argc - 1, &argv[1]) < 0) {
 		strbuf_release(&buf);
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 27a87167e19..8afd1ad865e 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -179,7 +179,8 @@ static void insert_records_from_trailers(struct shortlog *log,
 	 * Using format_commit_message("%B") would be simpler here, but
 	 * this saves us copying the message.
 	 */
-	commit_buffer = logmsg_reencode(commit, NULL, ctx->output_encoding);
+	commit_buffer = repo_logmsg_reencode(the_repository, commit, NULL,
+					     ctx->output_encoding);
 	body = strstr(commit_buffer, "\n\n");
 	if (!body)
 		return;
@@ -202,7 +203,7 @@ static void insert_records_from_trailers(struct shortlog *log,
 	trailer_iterator_release(&iter);
 
 	strbuf_release(&ident);
-	unuse_commit_buffer(commit, commit_buffer);
+	repo_unuse_commit_buffer(the_repository, commit, commit_buffer);
 }
 
 static int shortlog_needs_dedup(const struct shortlog *log)
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 9d208db3b43..7aea28f5b06 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -241,7 +241,7 @@ static void join_revs(struct commit_list **list_p,
 			parents = parents->next;
 			if ((this_flag & flags) == flags)
 				continue;
-			parse_commit(p);
+			repo_parse_commit(the_repository, p);
 			if (mark_seen(p, seen_p) && !still_interesting)
 				extra--;
 			p->object.flags |= flags;
@@ -843,7 +843,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 		if (!commit)
 			die(_("cannot find commit %s (%s)"),
 			    ref_name[num_rev], oid_to_hex(&revkey));
-		parse_commit(commit);
+		repo_parse_commit(the_repository, commit);
 		mark_seen(commit, &seen);
 
 		/* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,
diff --git a/commit-graph.c b/commit-graph.c
index 5e6098ff356..a30c4c96940 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2550,7 +2550,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
 
 		graph_commit = lookup_commit(r, &cur_oid);
 		odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
-		if (parse_commit_internal(odb_commit, 0, 0)) {
+		if (repo_parse_commit_internal(the_repository, odb_commit, 0, 0)) {
 			graph_report(_("failed to parse commit %s from object database for commit-graph"),
 				     oid_to_hex(&cur_oid));
 			continue;
diff --git a/commit-reach.c b/commit-reach.c
index 4a2ea9ca1f7..b9eb0952d7b 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -587,7 +587,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
 		return 0;
 	new_commit = (struct commit *) o;
 
-	if (parse_commit(new_commit) < 0)
+	if (repo_parse_commit(the_repository, new_commit) < 0)
 		return 0;
 
 	commit_list_insert(old_commit, &old_commit_list);
@@ -751,7 +751,7 @@ int can_all_from_reach_with_flag(struct object_array *from,
 		}
 
 		list[nr_commits] = (struct commit *)from_one;
-		if (parse_commit(list[nr_commits]) ||
+		if (repo_parse_commit(the_repository, list[nr_commits]) ||
 		    commit_graph_generation(list[nr_commits]) < min_generation) {
 			result = 0;
 			goto cleanup;
@@ -786,7 +786,7 @@ int can_all_from_reach_with_flag(struct object_array *from,
 				if (!(parent->item->object.flags & assign_flag)) {
 					parent->item->object.flags |= assign_flag;
 
-					if (parse_commit(parent->item) ||
+					if (repo_parse_commit(the_repository, parent->item) ||
 					    parent->item->date < min_commit_date ||
 					    commit_graph_generation(parent->item) < min_generation)
 						continue;
@@ -832,7 +832,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
 	while (from_iter) {
 		add_object_array(&from_iter->item->object, NULL, &from_objs);
 
-		if (!parse_commit(from_iter->item)) {
+		if (!repo_parse_commit(the_repository, from_iter->item)) {
 			timestamp_t generation;
 			if (from_iter->item->date < min_commit_date)
 				min_commit_date = from_iter->item->date;
@@ -846,7 +846,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
 	}
 
 	while (to_iter) {
-		if (!parse_commit(to_iter->item)) {
+		if (!repo_parse_commit(the_repository, to_iter->item)) {
 			timestamp_t generation;
 			if (to_iter->item->date < min_commit_date)
 				min_commit_date = to_iter->item->date;
@@ -896,7 +896,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
 		timestamp_t generation;
 		struct commit *c = *item;
 
-		parse_commit(c);
+		repo_parse_commit(the_repository, c);
 		generation = commit_graph_generation(c);
 		if (generation < min_generation)
 			min_generation = generation;
@@ -911,7 +911,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
 		struct commit *c = *item;
 		if (!(c->object.flags & PARENT2)) {
 			c->object.flags |= PARENT2;
-			parse_commit(c);
+			repo_parse_commit(the_repository, c);
 
 			prio_queue_put(&queue, *item);
 		}
@@ -930,7 +930,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
 		for (parents = current->parents; parents; parents = parents->next) {
 			struct commit *p = parents->item;
 
-			parse_commit(p);
+			repo_parse_commit(the_repository, p);
 
 			if (commit_graph_generation(p) < min_generation)
 				continue;
diff --git a/commit.c b/commit.c
index aa2e58ea207..127ec79b2d3 100644
--- a/commit.c
+++ b/commit.c
@@ -84,7 +84,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
 	if (repo_get_oid_committish(the_repository, name, &oid))
 		return NULL;
 	commit = lookup_commit_reference(the_repository, &oid);
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		return NULL;
 	return commit;
 }
@@ -383,7 +383,7 @@ struct tree *repo_get_commit_tree(struct repository *r,
 
 struct object_id *get_commit_tree_oid(const struct commit *commit)
 {
-	struct tree *tree = get_commit_tree(commit);
+	struct tree *tree = repo_get_commit_tree(the_repository, commit);
 	return tree ? &tree->object.oid : NULL;
 }
 
@@ -556,7 +556,7 @@ int repo_parse_commit_gently(struct repository *r,
 
 void parse_commit_or_die(struct commit *item)
 {
-	if (parse_commit(item))
+	if (repo_parse_commit(the_repository, item))
 		die("unable to parse commit %s",
 		    item ? oid_to_hex(&item->object.oid) : "(null)");
 }
@@ -689,7 +689,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
 
 	while (parents) {
 		struct commit *commit = parents->item;
-		if (!parse_commit(commit) && !(commit->object.flags & mark)) {
+		if (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) {
 			commit->object.flags |= mark;
 			commit_list_insert_by_date(commit, list);
 		}
@@ -763,7 +763,8 @@ define_commit_slab(author_date_slab, timestamp_t);
 void record_author_date(struct author_date_slab *author_date,
 			struct commit *commit)
 {
-	const char *buffer = get_commit_buffer(commit, NULL);
+	const char *buffer = repo_get_commit_buffer(the_repository, commit,
+						    NULL);
 	struct ident_split ident;
 	const char *ident_line;
 	size_t ident_len;
@@ -783,7 +784,7 @@ void record_author_date(struct author_date_slab *author_date,
 	*(author_date_slab_at(author_date, commit)) = date;
 
 fail_exit:
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
 int compare_commits_by_author_date(const void *a_, const void *b_,
@@ -966,7 +967,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
 	commit = lookup_commit(the_repository, oid);
 	if (!commit ||
 	    (commit->object.flags & TMP_MARK) ||
-	    parse_commit(commit))
+	    repo_parse_commit(the_repository, commit))
 		return;
 
 	ALLOC_GROW(revs->commit, revs->nr + 1, revs->alloc);
@@ -1099,10 +1100,11 @@ int parse_signed_commit(const struct commit *commit,
 			const struct git_hash_algo *algop)
 {
 	unsigned long size;
-	const char *buffer = get_commit_buffer(commit, &size);
+	const char *buffer = repo_get_commit_buffer(the_repository, commit,
+						    &size);
 	int ret = parse_buffer_signed_by_header(buffer, size, payload, signature, algop);
 
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 	return ret;
 }
 
@@ -1321,9 +1323,10 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,
 {
 	struct commit_extra_header *extra = NULL;
 	unsigned long size;
-	const char *buffer = get_commit_buffer(commit, &size);
+	const char *buffer = repo_get_commit_buffer(the_repository, commit,
+						    &size);
 	extra = read_commit_extra_header_lines(buffer, size, exclude);
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 	return extra;
 }
 
diff --git a/commit.h b/commit.h
index 06657b4c6e7..d87d5cd2a09 100644
--- a/commit.h
+++ b/commit.h
@@ -109,11 +109,6 @@ static inline int repo_parse_commit_no_graph(struct repository *r,
 	return repo_parse_commit_internal(r, commit, 0, 0);
 }
 
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use)
-#define parse_commit(item) repo_parse_commit(the_repository, item)
-#endif
-
 void parse_commit_or_die(struct commit *item);
 
 struct buffer_slab;
@@ -140,9 +135,6 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,
 const void *repo_get_commit_buffer(struct repository *r,
 				   const struct commit *,
 				   unsigned long *size);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s)
-#endif
 
 /*
  * Tell the commit subsystem that we are done with a particular commit buffer.
@@ -153,9 +145,6 @@ const void *repo_get_commit_buffer(struct repository *r,
 void repo_unuse_commit_buffer(struct repository *r,
 			      const struct commit *,
 			      const void *buffer);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b)
-#endif
 
 /*
  * Free any cached object buffer associated with the commit.
@@ -163,7 +152,6 @@ void repo_unuse_commit_buffer(struct repository *r,
 void free_commit_buffer(struct parsed_object_pool *pool, struct commit *);
 
 struct tree *repo_get_commit_tree(struct repository *, const struct commit *);
-#define get_commit_tree(c) repo_get_commit_tree(the_repository, c)
 struct object_id *get_commit_tree_oid(const struct commit *);
 
 /*
@@ -205,16 +193,10 @@ void free_commit_list(struct commit_list *list);
 
 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 
-const char *logmsg_reencode(const struct commit *commit,
-			    char **commit_encoding,
-			    const char *output_encoding);
 const char *repo_logmsg_reencode(struct repository *r,
 				 const struct commit *commit,
 				 char **commit_encoding,
 				 const char *output_encoding);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define logmsg_reencode(c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out)
-#endif
 
 const char *skip_blank_lines(const char *msg);
 
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index 1ab63f0196b..0cdf3f46304 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -54,6 +54,25 @@
 |
 - in_merge_bases_many
 + repo_in_merge_bases_many
+// commit.h
+|
+- parse_commit_internal
++ repo_parse_commit_internal
+|
+- parse_commit
++ repo_parse_commit
+|
+- get_commit_buffer
++ repo_get_commit_buffer
+|
+- unuse_commit_buffer
++ repo_unuse_commit_buffer
+|
+- logmsg_reencode
++ repo_logmsg_reencode
+|
+- get_commit_tree
++ repo_get_commit_tree
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index e9209fc0cc4..bf19e6a2487 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,26 +5,7 @@
 @@
 @@
 (
-// commit.h
-- parse_commit_internal
-+ repo_parse_commit_internal
-|
-- parse_commit
-+ repo_parse_commit
-|
-- get_commit_buffer
-+ repo_get_commit_buffer
-|
-- unuse_commit_buffer
-+ repo_unuse_commit_buffer
-|
-- logmsg_reencode
-+ repo_logmsg_reencode
-|
-- get_commit_tree
-+ repo_get_commit_tree
 // diff.h
-|
 - diff_setup
 + repo_diff_setup
 // object-store.h
diff --git a/delta-islands.c b/delta-islands.c
index fe12c93005b..7a412ccbf63 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -508,8 +508,9 @@ void propagate_island_marks(struct commit *commit)
 		struct commit_list *p;
 		struct island_bitmap *root_marks = kh_value(island_marks, pos);
 
-		parse_commit(commit);
-		set_island_marks(&get_commit_tree(commit)->object, root_marks);
+		repo_parse_commit(the_repository, commit);
+		set_island_marks(&repo_get_commit_tree(the_repository, commit)->object,
+				 root_marks);
 		for (p = commit->parents; p; p = p->next)
 			set_island_marks(&p->item->object, root_marks);
 	}
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index bb56d957a64..29a1afa2485 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -269,9 +269,10 @@ static void record_person_from_buf(int which, struct string_list *people,
 static void record_person(int which, struct string_list *people,
 			  struct commit *commit)
 {
-	const char *buffer = get_commit_buffer(commit, NULL);
+	const char *buffer = repo_get_commit_buffer(the_repository, commit,
+						    NULL);
 	record_person_from_buf(which, people, buffer);
-	unuse_commit_buffer(commit, buffer);
+	repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
 static int cmp_string_list_util_as_integral(const void *a_, const void *b_)
diff --git a/fsck.c b/fsck.c
index 871c0a9a252..0d752d57717 100644
--- a/fsck.c
+++ b/fsck.c
@@ -355,7 +355,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
 	int result;
 	const char *name;
 
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		return -1;
 
 	name = fsck_get_object_name(options, &commit->object.oid);
@@ -363,7 +363,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
 		fsck_put_object_name(options, get_commit_tree_oid(commit),
 				     "%s:", name);
 
-	result = options->walk((struct object *)get_commit_tree(commit),
+	result = options->walk((struct object *) repo_get_commit_tree(the_repository, commit),
 			       OBJ_TREE, data, options);
 	if (result < 0)
 		return result;
diff --git a/http-push.c b/http-push.c
index 2693d73cf9a..e149daeff3d 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1332,7 +1332,8 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
 	int count = 0;
 
 	while ((commit = get_revision(revs)) != NULL) {
-		p = process_tree(get_commit_tree(commit), p);
+		p = process_tree(repo_get_commit_tree(the_repository, commit),
+				 p);
 		commit->object.flags |= LOCAL;
 		if (!(commit->object.flags & UNINTERESTING))
 			count += add_send_request(&commit->object, lock);
diff --git a/list-objects.c b/list-objects.c
index ab5745bbfe4..d75132cfd73 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -228,7 +228,8 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
 		struct commit *parent = parents->item;
 		if (!(parent->object.flags & UNINTERESTING))
 			continue;
-		mark_tree_uninteresting(revs->repo, get_commit_tree(parent));
+		mark_tree_uninteresting(revs->repo,
+					repo_get_commit_tree(the_repository, parent));
 		if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
 			parent->object.flags |= SHOWN;
 			show_edge(parent);
@@ -245,7 +246,8 @@ static void add_edge_parents(struct commit *commit,
 
 	for (parents = commit->parents; parents; parents = parents->next) {
 		struct commit *parent = parents->item;
-		struct tree *tree = get_commit_tree(parent);
+		struct tree *tree = repo_get_commit_tree(the_repository,
+							 parent);
 
 		if (!tree)
 			continue;
@@ -276,7 +278,8 @@ void mark_edges_uninteresting(struct rev_info *revs,
 
 		for (list = revs->commits; list; list = list->next) {
 			struct commit *commit = list->item;
-			struct tree *tree = get_commit_tree(commit);
+			struct tree *tree = repo_get_commit_tree(the_repository,
+								 commit);
 
 			if (commit->object.flags & UNINTERESTING)
 				tree->object.flags |= UNINTERESTING;
@@ -292,7 +295,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
 			struct commit *commit = list->item;
 			if (commit->object.flags & UNINTERESTING) {
 				mark_tree_uninteresting(revs->repo,
-							get_commit_tree(commit));
+							repo_get_commit_tree(the_repository, commit));
 				if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
 					commit->object.flags |= SHOWN;
 					show_edge(commit);
@@ -310,7 +313,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
 			if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
 				continue;
 			mark_tree_uninteresting(revs->repo,
-						get_commit_tree(commit));
+						repo_get_commit_tree(the_repository, commit));
 			if (!(obj->flags & SHOWN)) {
 				obj->flags |= SHOWN;
 				show_edge(commit);
@@ -377,8 +380,9 @@ static void do_traverse(struct traversal_context *ctx)
 		 */
 		if (!ctx->revs->tree_objects)
 			; /* do not bother loading tree */
-		else if (get_commit_tree(commit)) {
-			struct tree *tree = get_commit_tree(commit);
+		else if (repo_get_commit_tree(the_repository, commit)) {
+			struct tree *tree = repo_get_commit_tree(the_repository,
+								 commit);
 			tree->object.flags |= NOT_USER_GIVEN;
 			add_pending_tree(ctx->revs, tree);
 		} else if (commit->object.parsed) {
diff --git a/merge-recursive.c b/merge-recursive.c
index cfb201d682b..6eeb4844f38 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3797,7 +3797,7 @@ static struct commit *get_ref(struct repository *repo,
 		return make_virtual_commit(repo, (struct tree*)object, name);
 	if (object->type != OBJ_COMMIT)
 		return NULL;
-	if (parse_commit((struct commit *)object))
+	if (repo_parse_commit(the_repository, (struct commit *)object))
 		return NULL;
 	return (struct commit *)object;
 }
diff --git a/negotiator/default.c b/negotiator/default.c
index b7e79feaf04..658d9dd6b95 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -25,7 +25,7 @@ static void rev_list_push(struct negotiation_state *ns,
 	if (!(commit->object.flags & mark)) {
 		commit->object.flags |= mark;
 
-		if (parse_commit(commit))
+		if (repo_parse_commit(the_repository, commit))
 			return;
 
 		prio_queue_put(&ns->rev_list, commit);
@@ -69,7 +69,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit,
 			if (!ancestors_only && !(o->flags & POPPED))
 				ns->non_common_revs--;
 			if (!o->parsed && !dont_parse)
-				if (parse_commit(commit))
+				if (repo_parse_commit(the_repository, commit))
 					return;
 
 			for (parents = commit->parents;
@@ -96,7 +96,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns)
 			return NULL;
 
 		commit = prio_queue_get(&ns->rev_list);
-		parse_commit(commit);
+		repo_parse_commit(the_repository, commit);
 		parents = commit->parents;
 
 		commit->object.flags |= POPPED;
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index 264acf8bbea..c4de512e6e6 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -184,7 +184,7 @@ static const struct object_id *get_rev(struct data *data)
 		if (!(commit->object.flags & COMMON) && !entry->ttl)
 			to_send = commit;
 
-		parse_commit(commit);
+		repo_parse_commit(the_repository, commit);
 		for (p = commit->parents; p; p = p->next)
 			parent_pushed |= push_parent(data, entry, p->item);
 
diff --git a/notes-merge.c b/notes-merge.c
index 699edcfe105..d26c826963e 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -679,7 +679,8 @@ int notes_merge_commit(struct notes_merge_options *o,
 	DIR *dir;
 	struct dirent *e;
 	struct strbuf path = STRBUF_INIT;
-	const char *buffer = get_commit_buffer(partial_commit, NULL);
+	const char *buffer = repo_get_commit_buffer(the_repository,
+						    partial_commit, NULL);
 	const char *msg = strstr(buffer, "\n\n");
 	int baselen;
 
@@ -726,7 +727,7 @@ int notes_merge_commit(struct notes_merge_options *o,
 
 	create_notes_commit(o->repo, partial_tree, partial_commit->parents, msg,
 			    strlen(msg), result_oid);
-	unuse_commit_buffer(partial_commit, buffer);
+	repo_unuse_commit_buffer(the_repository, partial_commit, buffer);
 	if (o->verbosity >= 4)
 		printf("Finalized notes merge commit: %s\n",
 			oid_to_hex(result_oid));
diff --git a/notes-utils.c b/notes-utils.c
index d7d18e30f5a..0550cfded86 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -23,7 +23,7 @@ void create_notes_commit(struct repository *r,
 		struct object_id parent_oid;
 		if (!read_ref(t->ref, &parent_oid)) {
 			struct commit *parent = lookup_commit(r, &parent_oid);
-			if (parse_commit(parent))
+			if (repo_parse_commit(the_repository, parent))
 				die("Failed to find/parse commit %s", t->ref);
 			commit_list_insert(parent, &parents);
 		}
diff --git a/object-name.c b/object-name.c
index 19ba23216a5..b297cbd0a18 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1037,7 +1037,7 @@ static enum get_oid_result get_parent(struct repository *r,
 	if (ret)
 		return ret;
 	commit = lookup_commit_reference(r, &oid);
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		return MISSING_OBJECT;
 	if (!idx) {
 		oidcpy(result, &commit->object.oid);
@@ -1071,7 +1071,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r,
 		return MISSING_OBJECT;
 
 	while (generation--) {
-		if (parse_commit(commit) || !commit->parents)
+		if (repo_parse_commit(the_repository, commit) || !commit->parents)
 			return MISSING_OBJECT;
 		commit = commit->parents->item;
 	}
@@ -1362,10 +1362,10 @@ static int get_oid_oneline(struct repository *r,
 		commit = pop_most_recent_commit(&list, ONELINE_SEEN);
 		if (!parse_object(r, &commit->object.oid))
 			continue;
-		buf = get_commit_buffer(commit, NULL);
+		buf = repo_get_commit_buffer(the_repository, commit, NULL);
 		p = strstr(buf, "\n\n");
 		matches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));
-		unuse_commit_buffer(commit, buf);
+		repo_unuse_commit_buffer(the_repository, commit, buf);
 
 		if (matches) {
 			oidcpy(oid, &commit->object.oid);
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 891d9d2772e..a3cafa8e201 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -427,7 +427,8 @@ static int fill_bitmap_commit(struct bb_commit *ent,
 		if (!found)
 			return -1;
 		bitmap_set(ent->bitmap, pos);
-		prio_queue_put(tree_queue, get_commit_tree(c));
+		prio_queue_put(tree_queue,
+			       repo_get_commit_tree(the_repository, c));
 
 		for (p = c->parents; p; p = p->next) {
 			pos = find_object_pos(&p->item->object.oid, &found);
diff --git a/pretty.c b/pretty.c
index 05b557d0961..34e0a3bc786 100644
--- a/pretty.c
+++ b/pretty.c
@@ -2207,7 +2207,8 @@ void pretty_print_commit(struct pretty_print_context *pp,
 	}
 
 	encoding = get_log_output_encoding();
-	msg = reencoded = logmsg_reencode(commit, NULL, encoding);
+	msg = reencoded = repo_logmsg_reencode(the_repository, commit, NULL,
+					       encoding);
 
 	if (pp->fmt == CMIT_FMT_ONELINE || cmit_fmt_is_mail(pp->fmt))
 		indent = 0;
@@ -2264,7 +2265,7 @@ void pretty_print_commit(struct pretty_print_context *pp,
 	if (cmit_fmt_is_mail(pp->fmt) && sb->len <= beginning_of_body)
 		strbuf_addch(sb, '\n');
 
-	unuse_commit_buffer(commit, reencoded);
+	repo_unuse_commit_buffer(the_repository, commit, reencoded);
 }
 
 void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
diff --git a/reflog.c b/reflog.c
index 04630f56ec6..6e8362e7a2f 100644
--- a/reflog.c
+++ b/reflog.c
@@ -186,7 +186,7 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb)
 		struct commit *commit = pop_commit(&pending);
 		if (commit->object.flags & REACHABLE)
 			continue;
-		if (parse_commit(commit))
+		if (repo_parse_commit(the_repository, commit))
 			continue;
 		commit->object.flags |= REACHABLE;
 		if (commit->date < expire_limit) {
diff --git a/revision.c b/revision.c
index b6a1b47c306..8f22b7b06dc 100644
--- a/revision.c
+++ b/revision.c
@@ -780,8 +780,8 @@ static int check_maybe_different_in_bloom_filter(struct rev_info *revs,
 static int rev_compare_tree(struct rev_info *revs,
 			    struct commit *parent, struct commit *commit, int nth_parent)
 {
-	struct tree *t1 = get_commit_tree(parent);
-	struct tree *t2 = get_commit_tree(commit);
+	struct tree *t1 = repo_get_commit_tree(the_repository, parent);
+	struct tree *t2 = repo_get_commit_tree(the_repository, commit);
 	int bloom_ret = 1;
 
 	if (!t1)
@@ -827,7 +827,7 @@ static int rev_compare_tree(struct rev_info *revs,
 
 static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
 {
-	struct tree *t1 = get_commit_tree(commit);
+	struct tree *t1 = repo_get_commit_tree(the_repository, commit);
 
 	if (!t1)
 		return 0;
@@ -965,7 +965,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
 	if (!revs->prune)
 		return;
 
-	if (!get_commit_tree(commit))
+	if (!repo_get_commit_tree(the_repository, commit))
 		return;
 
 	if (!commit->parents) {
@@ -3881,7 +3881,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
 	 * in it.
 	 */
 	encoding = get_log_output_encoding();
-	message = logmsg_reencode(commit, NULL, encoding);
+	message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
 
 	/* Copy the commit to temporary if we are using "fake" headers */
 	if (buf.len)
@@ -3917,7 +3917,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
 		retval = grep_buffer(&opt->grep_filter,
 				     (char *)message, strlen(message));
 	strbuf_release(&buf);
-	unuse_commit_buffer(commit, message);
+	repo_unuse_commit_buffer(the_repository, commit, message);
 	return retval;
 }
 
diff --git a/sequencer.c b/sequencer.c
index 3578dc25510..749455a2597 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -426,7 +426,8 @@ static int get_message(struct commit *commit, struct commit_message *out)
 	const char *abbrev, *subject;
 	int subject_len;
 
-	out->message = logmsg_reencode(commit, NULL, get_commit_output_encoding());
+	out->message = repo_logmsg_reencode(the_repository, commit, NULL,
+					    get_commit_output_encoding());
 	abbrev = short_commit_name(commit);
 
 	subject_len = find_commit_subject(out->message, &subject);
@@ -443,7 +444,7 @@ static void free_message(struct commit *commit, struct commit_message *msg)
 	free(msg->parent_label);
 	free(msg->label);
 	free(msg->subject);
-	unuse_commit_buffer(commit, msg->message);
+	repo_unuse_commit_buffer(the_repository, commit, msg->message);
 }
 
 static void print_advice(struct repository *r, int show_hint,
@@ -691,8 +692,8 @@ static int do_recursive_merge(struct repository *r,
 	o.show_rename_progress = 1;
 
 	head_tree = parse_tree_indirect(head);
-	next_tree = next ? get_commit_tree(next) : empty_tree(r);
-	base_tree = base ? get_commit_tree(base) : empty_tree(r);
+	next_tree = next ? repo_get_commit_tree(the_repository, next) : empty_tree(r);
+	base_tree = base ? repo_get_commit_tree(the_repository, base) : empty_tree(r);
 
 	for (i = 0; i < opts->xopts_nr; i++)
 		parse_merge_opt(&o, opts->xopts[i]);
@@ -770,7 +771,7 @@ static int is_index_unchanged(struct repository *r)
 	 * the commit is invalid, parse_commit() will complain.  So
 	 * there is nothing for us to say here.  Just return failure.
 	 */
-	if (parse_commit(head_commit))
+	if (repo_parse_commit(the_repository, head_commit))
 		return -1;
 
 	if (!(cache_tree_oid = get_cache_tree_oid(istate)))
@@ -1335,7 +1336,7 @@ void print_commit_summary(struct repository *r,
 	commit = lookup_commit(r, oid);
 	if (!commit)
 		die(_("couldn't look up newly created commit"));
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		die(_("could not parse newly created commit"));
 
 	strbuf_addstr(&format, "format:%h] %s");
@@ -1415,7 +1416,7 @@ static int parse_head(struct repository *r, struct commit **head)
 			warning(_("HEAD %s is not a commit!"),
 				oid_to_hex(&oid));
 		}
-		if (parse_commit(current_head))
+		if (repo_parse_commit(the_repository, current_head))
 			return error(_("could not parse HEAD commit"));
 	}
 	*head = current_head;
@@ -1458,8 +1459,9 @@ static int try_to_commit(struct repository *r,
 	if (flags & AMEND_MSG) {
 		const char *exclude_gpgsig[] = { "gpgsig", "gpgsig-sha256", NULL };
 		const char *out_enc = get_commit_output_encoding();
-		const char *message = logmsg_reencode(current_head, NULL,
-						      out_enc);
+		const char *message = repo_logmsg_reencode(the_repository,
+							   current_head, NULL,
+							   out_enc);
 
 		if (!msg) {
 			const char *orig_message = NULL;
@@ -1470,7 +1472,8 @@ static int try_to_commit(struct repository *r,
 			hook_commit = "HEAD";
 		}
 		author = amend_author = get_author(message);
-		unuse_commit_buffer(current_head, message);
+		repo_unuse_commit_buffer(the_repository, current_head,
+					 message);
 		if (!author) {
 			res = error(_("unable to parse commit author"));
 			goto out;
@@ -1667,12 +1670,12 @@ static int is_original_commit_empty(struct commit *commit)
 {
 	const struct object_id *ptree_oid;
 
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		return error(_("could not parse commit %s"),
 			     oid_to_hex(&commit->object.oid));
 	if (commit->parents) {
 		struct commit *parent = commit->parents->item;
-		if (parse_commit(parent))
+		if (repo_parse_commit(the_repository, parent))
 			return error(_("could not parse parent commit %s"),
 				oid_to_hex(&parent->object.oid));
 		ptree_oid = get_commit_tree_oid(parent);
@@ -2000,13 +2003,14 @@ static int update_squash_messages(struct repository *r,
 			return error(_("need a HEAD to fixup"));
 		if (!(head_commit = lookup_commit_reference(r, &head)))
 			return error(_("could not read HEAD"));
-		if (!(head_message = logmsg_reencode(head_commit, NULL, encoding)))
+		if (!(head_message = repo_logmsg_reencode(the_repository, head_commit, NULL, encoding)))
 			return error(_("could not read HEAD's commit message"));
 
 		find_commit_subject(head_message, &body);
 		if (command == TODO_FIXUP && !flag && write_message(body, strlen(body),
 							rebase_path_fixup_msg(), 0) < 0) {
-			unuse_commit_buffer(head_commit, head_message);
+			repo_unuse_commit_buffer(the_repository, head_commit,
+						 head_message);
 			return error(_("cannot write '%s'"), rebase_path_fixup_msg());
 		}
 		strbuf_addf(&buf, "%c ", comment_line_char);
@@ -2021,10 +2025,11 @@ static int update_squash_messages(struct repository *r,
 		else
 			strbuf_addstr(&buf, body);
 
-		unuse_commit_buffer(head_commit, head_message);
+		repo_unuse_commit_buffer(the_repository, head_commit,
+					 head_message);
 	}
 
-	if (!(message = logmsg_reencode(commit, NULL, encoding)))
+	if (!(message = repo_logmsg_reencode(the_repository, commit, NULL, encoding)))
 		return error(_("could not read commit message of %s"),
 			     oid_to_hex(&commit->object.oid));
 	find_commit_subject(message, &body);
@@ -2039,7 +2044,7 @@ static int update_squash_messages(struct repository *r,
 		strbuf_add_commented_lines(&buf, body, strlen(body));
 	} else
 		return error(_("unknown command: %d"), command);
-	unuse_commit_buffer(commit, message);
+	repo_unuse_commit_buffer(the_repository, commit, message);
 
 	if (!res)
 		res = write_message(buf.buf, buf.len, rebase_path_squash_msg(),
@@ -2213,7 +2218,7 @@ static int do_pick_commit(struct repository *r,
 		msg_file = NULL;
 		goto fast_forward_edit;
 	}
-	if (parent && parse_commit(parent) < 0)
+	if (parent && repo_parse_commit(the_repository, parent) < 0)
 		/* TRANSLATORS: The first %s will be a "todo" command like
 		   "revert" or "pick", the second %s a SHA1. */
 		return error(_("%s: cannot parse parent commit %s"),
@@ -3126,7 +3131,9 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
 
 	while ((commit = get_revision(opts->revs))) {
 		struct todo_item *item = append_new_todo(todo_list);
-		const char *commit_buffer = logmsg_reencode(commit, NULL, encoding);
+		const char *commit_buffer = repo_logmsg_reencode(the_repository,
+								 commit, NULL,
+								 encoding);
 		const char *subject;
 		int subject_len;
 
@@ -3138,7 +3145,8 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
 		subject_len = find_commit_subject(commit_buffer, &subject);
 		strbuf_addf(&todo_list->buf, "%s %s %.*s\n", command_string,
 			short_commit_name(commit), subject_len, subject);
-		unuse_commit_buffer(commit, commit_buffer);
+		repo_unuse_commit_buffer(the_repository, commit,
+					 commit_buffer);
 	}
 
 	if (!todo_list->nr)
@@ -3522,10 +3530,13 @@ static int make_patch(struct repository *r,
 	strbuf_addf(&buf, "%s/message", get_dir(opts));
 	if (!file_exists(buf.buf)) {
 		const char *encoding = get_commit_output_encoding();
-		const char *commit_buffer = logmsg_reencode(commit, NULL, encoding);
+		const char *commit_buffer = repo_logmsg_reencode(the_repository,
+								 commit, NULL,
+								 encoding);
 		find_commit_subject(commit_buffer, &subject);
 		res |= write_message(subject, strlen(subject), buf.buf, 1);
-		unuse_commit_buffer(commit, commit_buffer);
+		repo_unuse_commit_buffer(the_repository, commit,
+					 commit_buffer);
 	}
 	strbuf_release(&buf);
 	release_revisions(&log_tree_opt);
@@ -3992,7 +4003,9 @@ static int do_merge(struct repository *r,
 
 	if (commit) {
 		const char *encoding = get_commit_output_encoding();
-		const char *message = logmsg_reencode(commit, NULL, encoding);
+		const char *message = repo_logmsg_reencode(the_repository,
+							   commit, NULL,
+							   encoding);
 		const char *body;
 		int len;
 
@@ -4005,7 +4018,7 @@ static int do_merge(struct repository *r,
 		find_commit_subject(message, &body);
 		len = strlen(body);
 		ret = write_message(body, len, git_path_merge_msg(r), 0);
-		unuse_commit_buffer(commit, message);
+		repo_unuse_commit_buffer(the_repository, commit, message);
 		if (ret) {
 			error_errno(_("could not write '%s'"),
 				    git_path_merge_msg(r));
@@ -4588,7 +4601,7 @@ static int stopped_at_head(struct repository *r)
 
 	if (repo_get_oid(the_repository, "HEAD", &head) ||
 	    !(commit = lookup_commit(r, &head)) ||
-	    parse_commit(commit) || get_message(commit, &message))
+	    repo_parse_commit(the_repository, commit) || get_message(commit, &message))
 		fprintf(stderr, _("Stopped at HEAD\n"));
 	else {
 		fprintf(stderr, _("Stopped at %s\n"), message.label);
@@ -5045,13 +5058,15 @@ static int commit_staged_changes(struct repository *r,
 				const char *encoding = get_commit_output_encoding();
 
 				if (parse_head(r, &commit) ||
-				    !(p = logmsg_reencode(commit, NULL, encoding)) ||
+				    !(p = repo_logmsg_reencode(the_repository, commit, NULL, encoding)) ||
 				    write_message(p, strlen(p), path, 0)) {
-					unuse_commit_buffer(commit, p);
+					repo_unuse_commit_buffer(the_repository,
+								 commit, p);
 					return error(_("could not write file: "
 						       "'%s'"), path);
 				}
-				unuse_commit_buffer(commit, p);
+				repo_unuse_commit_buffer(the_repository,
+							 commit, p);
 			}
 		}
 
@@ -5928,7 +5943,7 @@ static int skip_unnecessary_picks(struct repository *r,
 			continue;
 		if (item->command != TODO_PICK)
 			break;
-		if (parse_commit(item->commit)) {
+		if (repo_parse_commit(the_repository, item->commit)) {
 			return error(_("could not parse commit '%s'"),
 				oid_to_hex(&item->commit->object.oid));
 		}
@@ -6261,12 +6276,15 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
 			return error(_("the script was already rearranged."));
 		}
 
-		parse_commit(item->commit);
-		commit_buffer = logmsg_reencode(item->commit, NULL, "UTF-8");
+		repo_parse_commit(the_repository, item->commit);
+		commit_buffer = repo_logmsg_reencode(the_repository,
+						     item->commit, NULL,
+						     "UTF-8");
 		find_commit_subject(commit_buffer, &subject);
 		format_subject(&buf, subject, " ");
 		subject = subjects[i] = strbuf_detach(&buf, &subject_len);
-		unuse_commit_buffer(item->commit, commit_buffer);
+		repo_unuse_commit_buffer(the_repository, item->commit,
+					 commit_buffer);
 		if (skip_fixupish(subject, &p)) {
 			struct commit *commit2;
 
diff --git a/shallow.c b/shallow.c
index db9856ef8ad..138bcfe009c 100644
--- a/shallow.c
+++ b/shallow.c
@@ -249,7 +249,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
 		struct commit *c = p->item;
 		struct commit_list *parent;
 
-		if (parse_commit(c))
+		if (repo_parse_commit(the_repository, c))
 			die("unable to parse commit %s",
 			    oid_to_hex(&c->object.oid));
 
@@ -585,7 +585,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
 		if (c->object.flags & BOTTOM)
 			continue;
 
-		if (parse_commit(c))
+		if (repo_parse_commit(the_repository, c))
 			die("unable to parse commit %s",
 			    oid_to_hex(&c->object.oid));
 
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index 3f8d5761780..e07448c1a17 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -66,7 +66,8 @@ static struct commit *create_commit(struct tree *tree,
 	struct commit_extra_header *extra;
 	struct strbuf msg = STRBUF_INIT;
 	const char *out_enc = get_commit_output_encoding();
-	const char *message = logmsg_reencode(based_on, NULL, out_enc);
+	const char *message = repo_logmsg_reencode(the_repository, based_on,
+						   NULL, out_enc);
 	const char *orig_message = NULL;
 	const char *exclude_gpgsig[] = { "gpgsig", NULL };
 
@@ -157,7 +158,7 @@ int cmd__fast_rebase(int argc, const char **argv)
 	memset(&result, 0, sizeof(result));
 	merge_opt.show_rename_progress = 1;
 	merge_opt.branch1 = "HEAD";
-	head_tree = get_commit_tree(onto);
+	head_tree = repo_get_commit_tree(the_repository, onto);
 	result.tree = head_tree;
 	last_commit = onto;
 	while ((commit = get_revision(&revs))) {
@@ -168,8 +169,8 @@ int cmd__fast_rebase(int argc, const char **argv)
 		assert(commit->parents && !commit->parents->next);
 		base = commit->parents->item;
 
-		next_tree = get_commit_tree(commit);
-		base_tree = get_commit_tree(base);
+		next_tree = repo_get_commit_tree(the_repository, commit);
+		base_tree = repo_get_commit_tree(the_repository, base);
 
 		merge_opt.branch2 = short_commit_name(commit);
 		merge_opt.ancestor = xstrfmt("parent of %s", merge_opt.branch2);
diff --git a/tree.c b/tree.c
index 76a6534f678..e33f4009ac9 100644
--- a/tree.c
+++ b/tree.c
@@ -59,7 +59,7 @@ int read_tree_at(struct repository *r,
 				    oid_to_hex(&entry.oid),
 				    base->buf, entry.path);
 
-			if (parse_commit(commit))
+			if (repo_parse_commit(the_repository, commit))
 				die("Invalid commit %s in submodule path %s%s",
 				    oid_to_hex(&entry.oid),
 				    base->buf, entry.path);
diff --git a/walker.c b/walker.c
index c0469363789..5275070de76 100644
--- a/walker.c
+++ b/walker.c
@@ -80,7 +80,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
 {
 	struct commit_list *parents;
 
-	if (parse_commit(commit))
+	if (repo_parse_commit(the_repository, commit))
 		return -1;
 
 	while (complete && complete->item->date >= commit->date) {
@@ -94,7 +94,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
 
 	walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));
 
-	if (process(walker, &get_commit_tree(commit)->object))
+	if (process(walker, &repo_get_commit_tree(the_repository, commit)->object))
 		return -1;
 
 	for (parents = commit->parents; parents; parents = parents->next) {
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 08/17] cocci: apply the "diff.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (6 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 07/17] cocci: apply the "commit.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 09/17] cocci: apply the "object-store.h" " Ævar Arnfjörð Bjarmason
                     ` (10 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"diff.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/log.c                                   | 2 +-
 builtin/rebase.c                                | 2 +-
 builtin/stash.c                                 | 2 +-
 contrib/coccinelle/the_repository.cocci         | 4 ++++
 contrib/coccinelle/the_repository.pending.cocci | 4 ----
 diff.h                                          | 3 ---
 log-tree.c                                      | 2 +-
 range-diff.c                                    | 2 +-
 8 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index a55325025a4..11ba99d6b48 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1385,7 +1385,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
 			.other_arg = &other_arg
 		};
 
-		diff_setup(&opts);
+		repo_diff_setup(the_repository, &opts);
 		opts.file = rev->diffopt.file;
 		opts.use_color = rev->diffopt.use_color;
 		diff_setup_done(&opts);
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 3e2cdabfda5..80a5b7486f8 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1787,7 +1787,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		}
 
 		/* We want color (if set), but no pager */
-		diff_setup(&opts);
+		repo_diff_setup(the_repository, &opts);
 		opts.stat_width = -1; /* use full terminal width */
 		opts.stat_graph_width = -1; /* respect statGraphWidth config */
 		opts.output_format |=
diff --git a/builtin/stash.c b/builtin/stash.c
index dd5f67e7e6e..447c3b678f3 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -428,7 +428,7 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)
 	 * to the index before a merge was run) and the current index
 	 * (reflecting the changes brought in by the merge).
 	 */
-	diff_setup(&diff_opts);
+	repo_diff_setup(the_repository, &diff_opts);
 	diff_opts.flags.recursive = 1;
 	diff_opts.detect_rename = 0;
 	diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index 0cdf3f46304..3c0bd8781e7 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -73,6 +73,10 @@
 |
 - get_commit_tree
 + repo_get_commit_tree
+// diff.h
+|
+- diff_setup
++ repo_diff_setup
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index bf19e6a2487..00461ee86b3 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// diff.h
-- diff_setup
-+ repo_diff_setup
 // object-store.h
-|
 - read_object_file
 + repo_read_object_file
 |
diff --git a/diff.h b/diff.h
index 09627f6e84a..c759bedc269 100644
--- a/diff.h
+++ b/diff.h
@@ -536,9 +536,6 @@ int git_diff_basic_config(const char *var, const char *value, void *cb);
 int git_diff_heuristic_config(const char *var, const char *value, void *cb);
 void init_diff_ui_defaults(void);
 int git_diff_ui_config(const char *var, const char *value, void *cb);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define diff_setup(diffopts) repo_diff_setup(the_repository, diffopts)
-#endif
 void repo_diff_setup(struct repository *, struct diff_options *);
 struct option *add_diff_options(const struct option *, struct diff_options *);
 int diff_opt_parse(struct diff_options *, const char **, int, const char *);
diff --git a/log-tree.c b/log-tree.c
index 97d374c76d6..5c97bc403fb 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -852,7 +852,7 @@ void show_log(struct rev_info *opt)
 		 * Pass minimum required diff-options to range-diff; others
 		 * can be added later if deemed desirable.
 		 */
-		diff_setup(&opts);
+		repo_diff_setup(the_repository, &opts);
 		opts.file = opt->diffopt.file;
 		opts.use_color = opt->diffopt.use_color;
 		diff_setup_done(&opts);
diff --git a/range-diff.c b/range-diff.c
index 5bcf966f6c5..15d0bc35a87 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -485,7 +485,7 @@ static void output(struct string_list *a, struct string_list *b,
 	if (range_diff_opts->diffopt)
 		memcpy(&opts, range_diff_opts->diffopt, sizeof(opts));
 	else
-		diff_setup(&opts);
+		repo_diff_setup(the_repository, &opts);
 
 	opts.no_free = 1;
 	if (!opts.output_format)
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 09/17] cocci: apply the "object-store.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (7 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 08/17] cocci: apply the "diff.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 10/17] cocci: apply the "pretty.h" " Ævar Arnfjörð Bjarmason
                     ` (9 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"object-store.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 apply.c                                       |  9 +++++---
 archive.c                                     |  2 +-
 bisect.c                                      |  5 ++--
 blame.c                                       | 11 +++++----
 builtin/cat-file.c                            | 23 +++++++++++--------
 builtin/clone.c                               |  6 ++---
 builtin/difftool.c                            |  3 ++-
 builtin/fast-export.c                         |  5 ++--
 builtin/fast-import.c                         |  7 +++---
 builtin/fetch.c                               | 12 +++++-----
 builtin/grep.c                                |  6 +++--
 builtin/index-pack.c                          |  9 +++++---
 builtin/log.c                                 |  2 +-
 builtin/merge-tree.c                          |  9 +++++---
 builtin/mktag.c                               |  3 ++-
 builtin/notes.c                               |  7 +++---
 builtin/pack-objects.c                        | 22 ++++++++++++------
 builtin/receive-pack.c                        |  2 +-
 builtin/remote.c                              |  2 +-
 builtin/show-ref.c                            |  2 +-
 builtin/tag.c                                 |  4 ++--
 builtin/unpack-file.c                         |  2 +-
 builtin/unpack-objects.c                      |  5 ++--
 bulk-checkin.c                                |  2 +-
 bundle.c                                      |  2 +-
 cache-tree.c                                  |  8 +++----
 combine-diff.c                                |  2 +-
 commit.c                                      |  3 ++-
 contrib/coccinelle/the_repository.cocci       | 10 ++++++++
 .../coccinelle/the_repository.pending.cocci   | 10 --------
 dir.c                                         |  2 +-
 entry.c                                       |  3 ++-
 fetch-pack.c                                  |  8 +++----
 fmt-merge-msg.c                               |  3 ++-
 fsck.c                                        |  2 +-
 http-push.c                                   | 11 +++++----
 http-walker.c                                 |  4 ++--
 list-objects.c                                |  2 +-
 mailmap.c                                     |  2 +-
 match-trees.c                                 |  4 ++--
 merge-blobs.c                                 |  6 +++--
 merge-ort.c                                   |  2 +-
 merge-recursive.c                             |  5 ++--
 notes-cache.c                                 |  2 +-
 notes-merge.c                                 |  2 +-
 notes.c                                       | 12 ++++++----
 object-file.c                                 |  2 +-
 object-store.h                                |  7 ------
 read-cache.c                                  |  5 ++--
 reflog.c                                      |  5 ++--
 remote.c                                      |  2 +-
 rerere.c                                      |  5 ++--
 send-pack.c                                   |  6 ++---
 shallow.c                                     |  6 ++---
 submodule-config.c                            |  3 ++-
 tag.c                                         |  5 ++--
 tree.c                                        |  3 ++-
 upload-pack.c                                 |  8 +++----
 walker.c                                      |  2 +-
 xdiff-interface.c                             |  2 +-
 60 files changed, 184 insertions(+), 142 deletions(-)

diff --git a/apply.c b/apply.c
index ed6abc7722f..23789bb2d12 100644
--- a/apply.c
+++ b/apply.c
@@ -3203,7 +3203,8 @@ static int apply_binary(struct apply_state *state,
 		unsigned long size;
 		char *result;
 
-		result = read_object_file(&oid, &type, &size);
+		result = repo_read_object_file(the_repository, &oid, &type,
+					       &size);
 		if (!result)
 			return error(_("the necessary postimage %s for "
 				       "'%s' cannot be read"),
@@ -3266,7 +3267,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
 		unsigned long sz;
 		char *result;
 
-		result = read_object_file(oid, &type, &sz);
+		result = repo_read_object_file(the_repository, oid, &type,
+					       &sz);
 		if (!result)
 			return -1;
 		/* XXX read_sha1_file NUL-terminates */
@@ -3494,7 +3496,8 @@ static int resolve_to(struct image *image, const struct object_id *result_id)
 
 	clear_image(image);
 
-	image->buf = read_object_file(result_id, &type, &size);
+	image->buf = repo_read_object_file(the_repository, result_id, &type,
+					   &size);
 	if (!image->buf || type != OBJ_BLOB)
 		die("unable to read blob object %s", oid_to_hex(result_id));
 	image->len = size;
diff --git a/archive.c b/archive.c
index cb7ca69cce1..c6eaa6d6146 100644
--- a/archive.c
+++ b/archive.c
@@ -86,7 +86,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
 			       (args->tree ? &args->tree->object.oid : NULL), oid);
 
 	path += args->baselen;
-	buffer = read_object_file(oid, type, sizep);
+	buffer = repo_read_object_file(the_repository, oid, type, sizep);
 	if (buffer && S_ISREG(mode)) {
 		struct strbuf buf = STRBUF_INIT;
 		size_t size = 0;
diff --git a/bisect.c b/bisect.c
index b1639a9de7f..5998e4b2e32 100644
--- a/bisect.c
+++ b/bisect.c
@@ -149,8 +149,9 @@ static void show_list(const char *debug, int counted, int nr,
 		unsigned commit_flags = commit->object.flags;
 		enum object_type type;
 		unsigned long size;
-		char *buf = read_object_file(&commit->object.oid, &type,
-					     &size);
+		char *buf = repo_read_object_file(the_repository,
+						  &commit->object.oid, &type,
+						  &size);
 		const char *subject_start;
 		int subject_len;
 
diff --git a/blame.c b/blame.c
index 0f2751de83b..c42ceea5ae1 100644
--- a/blame.c
+++ b/blame.c
@@ -1029,8 +1029,9 @@ static void fill_origin_blob(struct diff_options *opt,
 				    &o->blob_oid, 1, &file->ptr, &file_size))
 			;
 		else
-			file->ptr = read_object_file(&o->blob_oid, &type,
-						     &file_size);
+			file->ptr = repo_read_object_file(the_repository,
+							  &o->blob_oid, &type,
+							  &file_size);
 		file->size = file_size;
 
 		if (!file->ptr)
@@ -2839,8 +2840,10 @@ void setup_scoreboard(struct blame_scoreboard *sb,
 				    &sb->final_buf_size))
 			;
 		else
-			sb->final_buf = read_object_file(&o->blob_oid, &type,
-							 &sb->final_buf_size);
+			sb->final_buf = repo_read_object_file(the_repository,
+							      &o->blob_oid,
+							      &type,
+							      &sb->final_buf_size);
 
 		if (!sb->final_buf)
 			die(_("cannot read blob %s for path %s"),
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 9e7e03ade41..a7bcb55b40d 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -64,7 +64,7 @@ static int filter_object(const char *path, unsigned mode,
 {
 	enum object_type type;
 
-	*buf = read_object_file(oid, &type, size);
+	*buf = repo_read_object_file(the_repository, oid, &type, size);
 	if (!*buf)
 		return error(_("cannot read object %s '%s'"),
 			     oid_to_hex(oid), path);
@@ -156,7 +156,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
 		goto cleanup;
 
 	case 'e':
-		return !has_object_file(&oid);
+		return !repo_has_object_file(the_repository, &oid);
 
 	case 'w':
 
@@ -191,7 +191,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
 			ret = stream_blob(&oid);
 			goto cleanup;
 		}
-		buf = read_object_file(&oid, &type, &size);
+		buf = repo_read_object_file(the_repository, &oid, &type,
+					    &size);
 		if (!buf)
 			die("Cannot read object %s", obj_name);
 
@@ -211,8 +212,10 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
 		if (exp_type_id == OBJ_BLOB) {
 			struct object_id blob_oid;
 			if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {
-				char *buffer = read_object_file(&oid, &type,
-								&size);
+				char *buffer = repo_read_object_file(the_repository,
+								     &oid,
+								     &type,
+								     &size);
 				const char *target;
 				if (!skip_prefix(buffer, "object ", &target) ||
 				    get_oid_hex(target, &blob_oid))
@@ -387,9 +390,10 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
 				if (!textconv_object(the_repository,
 						     data->rest, 0100644, oid,
 						     1, &contents, &size))
-					contents = read_object_file(oid,
-								    &type,
-								    &size);
+					contents = repo_read_object_file(the_repository,
+									 oid,
+									 &type,
+									 &size);
 				if (!contents)
 					die("could not convert '%s' %s",
 					    oid_to_hex(oid), data->rest);
@@ -406,7 +410,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
 		unsigned long size;
 		void *contents;
 
-		contents = read_object_file(oid, &type, &size);
+		contents = repo_read_object_file(the_repository, oid, &type,
+						 &size);
 
 		if (use_mailmap) {
 			size_t s = size;
diff --git a/builtin/clone.c b/builtin/clone.c
index 462c286274c..e50e7e2c06e 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -548,9 +548,9 @@ static void write_followtags(const struct ref *refs, const char *msg)
 			continue;
 		if (ends_with(ref->name, "^{}"))
 			continue;
-		if (!has_object_file_with_flags(&ref->old_oid,
-						OBJECT_INFO_QUICK |
-						OBJECT_INFO_SKIP_FETCH_OBJECT))
+		if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid,
+						     OBJECT_INFO_QUICK |
+						     OBJECT_INFO_SKIP_FETCH_OBJECT))
 			continue;
 		update_ref(msg, ref->name, &ref->old_oid, NULL, 0,
 			   UPDATE_REFS_DIE_ON_ERR);
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 01681d0fb88..74466332b58 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -296,7 +296,8 @@ static char *get_symlink(const struct object_id *oid, const char *path)
 	} else {
 		enum object_type type;
 		unsigned long size;
-		data = read_object_file(oid, &type, &size);
+		data = repo_read_object_file(the_repository, oid, &type,
+					     &size);
 		if (!data)
 			die(_("could not read object %s for symlink %s"),
 				oid_to_hex(oid), path);
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index fc5859dc9fa..166f51b100a 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -297,7 +297,7 @@ static void export_blob(const struct object_id *oid)
 		object = (struct object *)lookup_blob(the_repository, oid);
 		eaten = 0;
 	} else {
-		buf = read_object_file(oid, &type, &size);
+		buf = repo_read_object_file(the_repository, oid, &type, &size);
 		if (!buf)
 			die("could not read blob %s", oid_to_hex(oid));
 		if (check_object_signature(the_repository, oid, buf, size,
@@ -767,7 +767,8 @@ static void handle_tag(const char *name, struct tag *tag)
 		return;
 	}
 
-	buf = read_object_file(&tag->object.oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &tag->object.oid, &type,
+				    &size);
 	if (!buf)
 		die("could not read tag %s", oid_to_hex(&tag->object.oid));
 	message = memmem(buf, size, "\n\n", 2);
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index e4566490d91..7a7987b67de 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -1266,7 +1266,7 @@ static void load_tree(struct tree_entry *root)
 			die("Can't load tree %s", oid_to_hex(oid));
 	} else {
 		enum object_type type;
-		buf = read_object_file(oid, &type, &size);
+		buf = repo_read_object_file(the_repository, oid, &type, &size);
 		if (!buf || type != OBJ_TREE)
 			die("Can't load tree %s", oid_to_hex(oid));
 	}
@@ -2937,7 +2937,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
 	char *buf;
 
 	if (!oe || oe->pack_id == MAX_PACK_ID) {
-		buf = read_object_file(oid, &type, &size);
+		buf = repo_read_object_file(the_repository, oid, &type, &size);
 	} else {
 		type = oe->type;
 		buf = gfi_unpack_entry(oe, &size);
@@ -3045,7 +3045,8 @@ static struct object_entry *dereference(struct object_entry *oe,
 		buf = gfi_unpack_entry(oe, &size);
 	} else {
 		enum object_type unused;
-		buf = read_object_file(oid, &unused, &size);
+		buf = repo_read_object_file(the_repository, oid, &unused,
+					    &size);
 	}
 	if (!buf)
 		die("Can't load object %s", oid_to_hex(oid));
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 16dc2a33cac..0ee5d269768 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -408,9 +408,9 @@ static void find_non_local_tags(const struct ref *refs,
 		 */
 		if (ends_with(ref->name, "^{}")) {
 			if (item &&
-			    !has_object_file_with_flags(&ref->old_oid, quick_flags) &&
+			    !repo_has_object_file_with_flags(the_repository, &ref->old_oid, quick_flags) &&
 			    !oidset_contains(&fetch_oids, &ref->old_oid) &&
-			    !has_object_file_with_flags(&item->oid, quick_flags) &&
+			    !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
 			    !oidset_contains(&fetch_oids, &item->oid))
 				clear_item(item);
 			item = NULL;
@@ -424,7 +424,7 @@ static void find_non_local_tags(const struct ref *refs,
 		 * fetch.
 		 */
 		if (item &&
-		    !has_object_file_with_flags(&item->oid, quick_flags) &&
+		    !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
 		    !oidset_contains(&fetch_oids, &item->oid))
 			clear_item(item);
 
@@ -445,7 +445,7 @@ static void find_non_local_tags(const struct ref *refs,
 	 * checked to see if it needs fetching.
 	 */
 	if (item &&
-	    !has_object_file_with_flags(&item->oid, quick_flags) &&
+	    !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
 	    !oidset_contains(&fetch_oids, &item->oid))
 		clear_item(item);
 
@@ -1322,8 +1322,8 @@ static int check_exist_and_connected(struct ref *ref_map)
 	 * we need all direct targets to exist.
 	 */
 	for (r = rm; r; r = r->next) {
-		if (!has_object_file_with_flags(&r->old_oid,
-						OBJECT_INFO_SKIP_FETCH_OBJECT))
+		if (!repo_has_object_file_with_flags(the_repository, &r->old_oid,
+						     OBJECT_INFO_SKIP_FETCH_OBJECT))
 			return -1;
 	}
 
diff --git a/builtin/grep.c b/builtin/grep.c
index c590fcb19dd..49fc0c69095 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -562,7 +562,8 @@ static int grep_cache(struct grep_opt *opt,
 			void *data;
 			unsigned long size;
 
-			data = read_object_file(&ce->oid, &type, &size);
+			data = repo_read_object_file(the_repository, &ce->oid,
+						     &type, &size);
 			init_tree_desc(&tree, data, size);
 
 			hit |= grep_tree(opt, pathspec, &tree, &name, 0, 0);
@@ -652,7 +653,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
 			void *data;
 			unsigned long size;
 
-			data = read_object_file(&entry.oid, &type, &size);
+			data = repo_read_object_file(the_repository,
+						     &entry.oid, &type, &size);
 			if (!data)
 				die(_("unable to read tree (%s)"),
 				    oid_to_hex(&entry.oid));
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index b451755f405..e823a73b357 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -804,7 +804,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
 	if (startup_info->have_repository) {
 		read_lock();
 		collision_test_needed =
-			has_object_file_with_flags(oid, OBJECT_INFO_QUICK);
+			repo_has_object_file_with_flags(the_repository, oid,
+							OBJECT_INFO_QUICK);
 		read_unlock();
 	}
 
@@ -824,7 +825,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
 			die(_("cannot read existing object info %s"), oid_to_hex(oid));
 		if (has_type != type || has_size != size)
 			die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
-		has_data = read_object_file(oid, &has_type, &has_size);
+		has_data = repo_read_object_file(the_repository, oid,
+						 &has_type, &has_size);
 		read_unlock();
 		if (!data)
 			data = new_data = get_data_from_pack(obj_entry);
@@ -1417,7 +1419,8 @@ static void fix_unresolved_deltas(struct hashfile *f)
 
 		if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
 			continue;
-		data = read_object_file(&d->oid, &type, &size);
+		data = repo_read_object_file(the_repository, &d->oid, &type,
+					     &size);
 		if (!data)
 			continue;
 
diff --git a/builtin/log.c b/builtin/log.c
index 11ba99d6b48..28085547aa8 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -676,7 +676,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
 {
 	unsigned long size;
 	enum object_type type;
-	char *buf = read_object_file(oid, &type, &size);
+	char *buf = repo_read_object_file(the_repository, oid, &type, &size);
 	int offset = 0;
 
 	if (!buf)
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index dd23ee684c7..590532706eb 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -70,7 +70,9 @@ static void *result(struct merge_list *entry, unsigned long *size)
 	const char *path = entry->path;
 
 	if (!entry->stage)
-		return read_object_file(&entry->blob->object.oid, &type, size);
+		return repo_read_object_file(the_repository,
+					     &entry->blob->object.oid, &type,
+					     size);
 	base = NULL;
 	if (entry->stage == 1) {
 		base = entry->blob;
@@ -93,8 +95,9 @@ static void *origin(struct merge_list *entry, unsigned long *size)
 	enum object_type type;
 	while (entry) {
 		if (entry->stage == 2)
-			return read_object_file(&entry->blob->object.oid,
-						&type, size);
+			return repo_read_object_file(the_repository,
+						     &entry->blob->object.oid,
+						     &type, size);
 		entry = entry->link;
 	}
 	return NULL;
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 42c2457c705..4849b8b37c3 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -52,7 +52,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)
 	void *buffer;
 	const struct object_id *repl;
 
-	buffer = read_object_file(tagged_oid, &type, &size);
+	buffer = repo_read_object_file(the_repository, tagged_oid, &type,
+				       &size);
 	if (!buffer)
 		die(_("could not read tagged object '%s'"),
 		    oid_to_hex(tagged_oid));
diff --git a/builtin/notes.c b/builtin/notes.c
index 9aea5a4b27b..4b13943be7f 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -126,7 +126,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)
 {
 	unsigned long size;
 	enum object_type type;
-	char *buf = read_object_file(oid, &type, &size);
+	char *buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (buf) {
 		if (size)
 			write_or_die(fd, buf, size);
@@ -261,7 +261,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
 
 	if (repo_get_oid(the_repository, arg, &object))
 		die(_("failed to resolve '%s' as a valid ref."), arg);
-	if (!(buf = read_object_file(&object, &type, &len)))
+	if (!(buf = repo_read_object_file(the_repository, &object, &type, &len)))
 		die(_("failed to read object '%s'."), arg);
 	if (type != OBJ_BLOB) {
 		free(buf);
@@ -618,7 +618,8 @@ static int append_edit(int argc, const char **argv, const char *prefix)
 		/* Append buf to previous note contents */
 		unsigned long size;
 		enum object_type type;
-		char *prev_buf = read_object_file(note, &type, &size);
+		char *prev_buf = repo_read_object_file(the_repository, note,
+						       &type, &size);
 
 		strbuf_grow(&d.buf, size + 1);
 		if (d.buf.len && prev_buf && size)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 545b8bddc8e..068e6326c1d 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -290,11 +290,13 @@ static void *get_delta(struct object_entry *entry)
 	void *buf, *base_buf, *delta_buf;
 	enum object_type type;
 
-	buf = read_object_file(&entry->idx.oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &entry->idx.oid, &type,
+				    &size);
 	if (!buf)
 		die(_("unable to read %s"), oid_to_hex(&entry->idx.oid));
-	base_buf = read_object_file(&DELTA(entry)->idx.oid, &type,
-				    &base_size);
+	base_buf = repo_read_object_file(the_repository,
+					 &DELTA(entry)->idx.oid, &type,
+					 &base_size);
 	if (!base_buf)
 		die("unable to read %s",
 		    oid_to_hex(&DELTA(entry)->idx.oid));
@@ -456,7 +458,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
 				       &size, NULL)) != NULL)
 			buf = NULL;
 		else {
-			buf = read_object_file(&entry->idx.oid, &type, &size);
+			buf = repo_read_object_file(the_repository,
+						    &entry->idx.oid, &type,
+						    &size);
 			if (!buf)
 				die(_("unable to read %s"),
 				    oid_to_hex(&entry->idx.oid));
@@ -1667,7 +1671,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
 	/* Did not find one.  Either we got a bogus request or
 	 * we need to read and perhaps cache.
 	 */
-	data = read_object_file(oid, &type, &size);
+	data = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!data)
 		return NULL;
 	if (type != OBJ_TREE) {
@@ -2527,7 +2531,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
 	/* Load data if not already done */
 	if (!trg->data) {
 		packing_data_lock(&to_pack);
-		trg->data = read_object_file(&trg_entry->idx.oid, &type, &sz);
+		trg->data = repo_read_object_file(the_repository,
+						  &trg_entry->idx.oid, &type,
+						  &sz);
 		packing_data_unlock(&to_pack);
 		if (!trg->data)
 			die(_("object %s cannot be read"),
@@ -2540,7 +2546,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
 	}
 	if (!src->data) {
 		packing_data_lock(&to_pack);
-		src->data = read_object_file(&src_entry->idx.oid, &type, &sz);
+		src->data = repo_read_object_file(the_repository,
+						  &src_entry->idx.oid, &type,
+						  &sz);
 		packing_data_unlock(&to_pack);
 		if (!src->data) {
 			if (src_entry->preferred_base) {
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index e2b7202b04c..90d117beaf5 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1493,7 +1493,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
 		}
 	}
 
-	if (!is_null_oid(new_oid) && !has_object_file(new_oid)) {
+	if (!is_null_oid(new_oid) && !repo_has_object_file(the_repository, new_oid)) {
 		error("unpack should have generated %s, "
 		      "but I can't find it!", oid_to_hex(new_oid));
 		ret = "bad pack";
diff --git a/builtin/remote.c b/builtin/remote.c
index 729f6f3643a..a6b100dce7f 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -443,7 +443,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
 			info->status = PUSH_STATUS_UPTODATE;
 		else if (is_null_oid(&ref->old_oid))
 			info->status = PUSH_STATUS_CREATE;
-		else if (has_object_file(&ref->old_oid) &&
+		else if (repo_has_object_file(the_repository, &ref->old_oid) &&
 			 ref_newer(&ref->new_oid, &ref->old_oid))
 			info->status = PUSH_STATUS_FASTFORWARD;
 		else
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index b5a68e23e65..63a5bb1efae 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -27,7 +27,7 @@ static void show_one(const char *refname, const struct object_id *oid)
 	const char *hex;
 	struct object_id peeled;
 
-	if (!has_object_file(oid))
+	if (!repo_has_object_file(the_repository, oid))
 		die("git show-ref: bad ref %s (%s)", refname,
 		    oid_to_hex(oid));
 
diff --git a/builtin/tag.c b/builtin/tag.c
index 7af7eaa4139..61fd55d62e2 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -211,7 +211,7 @@ static void write_tag_body(int fd, const struct object_id *oid)
 	struct strbuf payload = STRBUF_INIT;
 	struct strbuf signature = STRBUF_INIT;
 
-	orig = buf = read_object_file(oid, &type, &size);
+	orig = buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!buf)
 		return;
 	if (parse_signature(buf, size, &payload, &signature)) {
@@ -362,7 +362,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
 		strbuf_addstr(sb, "object of unknown type");
 		break;
 	case OBJ_COMMIT:
-		if ((buf = read_object_file(oid, &type, &size))) {
+		if ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {
 			subject_len = find_commit_subject(buf, &subject_start);
 			strbuf_insert(sb, sb->len, subject_start, subject_len);
 		} else {
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index b9e258a553f..9cbc295e193 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -11,7 +11,7 @@ static char *create_temp_file(struct object_id *oid)
 	unsigned long size;
 	int fd;
 
-	buf = read_object_file(oid, &type, &size);
+	buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!buf || type != OBJ_BLOB)
 		die("unable to read blob object %s", oid_to_hex(oid));
 
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 1908dcfcffb..2e0ca419190 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -444,7 +444,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
 		delta_data = get_data(delta_size);
 		if (!delta_data)
 			return;
-		if (has_object_file(&base_oid))
+		if (repo_has_object_file(the_repository, &base_oid))
 			; /* Ok we have this one */
 		else if (resolve_against_held(nr, &base_oid,
 					      delta_data, delta_size))
@@ -510,7 +510,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
 	if (resolve_against_held(nr, &base_oid, delta_data, delta_size))
 		return;
 
-	base = read_object_file(&base_oid, &type, &base_size);
+	base = repo_read_object_file(the_repository, &base_oid, &type,
+				     &base_size);
 	if (!base) {
 		error("failed to read delta-pack base object %s",
 		      oid_to_hex(&base_oid));
diff --git a/bulk-checkin.c b/bulk-checkin.c
index d64cd5c52d0..556a34ba7d4 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -126,7 +126,7 @@ static int already_written(struct bulk_checkin_packfile *state, struct object_id
 	int i;
 
 	/* The object may already exist in the repository */
-	if (has_object_file(oid))
+	if (repo_has_object_file(the_repository, oid))
 		return 1;
 
 	/* Might want to keep the list sorted */
diff --git a/bundle.c b/bundle.c
index 99d7de97f6c..bce0c7f99e8 100644
--- a/bundle.c
+++ b/bundle.c
@@ -294,7 +294,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
 	if (revs->max_age == -1 && revs->min_age == -1)
 		goto out;
 
-	buf = read_object_file(&tag->oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &tag->oid, &type, &size);
 	if (!buf)
 		goto out;
 	line = memmem(buf, size, "\ntagger ", 8);
diff --git a/cache-tree.c b/cache-tree.c
index 9d46ecef091..d71b9befd9a 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -231,7 +231,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
 	int i;
 	if (!it)
 		return 0;
-	if (it->entry_count < 0 || !has_object_file(&it->oid))
+	if (it->entry_count < 0 || !repo_has_object_file(the_repository, &it->oid))
 		return 0;
 	for (i = 0; i < it->subtree_nr; i++) {
 		if (!cache_tree_fully_valid(it->down[i]->cache_tree))
@@ -282,7 +282,7 @@ static int update_one(struct cache_tree *it,
 		}
 	}
 
-	if (0 <= it->entry_count && has_object_file(&it->oid))
+	if (0 <= it->entry_count && repo_has_object_file(the_repository, &it->oid))
 		return it->entry_count;
 
 	/*
@@ -388,7 +388,7 @@ static int update_one(struct cache_tree *it,
 		ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
 			!must_check_existence(ce);
 		if (is_null_oid(oid) ||
-		    (!ce_missing_ok && !has_object_file(oid))) {
+		    (!ce_missing_ok && !repo_has_object_file(the_repository, oid))) {
 			strbuf_release(&buffer);
 			if (expected_missing)
 				return -1;
@@ -436,7 +436,7 @@ static int update_one(struct cache_tree *it,
 		struct object_id oid;
 		hash_object_file(the_hash_algo, buffer.buf, buffer.len,
 				 OBJ_TREE, &oid);
-		if (has_object_file_with_flags(&oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
+		if (repo_has_object_file_with_flags(the_repository, &oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
 			oidcpy(&it->oid, &oid);
 		else
 			to_invalidate = 1;
diff --git a/combine-diff.c b/combine-diff.c
index e917362faf7..6077d4ec498 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -333,7 +333,7 @@ static char *grab_blob(struct repository *r,
 		*size = fill_textconv(r, textconv, df, &blob);
 		free_filespec(df);
 	} else {
-		blob = read_object_file(oid, &type, size);
+		blob = repo_read_object_file(the_repository, oid, &type, size);
 		if (type != OBJ_BLOB)
 			die("object '%s' is not a blob!", oid_to_hex(oid));
 	}
diff --git a/commit.c b/commit.c
index 127ec79b2d3..cfd14f7d975 100644
--- a/commit.c
+++ b/commit.c
@@ -1215,7 +1215,8 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header
 	desc = merge_remote_util(parent);
 	if (!desc || !desc->obj)
 		return;
-	buf = read_object_file(&desc->obj->oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &desc->obj->oid, &type,
+				    &size);
 	if (!buf || type != OBJ_TAG)
 		goto free_return;
 	if (!parse_signature(buf, size, &payload, &signature))
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index 3c0bd8781e7..fa159aba5b5 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -77,6 +77,16 @@
 |
 - diff_setup
 + repo_diff_setup
+// object-store.h
+|
+- read_object_file
++ repo_read_object_file
+|
+- has_object_file
++ repo_has_object_file
+|
+- has_object_file_with_flags
++ repo_has_object_file_with_flags
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 00461ee86b3..69e9694111e 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,17 +5,7 @@
 @@
 @@
 (
-// object-store.h
-- read_object_file
-+ repo_read_object_file
-|
-- has_object_file
-+ repo_has_object_file
-|
-- has_object_file_with_flags
-+ repo_has_object_file_with_flags
 // pretty.h
-|
 - format_commit_message
 + repo_format_commit_message
 // packfile.h
diff --git a/dir.c b/dir.c
index d5bb199f4b4..b06a100514d 100644
--- a/dir.c
+++ b/dir.c
@@ -268,7 +268,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
 	*size_out = 0;
 	*data_out = NULL;
 
-	data = read_object_file(oid, &type, &sz);
+	data = repo_read_object_file(the_repository, oid, &type, &sz);
 	if (!data || type != OBJ_BLOB) {
 		free(data);
 		return -1;
diff --git a/entry.c b/entry.c
index c97cfa833bb..8c21f98b9e8 100644
--- a/entry.c
+++ b/entry.c
@@ -87,7 +87,8 @@ void *read_blob_entry(const struct cache_entry *ce, size_t *size)
 {
 	enum object_type type;
 	unsigned long ul;
-	void *blob_data = read_object_file(&ce->oid, &type, &ul);
+	void *blob_data = repo_read_object_file(the_repository, &ce->oid,
+						&type, &ul);
 
 	*size = ul;
 	if (blob_data) {
diff --git a/fetch-pack.c b/fetch-pack.c
index 4ddabb4ec76..12675052f97 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -764,9 +764,9 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
 		if (!commit) {
 			struct object *o;
 
-			if (!has_object_file_with_flags(&ref->old_oid,
-						OBJECT_INFO_QUICK |
-						OBJECT_INFO_SKIP_FETCH_OBJECT))
+			if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid,
+							     OBJECT_INFO_QUICK |
+							     OBJECT_INFO_SKIP_FETCH_OBJECT))
 				continue;
 			o = parse_object(the_repository, &ref->old_oid);
 			if (!o || o->type != OBJ_COMMIT)
@@ -1965,7 +1965,7 @@ static void update_shallow(struct fetch_pack_args *args,
 		struct oid_array extra = OID_ARRAY_INIT;
 		struct object_id *oid = si->shallow->oid;
 		for (i = 0; i < si->shallow->nr; i++)
-			if (has_object_file(&oid[i]))
+			if (repo_has_object_file(the_repository, &oid[i]))
 				oid_array_append(&extra, &oid[i]);
 		if (extra.nr) {
 			setup_alternate_shallow(&shallow_lock,
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 29a1afa2485..5aab1d06619 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -518,7 +518,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
 		struct object_id *oid = origins.items[i].util;
 		enum object_type type;
 		unsigned long size;
-		char *buf = read_object_file(oid, &type, &size);
+		char *buf = repo_read_object_file(the_repository, oid, &type,
+						  &size);
 		char *origbuf = buf;
 		unsigned long len = size;
 		struct signature_check sigc = { NULL };
diff --git a/fsck.c b/fsck.c
index 0d752d57717..adbe8bf59e7 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1334,7 +1334,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,
 		if (oidset_contains(blobs_done, oid))
 			continue;
 
-		buf = read_object_file(oid, &type, &size);
+		buf = repo_read_object_file(the_repository, oid, &type, &size);
 		if (!buf) {
 			if (is_promisor_object(oid))
 				continue;
diff --git a/http-push.c b/http-push.c
index e149daeff3d..8c852ff646b 100644
--- a/http-push.c
+++ b/http-push.c
@@ -363,7 +363,8 @@ static void start_put(struct transfer_request *request)
 	ssize_t size;
 	git_zstream stream;
 
-	unpacked = read_object_file(&request->obj->oid, &type, &len);
+	unpacked = repo_read_object_file(the_repository, &request->obj->oid,
+					 &type, &len);
 	hdrlen = format_object_header(hdr, sizeof(hdr), type, len);
 
 	/* Set it up */
@@ -1428,7 +1429,7 @@ static void one_remote_ref(const char *refname)
 	 * Fetch a copy of the object if it doesn't exist locally - it
 	 * may be required for updating server info later.
 	 */
-	if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
+	if (repo->can_update_info_refs && !repo_has_object_file(the_repository, &ref->old_oid)) {
 		obj = lookup_unknown_object(the_repository, &ref->old_oid);
 		fprintf(stderr,	"  fetch %s for %s\n",
 			oid_to_hex(&ref->old_oid), refname);
@@ -1629,14 +1630,14 @@ static int delete_remote_branch(const char *pattern, int force)
 			return error("Remote HEAD symrefs too deep");
 		if (is_null_oid(&head_oid))
 			return error("Unable to resolve remote HEAD");
-		if (!has_object_file(&head_oid))
+		if (!repo_has_object_file(the_repository, &head_oid))
 			return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid));
 
 		/* Remote branch must resolve to a known object */
 		if (is_null_oid(&remote_ref->old_oid))
 			return error("Unable to resolve remote branch %s",
 				     remote_ref->name);
-		if (!has_object_file(&remote_ref->old_oid))
+		if (!repo_has_object_file(the_repository, &remote_ref->old_oid))
 			return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, oid_to_hex(&remote_ref->old_oid));
 
 		/* Remote branch must be an ancestor of remote HEAD */
@@ -1856,7 +1857,7 @@ int cmd_main(int argc, const char **argv)
 		if (!force_all &&
 		    !is_null_oid(&ref->old_oid) &&
 		    !ref->force) {
-			if (!has_object_file(&ref->old_oid) ||
+			if (!repo_has_object_file(the_repository, &ref->old_oid) ||
 			    !ref_newer(&ref->peer_ref->new_oid,
 				       &ref->old_oid)) {
 				/*
diff --git a/http-walker.c b/http-walker.c
index c3e902c40e6..4588e6a340a 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -136,7 +136,7 @@ static int fill_active_slot(struct walker *walker)
 	list_for_each_safe(pos, tmp, head) {
 		obj_req = list_entry(pos, struct object_request, node);
 		if (obj_req->state == WAITING) {
-			if (has_object_file(&obj_req->oid))
+			if (repo_has_object_file(the_repository, &obj_req->oid))
 				obj_req->state = COMPLETE;
 			else {
 				start_object_request(walker, obj_req);
@@ -493,7 +493,7 @@ static int fetch_object(struct walker *walker, unsigned char *hash)
 	if (!obj_req)
 		return error("Couldn't find request for %s in the queue", hex);
 
-	if (has_object_file(&obj_req->oid)) {
+	if (repo_has_object_file(the_repository, &obj_req->oid)) {
 		if (obj_req->req)
 			abort_http_object_request(obj_req->req);
 		abort_object_request(obj_req);
diff --git a/list-objects.c b/list-objects.c
index d75132cfd73..6e6e7ce61ea 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -65,7 +65,7 @@ static void process_blob(struct traversal_context *ctx,
 	 * of missing objects.
 	 */
 	if (ctx->revs->exclude_promisor_objects &&
-	    !has_object_file(&obj->oid) &&
+	    !repo_has_object_file(the_repository, &obj->oid) &&
 	    is_promisor_object(&obj->oid))
 		return;
 
diff --git a/mailmap.c b/mailmap.c
index ed8289aea58..f68f664bb1b 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -216,7 +216,7 @@ static int read_mailmap_blob(struct string_list *map, const char *name)
 	if (repo_get_oid(the_repository, name, &oid) < 0)
 		return 0;
 
-	buf = read_object_file(&oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &oid, &type, &size);
 	if (!buf)
 		return error("unable to read mailmap object at %s", name);
 	if (type != OBJ_BLOB)
diff --git a/match-trees.c b/match-trees.c
index c38dcbac7c6..5877fc64a8f 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -56,7 +56,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,
 	enum object_type type;
 	unsigned long size;
 
-	buffer = read_object_file(hash, &type, &size);
+	buffer = repo_read_object_file(the_repository, hash, &type, &size);
 	if (!buffer)
 		die("unable to read tree (%s)", oid_to_hex(hash));
 	if (type != OBJ_TREE)
@@ -189,7 +189,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
 	if (*subpath)
 		subpath++;
 
-	buf = read_object_file(oid1, &type, &sz);
+	buf = repo_read_object_file(the_repository, oid1, &type, &sz);
 	if (!buf)
 		die("cannot read tree %s", oid_to_hex(oid1));
 	init_tree_desc(&desc, buf, sz);
diff --git a/merge-blobs.c b/merge-blobs.c
index aedcab81138..5632ff6abb6 100644
--- a/merge-blobs.c
+++ b/merge-blobs.c
@@ -12,7 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
 	unsigned long size;
 	enum object_type type;
 
-	buf = read_object_file(&obj->object.oid, &type, &size);
+	buf = repo_read_object_file(the_repository, &obj->object.oid, &type,
+				    &size);
 	if (!buf)
 		return -1;
 	if (type != OBJ_BLOB) {
@@ -78,7 +79,8 @@ void *merge_blobs(struct index_state *istate, const char *path,
 			return NULL;
 		if (!our)
 			our = their;
-		return read_object_file(&our->object.oid, &type, size);
+		return repo_read_object_file(the_repository, &our->object.oid,
+					     &type, size);
 	}
 
 	if (fill_mmfile_blob(&f1, our) < 0)
diff --git a/merge-ort.c b/merge-ort.c
index 186e26d90a0..607e2c263f1 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -3506,7 +3506,7 @@ static int read_oid_strbuf(struct merge_options *opt,
 	void *buf;
 	enum object_type type;
 	unsigned long size;
-	buf = read_object_file(oid, &type, &size);
+	buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!buf)
 		return err(opt, _("cannot read object %s"), oid_to_hex(oid));
 	if (type != OBJ_BLOB) {
diff --git a/merge-recursive.c b/merge-recursive.c
index 6eeb4844f38..9c80b7aa3a7 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -951,7 +951,8 @@ static int update_file_flags(struct merge_options *opt,
 			goto update_index;
 		}
 
-		buf = read_object_file(&contents->oid, &type, &size);
+		buf = repo_read_object_file(the_repository, &contents->oid,
+					    &type, &size);
 		if (!buf) {
 			ret = err(opt, _("cannot read object %s '%s'"),
 				  oid_to_hex(&contents->oid), path);
@@ -3021,7 +3022,7 @@ static int read_oid_strbuf(struct merge_options *opt,
 	void *buf;
 	enum object_type type;
 	unsigned long size;
-	buf = read_object_file(oid, &type, &size);
+	buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!buf)
 		return err(opt, _("cannot read object %s"), oid_to_hex(oid));
 	if (type != OBJ_BLOB) {
diff --git a/notes-cache.c b/notes-cache.c
index 9dfd251a815..38466091360 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -81,7 +81,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,
 	value_oid = get_note(&c->tree, key_oid);
 	if (!value_oid)
 		return NULL;
-	value = read_object_file(value_oid, &type, &size);
+	value = repo_read_object_file(the_repository, value_oid, &type, &size);
 
 	*outsize = size;
 	return value;
diff --git a/notes-merge.c b/notes-merge.c
index d26c826963e..571ecf15c7e 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -327,7 +327,7 @@ static void write_note_to_worktree(const struct object_id *obj,
 {
 	enum object_type type;
 	unsigned long size;
-	void *buf = read_object_file(note, &type, &size);
+	void *buf = repo_read_object_file(the_repository, note, &type, &size);
 
 	if (!buf)
 		die("cannot read note %s for object %s",
diff --git a/notes.c b/notes.c
index 427cfdac294..d40affc0f2f 100644
--- a/notes.c
+++ b/notes.c
@@ -788,7 +788,7 @@ static int prune_notes_helper(const struct object_id *object_oid,
 	struct note_delete_list **l = (struct note_delete_list **) cb_data;
 	struct note_delete_list *n;
 
-	if (has_object_file(object_oid))
+	if (repo_has_object_file(the_repository, object_oid))
 		return 0; /* nothing to do for this note */
 
 	/* failed to find object => prune this note */
@@ -809,13 +809,15 @@ int combine_notes_concatenate(struct object_id *cur_oid,
 
 	/* read in both note blob objects */
 	if (!is_null_oid(new_oid))
-		new_msg = read_object_file(new_oid, &new_type, &new_len);
+		new_msg = repo_read_object_file(the_repository, new_oid,
+						&new_type, &new_len);
 	if (!new_msg || !new_len || new_type != OBJ_BLOB) {
 		free(new_msg);
 		return 0;
 	}
 	if (!is_null_oid(cur_oid))
-		cur_msg = read_object_file(cur_oid, &cur_type, &cur_len);
+		cur_msg = repo_read_object_file(the_repository, cur_oid,
+						&cur_type, &cur_len);
 	if (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {
 		free(cur_msg);
 		free(new_msg);
@@ -871,7 +873,7 @@ static int string_list_add_note_lines(struct string_list *list,
 		return 0;
 
 	/* read_sha1_file NUL-terminates */
-	data = read_object_file(oid, &t, &len);
+	data = repo_read_object_file(the_repository, oid, &t, &len);
 	if (t != OBJ_BLOB || !data || !len) {
 		free(data);
 		return t != OBJ_BLOB || !data;
@@ -1266,7 +1268,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid
 	if (!oid)
 		return;
 
-	if (!(msg = read_object_file(oid, &type, &msglen)) || type != OBJ_BLOB) {
+	if (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) {
 		free(msg);
 		return;
 	}
diff --git a/object-file.c b/object-file.c
index 8fab8dbe80b..5944f51a3e0 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1680,7 +1680,7 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,
 	struct cached_object *co;
 
 	hash_object_file(the_hash_algo, buf, len, type, oid);
-	if (has_object_file_with_flags(oid, OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT) ||
+	if (repo_has_object_file_with_flags(the_repository, oid, OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT) ||
 	    find_cached_object(oid))
 		return 0;
 	ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc);
diff --git a/object-store.h b/object-store.h
index 82201ec3e7b..62a683af4d6 100644
--- a/object-store.h
+++ b/object-store.h
@@ -245,9 +245,6 @@ void *repo_read_object_file(struct repository *r,
 			    const struct object_id *oid,
 			    enum object_type *type,
 			    unsigned long *size);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define read_object_file(oid, type, size) repo_read_object_file(the_repository, oid, type, size)
-#endif
 
 /* Read and unpack an object file into memory, write memory to an object file */
 int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);
@@ -387,10 +384,6 @@ int has_object(struct repository *r, const struct object_id *oid,
 int repo_has_object_file(struct repository *r, const struct object_id *oid);
 int repo_has_object_file_with_flags(struct repository *r,
 				    const struct object_id *oid, int flags);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define has_object_file(oid) repo_has_object_file(the_repository, oid)
-#define has_object_file_with_flags(oid, flags) repo_has_object_file_with_flags(the_repository, oid, flags)
-#endif
 
 /*
  * Return true iff an alternate object database has a loose object
diff --git a/read-cache.c b/read-cache.c
index c1d47b9fc83..4518a40ac06 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -265,7 +265,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)
 	if (strbuf_readlink(&sb, ce->name, expected_size))
 		return -1;
 
-	buffer = read_object_file(&ce->oid, &type, &size);
+	buffer = repo_read_object_file(the_repository, &ce->oid, &type, &size);
 	if (buffer) {
 		if (size == sb.len)
 			match = memcmp(buffer, sb.buf, size);
@@ -3555,7 +3555,8 @@ void *read_blob_data_from_index(struct index_state *istate,
 	}
 	if (pos < 0)
 		return NULL;
-	data = read_object_file(&istate->cache[pos]->oid, &type, &sz);
+	data = repo_read_object_file(the_repository, &istate->cache[pos]->oid,
+				     &type, &sz);
 	if (!data || type != OBJ_BLOB) {
 		free(data);
 		return NULL;
diff --git a/reflog.c b/reflog.c
index 6e8362e7a2f..510663e1e51 100644
--- a/reflog.c
+++ b/reflog.c
@@ -28,7 +28,8 @@ static int tree_is_complete(const struct object_id *oid)
 	if (!tree->buffer) {
 		enum object_type type;
 		unsigned long size;
-		void *data = read_object_file(oid, &type, &size);
+		void *data = repo_read_object_file(the_repository, oid, &type,
+						   &size);
 		if (!data) {
 			tree->object.flags |= INCOMPLETE;
 			return 0;
@@ -39,7 +40,7 @@ static int tree_is_complete(const struct object_id *oid)
 	init_tree_desc(&desc, tree->buffer, tree->size);
 	complete = 1;
 	while (tree_entry(&desc, &entry)) {
-		if (!has_object_file(&entry.oid) ||
+		if (!repo_has_object_file(the_repository, &entry.oid) ||
 		    (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {
 			tree->object.flags |= INCOMPLETE;
 			complete = 0;
diff --git a/remote.c b/remote.c
index 37cb5213795..9219ebb8962 100644
--- a/remote.c
+++ b/remote.c
@@ -1761,7 +1761,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
 		if (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {
 			if (starts_with(ref->name, "refs/tags/"))
 				reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
-			else if (!has_object_file(&ref->old_oid))
+			else if (!repo_has_object_file(the_repository, &ref->old_oid))
 				reject_reason = REF_STATUS_REJECT_FETCH_FIRST;
 			else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||
 				 !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))
diff --git a/rerere.c b/rerere.c
index a67abaab077..0ec546b744f 100644
--- a/rerere.c
+++ b/rerere.c
@@ -967,8 +967,9 @@ static int handle_cache(struct index_state *istate,
 			break;
 		i = ce_stage(ce) - 1;
 		if (!mmfile[i].ptr) {
-			mmfile[i].ptr = read_object_file(&ce->oid, &type,
-							 &size);
+			mmfile[i].ptr = repo_read_object_file(the_repository,
+							      &ce->oid, &type,
+							      &size);
 			mmfile[i].size = size;
 		}
 	}
diff --git a/send-pack.c b/send-pack.c
index 423a5cfe22d..2cb313a5023 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -43,9 +43,9 @@ int option_parse_push_signed(const struct option *opt,
 static void feed_object(const struct object_id *oid, FILE *fh, int negative)
 {
 	if (negative &&
-	    !has_object_file_with_flags(oid,
-					OBJECT_INFO_SKIP_FETCH_OBJECT |
-					OBJECT_INFO_QUICK))
+	    !repo_has_object_file_with_flags(the_repository, oid,
+					     OBJECT_INFO_SKIP_FETCH_OBJECT |
+					     OBJECT_INFO_QUICK))
 		return;
 
 	if (negative)
diff --git a/shallow.c b/shallow.c
index 138bcfe009c..ce21f66e5e1 100644
--- a/shallow.c
+++ b/shallow.c
@@ -303,7 +303,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
 	if (graft->nr_parent != -1)
 		return 0;
 	if (data->flags & QUICK) {
-		if (!has_object_file(&graft->oid))
+		if (!repo_has_object_file(the_repository, &graft->oid))
 			return 0;
 	} else if (data->flags & SEEN_ONLY) {
 		struct commit *c = lookup_commit(the_repository, &graft->oid);
@@ -468,7 +468,7 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
 	ALLOC_ARRAY(info->ours, sa->nr);
 	ALLOC_ARRAY(info->theirs, sa->nr);
 	for (i = 0; i < sa->nr; i++) {
-		if (has_object_file(sa->oid + i)) {
+		if (repo_has_object_file(the_repository, sa->oid + i)) {
 			struct commit_graft *graft;
 			graft = lookup_commit_graft(the_repository,
 						    &sa->oid[i]);
@@ -496,7 +496,7 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)
 	for (i = dst = 0; i < info->nr_theirs; i++) {
 		if (i != dst)
 			info->theirs[dst] = info->theirs[i];
-		if (has_object_file(oid + info->theirs[i]))
+		if (repo_has_object_file(the_repository, oid + info->theirs[i]))
 			dst++;
 	}
 	info->nr_theirs = dst;
diff --git a/submodule-config.c b/submodule-config.c
index 57972c3e131..d0111e99937 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -590,7 +590,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,
 	if (submodule)
 		goto out;
 
-	config = read_object_file(&oid, &type, &config_size);
+	config = repo_read_object_file(the_repository, &oid, &type,
+				       &config_size);
 	if (!config || type != OBJ_BLOB)
 		goto out;
 
diff --git a/tag.c b/tag.c
index 85c348ad824..911cd3178ca 100644
--- a/tag.c
+++ b/tag.c
@@ -55,7 +55,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
 				repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
 				type_name(type));
 
-	buf = read_object_file(oid, &type, &size);
+	buf = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!buf)
 		return error("%s: unable to read file.",
 				name_to_report ?
@@ -217,7 +217,8 @@ int parse_tag(struct tag *item)
 
 	if (item->object.parsed)
 		return 0;
-	data = read_object_file(&item->object.oid, &type, &size);
+	data = repo_read_object_file(the_repository, &item->object.oid, &type,
+				     &size);
 	if (!data)
 		return error("Could not read %s",
 			     oid_to_hex(&item->object.oid));
diff --git a/tree.c b/tree.c
index e33f4009ac9..955b53f6a57 100644
--- a/tree.c
+++ b/tree.c
@@ -130,7 +130,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)
 
 	if (item->object.parsed)
 		return 0;
-	buffer = read_object_file(&item->object.oid, &type, &size);
+	buffer = repo_read_object_file(the_repository, &item->object.oid,
+				       &type, &size);
 	if (!buffer)
 		return quiet_on_missing ? -1 :
 			error("Could not read %s",
diff --git a/upload-pack.c b/upload-pack.c
index 41b9362cf1b..54be6a61910 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -500,8 +500,8 @@ static int got_oid(struct upload_pack_data *data,
 {
 	if (get_oid_hex(hex, oid))
 		die("git upload-pack: expected SHA1 object, got '%s'", hex);
-	if (!has_object_file_with_flags(oid,
-					OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
+	if (!repo_has_object_file_with_flags(the_repository, oid,
+					     OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
 		return -1;
 	return do_got_oid(data, oid);
 }
@@ -1601,8 +1601,8 @@ static int process_haves(struct upload_pack_data *data, struct oid_array *common
 	for (i = 0; i < data->haves.nr; i++) {
 		const struct object_id *oid = &data->haves.oid[i];
 
-		if (!has_object_file_with_flags(oid,
-						OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
+		if (!repo_has_object_file_with_flags(the_repository, oid,
+						     OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
 			continue;
 
 		oid_array_append(common, oid);
diff --git a/walker.c b/walker.c
index 5275070de76..e86f85e5283 100644
--- a/walker.c
+++ b/walker.c
@@ -146,7 +146,7 @@ static int process(struct walker *walker, struct object *obj)
 		return 0;
 	obj->flags |= SEEN;
 
-	if (has_object_file(&obj->oid)) {
+	if (repo_has_object_file(the_repository, &obj->oid)) {
 		/* We already have it, so we should scan it now. */
 		obj->flags |= TO_SCAN;
 	}
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 5baf6ceb947..0617fadbfbb 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -184,7 +184,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)
 		return;
 	}
 
-	ptr->ptr = read_object_file(oid, &type, &size);
+	ptr->ptr = repo_read_object_file(the_repository, oid, &type, &size);
 	if (!ptr->ptr || type != OBJ_BLOB)
 		die("unable to read blob object %s", oid_to_hex(oid));
 	ptr->size = size;
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 10/17] cocci: apply the "pretty.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (8 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 09/17] cocci: apply the "object-store.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 11/17] cocci: apply the "packfile.h" " Ævar Arnfjörð Bjarmason
                     ` (8 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"pretty.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 archive.c                                       |  3 ++-
 bisect.c                                        |  3 ++-
 builtin/bisect.c                                | 10 ++++++----
 builtin/commit.c                                | 13 ++++++++-----
 builtin/notes.c                                 |  3 ++-
 builtin/shortlog.c                              |  6 ++++--
 contrib/coccinelle/the_repository.cocci         |  4 ++++
 contrib/coccinelle/the_repository.pending.cocci |  4 ----
 fmt-merge-msg.c                                 |  3 ++-
 log-tree.c                                      |  9 ++++++---
 notes-cache.c                                   |  3 ++-
 object-name.c                                   |  6 ++++--
 pretty.c                                        |  3 ++-
 pretty.h                                        |  4 ----
 sequencer.c                                     | 12 ++++++++----
 t/helper/test-revision-walking.c                |  3 ++-
 16 files changed, 54 insertions(+), 35 deletions(-)

diff --git a/archive.c b/archive.c
index c6eaa6d6146..98de324362a 100644
--- a/archive.c
+++ b/archive.c
@@ -61,7 +61,8 @@ static void format_subst(const struct commit *commit,
 		strbuf_add(&fmt, b + 8, c - b - 8);
 
 		strbuf_add(buf, src, b - src);
-		format_commit_message(commit, fmt.buf, buf, ctx);
+		repo_format_commit_message(the_repository, commit, fmt.buf,
+					   buf, ctx);
 		len -= c + 1 - src;
 		src  = c + 1;
 	}
diff --git a/bisect.c b/bisect.c
index 5998e4b2e32..d55f2a4da5d 100644
--- a/bisect.c
+++ b/bisect.c
@@ -753,7 +753,8 @@ enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
 	}
 
 	commit = lookup_commit_reference(the_repository, bisect_rev);
-	format_commit_message(commit, "[%H] %s%n", &commit_msg, &pp);
+	repo_format_commit_message(the_repository, commit, "[%H] %s%n",
+				   &commit_msg, &pp);
 	fputs(commit_msg.buf, stdout);
 	strbuf_release(&commit_msg);
 
diff --git a/builtin/bisect.c b/builtin/bisect.c
index f925ceeb3c0..6b01e3c3e8e 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -267,7 +267,8 @@ static void log_commit(FILE *fp, char *fmt, const char *state,
 	struct strbuf commit_msg = STRBUF_INIT;
 	char *label = xstrfmt(fmt, state);
 
-	format_commit_message(commit, "%s", &commit_msg, &pp);
+	repo_format_commit_message(the_repository, commit, "%s", &commit_msg,
+				   &pp);
 
 	fprintf(fp, "# %s: [%s] %s\n", label, oid_to_hex(&commit->object.oid),
 		commit_msg.buf);
@@ -605,8 +606,8 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
 
 	while ((commit = get_revision(&revs)) != NULL) {
 		strbuf_reset(&commit_name);
-		format_commit_message(commit, "%s",
-				      &commit_name, &pp);
+		repo_format_commit_message(the_repository, commit, "%s",
+					   &commit_name, &pp);
 		fprintf(fp, "# possible first %s commit: [%s] %s\n",
 			terms->term_bad, oid_to_hex(&commit->object.oid),
 			commit_name.buf);
@@ -635,7 +636,8 @@ static int bisect_successful(struct bisect_terms *terms)
 
 	read_ref(bad_ref, &oid);
 	commit = lookup_commit_reference_by_name(bad_ref);
-	format_commit_message(commit, "%s", &commit_name, &pp);
+	repo_format_commit_message(the_repository, commit, "%s", &commit_name,
+				   &pp);
 
 	res = append_to_file(git_path_bisect_log(), "# first %s commit: [%s] %s\n",
 			    terms->term_bad, oid_to_hex(&commit->object.oid),
diff --git a/builtin/commit.c b/builtin/commit.c
index c64fc50e923..b8b4893ab20 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -719,7 +719,7 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
 	 * duplicate the subject line.
 	 */
 	fmt = starts_with(subject, "amend!") ? "%b" : "%B";
-	format_commit_message(commit, fmt, sb, ctx);
+	repo_format_commit_message(the_repository, commit, fmt, sb, ctx);
 	repo_unuse_commit_buffer(the_repository, commit, buffer);
 }
 
@@ -760,8 +760,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 			if (!c)
 				die(_("could not lookup commit %s"), squash_message);
 			ctx.output_encoding = get_commit_output_encoding();
-			format_commit_message(c, "squash! %s\n\n", &sb,
-					      &ctx);
+			repo_format_commit_message(the_repository, c,
+						   "squash! %s\n\n", &sb,
+						   &ctx);
 		}
 	}
 
@@ -795,7 +796,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 			die(_("could not lookup commit %s"), fixup_commit);
 		ctx.output_encoding = get_commit_output_encoding();
 		fmt = xstrfmt("%s! %%s\n\n", fixup_prefix);
-		format_commit_message(commit, fmt, &sb, &ctx);
+		repo_format_commit_message(the_repository, commit, fmt, &sb,
+					   &ctx);
 		free(fmt);
 		hook_arg1 = "message";
 
@@ -1135,7 +1137,8 @@ static const char *find_author_by_nickname(const char *name)
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode.type = DATE_NORMAL;
 		strbuf_release(&buf);
-		format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
+		repo_format_commit_message(the_repository, commit,
+					   "%aN <%aE>", &buf, &ctx);
 		release_revisions(&revs);
 		return strbuf_detach(&buf, NULL);
 	}
diff --git a/builtin/notes.c b/builtin/notes.c
index 4b13943be7f..859a56591aa 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -744,7 +744,8 @@ static int merge_commit(struct notes_merge_options *o)
 
 	/* Reuse existing commit message in reflog message */
 	memset(&pretty_ctx, 0, sizeof(pretty_ctx));
-	format_commit_message(partial, "%s", &msg, &pretty_ctx);
+	repo_format_commit_message(the_repository, partial, "%s", &msg,
+				   &pretty_ctx);
 	strbuf_trim(&msg);
 	strbuf_insertstr(&msg, 0, "notes: ");
 	update_ref(msg.buf, o->local_ref, &oid,
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 8afd1ad865e..62f91b8b932 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -223,7 +223,8 @@ static void insert_records_from_format(struct shortlog *log,
 	for_each_string_list_item(item, &log->format) {
 		strbuf_reset(&buf);
 
-		format_commit_message(commit, item->string, &buf, ctx);
+		repo_format_commit_message(the_repository, commit,
+					   item->string, &buf, ctx);
 
 		if (!shortlog_needs_dedup(log) || strset_add(dups, buf.buf))
 			insert_one_record(log, buf.buf, oneline);
@@ -249,7 +250,8 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 		if (log->user_format)
 			pretty_print_commit(&ctx, commit, &oneline);
 		else
-			format_commit_message(commit, "%s", &oneline, &ctx);
+			repo_format_commit_message(the_repository, commit,
+						   "%s", &oneline, &ctx);
 	}
 	oneline_str = oneline.len ? oneline.buf : "<none>";
 
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index fa159aba5b5..ff4c56114f1 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -87,6 +87,10 @@
 |
 - has_object_file_with_flags
 + repo_has_object_file_with_flags
+// pretty.h
+|
+- format_commit_message
++ repo_format_commit_message
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 69e9694111e..375850e773c 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// pretty.h
-- format_commit_message
-+ repo_format_commit_message
 // packfile.h
-|
 - approximate_object_count
 + repo_approximate_object_count
 // promisor-remote.h
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 5aab1d06619..5236b75fab2 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -383,7 +383,8 @@ static void shortlog(const char *name,
 		if (subjects.nr > limit)
 			continue;
 
-		format_commit_message(commit, "%s", &sb, &ctx);
+		repo_format_commit_message(the_repository, commit, "%s", &sb,
+					   &ctx);
 		strbuf_ltrim(&sb);
 
 		if (!sb.len)
diff --git a/log-tree.c b/log-tree.c
index 5c97bc403fb..f65c36e19dc 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -410,7 +410,8 @@ void fmt_output_commit(struct strbuf *filename,
 	struct pretty_print_context ctx = {0};
 	struct strbuf subject = STRBUF_INIT;
 
-	format_commit_message(commit, "%f", &subject, &ctx);
+	repo_format_commit_message(the_repository, commit, "%f", &subject,
+				   &ctx);
 	fmt_output_subject(filename, subject.buf, info);
 	strbuf_release(&subject);
 }
@@ -988,8 +989,10 @@ static int do_remerge_diff(struct rev_info *opt,
 	o.msg_header_prefix = "remerge";
 
 	ctx.abbrev = DEFAULT_ABBREV;
-	format_commit_message(parent1, "%h (%s)", &parent1_desc, &ctx);
-	format_commit_message(parent2, "%h (%s)", &parent2_desc, &ctx);
+	repo_format_commit_message(the_repository, parent1, "%h (%s)",
+				   &parent1_desc, &ctx);
+	repo_format_commit_message(the_repository, parent2, "%h (%s)",
+				   &parent2_desc, &ctx);
 	o.branch1 = parent1_desc.buf;
 	o.branch2 = parent2_desc.buf;
 
diff --git a/notes-cache.c b/notes-cache.c
index 38466091360..e5e9092d367 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -23,7 +23,8 @@ static int notes_cache_match_validity(struct repository *r,
 		return 0;
 
 	memset(&pretty_ctx, 0, sizeof(pretty_ctx));
-	format_commit_message(commit, "%s", &msg, &pretty_ctx);
+	repo_format_commit_message(the_repository, commit, "%s", &msg,
+				   &pretty_ctx);
 	strbuf_trim(&msg);
 
 	ret = !strcmp(msg.buf, validity);
diff --git a/object-name.c b/object-name.c
index b297cbd0a18..c7cef682f20 100644
--- a/object-name.c
+++ b/object-name.c
@@ -395,8 +395,10 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
 		if (commit) {
 			struct pretty_print_context pp = {0};
 			pp.date_mode.type = DATE_SHORT;
-			format_commit_message(commit, "%ad", &date, &pp);
-			format_commit_message(commit, "%s", &msg, &pp);
+			repo_format_commit_message(the_repository, commit,
+						   "%ad", &date, &pp);
+			repo_format_commit_message(the_repository, commit,
+						   "%s", &msg, &pp);
 		}
 
 		/*
diff --git a/pretty.c b/pretty.c
index 34e0a3bc786..0ce6ab7e196 100644
--- a/pretty.c
+++ b/pretty.c
@@ -2202,7 +2202,8 @@ void pretty_print_commit(struct pretty_print_context *pp,
 	int need_8bit_cte = pp->need_8bit_cte;
 
 	if (pp->fmt == CMIT_FMT_USERFORMAT) {
-		format_commit_message(commit, user_format, sb, pp);
+		repo_format_commit_message(the_repository, commit,
+					   user_format, sb, pp);
 		return;
 	}
 
diff --git a/pretty.h b/pretty.h
index 921dd6e0cae..421209e9ec2 100644
--- a/pretty.h
+++ b/pretty.h
@@ -120,10 +120,6 @@ void repo_format_commit_message(struct repository *r,
 			const struct commit *commit,
 			const char *format, struct strbuf *sb,
 			const struct pretty_print_context *context);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define format_commit_message(c, f, s, con) \
-	repo_format_commit_message(the_repository, c, f, s, con)
-#endif
 
 /*
  * Parse given arguments from "arg", check it for correctness and
diff --git a/sequencer.c b/sequencer.c
index 749455a2597..d0ad37700fd 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1341,8 +1341,10 @@ void print_commit_summary(struct repository *r,
 
 	strbuf_addstr(&format, "format:%h] %s");
 
-	format_commit_message(commit, "%an <%ae>", &author_ident, &pctx);
-	format_commit_message(commit, "%cn <%ce>", &committer_ident, &pctx);
+	repo_format_commit_message(the_repository, commit, "%an <%ae>",
+				   &author_ident, &pctx);
+	repo_format_commit_message(the_repository, commit, "%cn <%ce>",
+				   &committer_ident, &pctx);
 	if (strbuf_cmp(&author_ident, &committer_ident)) {
 		strbuf_addstr(&format, "\n Author: ");
 		strbuf_addbuf_percentquote(&format, &author_ident);
@@ -1350,7 +1352,8 @@ void print_commit_summary(struct repository *r,
 	if (flags & SUMMARY_SHOW_AUTHOR_DATE) {
 		struct strbuf date = STRBUF_INIT;
 
-		format_commit_message(commit, "%ad", &date, &pctx);
+		repo_format_commit_message(the_repository, commit, "%ad",
+					   &date, &pctx);
 		strbuf_addstr(&format, "\n Date: ");
 		strbuf_addbuf_percentquote(&format, &date);
 		strbuf_release(&date);
@@ -2123,7 +2126,8 @@ static void refer_to_commit(struct replay_opts *opts,
 			.abbrev = DEFAULT_ABBREV,
 			.date_mode.type = DATE_SHORT,
 		};
-		format_commit_message(commit, "%h (%s, %ad)", msgbuf, &ctx);
+		repo_format_commit_message(the_repository, commit,
+					   "%h (%s, %ad)", msgbuf, &ctx);
 	} else {
 		strbuf_addstr(msgbuf, oid_to_hex(&commit->object.oid));
 	}
diff --git a/t/helper/test-revision-walking.c b/t/helper/test-revision-walking.c
index 4a45d5bac2a..c7b22cb33d5 100644
--- a/t/helper/test-revision-walking.c
+++ b/t/helper/test-revision-walking.c
@@ -19,7 +19,8 @@ static void print_commit(struct commit *commit)
 	struct strbuf sb = STRBUF_INIT;
 	struct pretty_print_context ctx = {0};
 	ctx.date_mode.type = DATE_NORMAL;
-	format_commit_message(commit, " %m %s", &sb, &ctx);
+	repo_format_commit_message(the_repository, commit, " %m %s", &sb,
+				   &ctx);
 	printf("%s\n", sb.buf);
 	strbuf_release(&sb);
 }
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 11/17] cocci: apply the "packfile.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (9 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 10/17] cocci: apply the "pretty.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 12/17] cocci: apply the "promisor-remote.h" " Ævar Arnfjörð Bjarmason
                     ` (7 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"packfile.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/gc.c                                    | 2 +-
 commit-graph.c                                  | 2 +-
 contrib/coccinelle/the_repository.cocci         | 4 ++++
 contrib/coccinelle/the_repository.pending.cocci | 4 ----
 packfile.h                                      | 1 -
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/builtin/gc.c b/builtin/gc.c
index 9dc80344b64..a61d62bcf7b 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -285,7 +285,7 @@ static uint64_t total_ram(void)
 
 static uint64_t estimate_repack_memory(struct packed_git *pack)
 {
-	unsigned long nr_objects = approximate_object_count();
+	unsigned long nr_objects = repo_approximate_object_count(the_repository);
 	size_t os_cache, heap;
 
 	if (!pack || !nr_objects)
diff --git a/commit-graph.c b/commit-graph.c
index a30c4c96940..6403567dfee 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2361,7 +2361,7 @@ int write_commit_graph(struct object_directory *odb,
 			replace = ctx->opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;
 	}
 
-	ctx->approx_nr_objects = approximate_object_count();
+	ctx->approx_nr_objects = repo_approximate_object_count(the_repository);
 
 	if (ctx->append && ctx->r->objects->commit_graph) {
 		struct commit_graph *g = ctx->r->objects->commit_graph;
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index ff4c56114f1..a325361f961 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -91,6 +91,10 @@
 |
 - format_commit_message
 + repo_format_commit_message
+// packfile.h
+|
+- approximate_object_count
++ repo_approximate_object_count
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 375850e773c..9b426e49e66 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// packfile.h
-- approximate_object_count
-+ repo_approximate_object_count
 // promisor-remote.h
-|
 - promisor_remote_reinit
 + repo_promisor_remote_reinit
 |
diff --git a/packfile.h b/packfile.h
index a3f6723857b..6ec16567971 100644
--- a/packfile.h
+++ b/packfile.h
@@ -65,7 +65,6 @@ struct packed_git *get_all_packs(struct repository *r);
  * for speed.
  */
 unsigned long repo_approximate_object_count(struct repository *r);
-#define approximate_object_count() repo_approximate_object_count(the_repository)
 
 struct packed_git *find_sha1_pack(const unsigned char *sha1,
 				  struct packed_git *packs);
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 12/17] cocci: apply the "promisor-remote.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (10 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 11/17] cocci: apply the "packfile.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 13/17] cocci: apply the "refs.h" " Ævar Arnfjörð Bjarmason
                     ` (6 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"promisor-remote.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/cat-file.c                              |  2 +-
 builtin/fetch.c                                 |  4 ++--
 builtin/gc.c                                    |  2 +-
 builtin/index-pack.c                            |  2 +-
 builtin/pack-objects.c                          |  2 +-
 builtin/repack.c                                |  2 +-
 cache-tree.c                                    |  4 ++--
 connected.c                                     |  4 ++--
 contrib/coccinelle/the_repository.cocci         | 10 ++++++++++
 contrib/coccinelle/the_repository.pending.cocci | 10 ----------
 diff.c                                          |  2 +-
 diffcore-break.c                                |  2 +-
 diffcore-rename.c                               |  4 ++--
 list-objects-filter-options.c                   |  7 ++++---
 merge-ort.c                                     |  2 +-
 packfile.c                                      |  2 +-
 promisor-remote.h                               | 15 ---------------
 unpack-trees.c                                  |  2 +-
 18 files changed, 32 insertions(+), 46 deletions(-)

diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index a7bcb55b40d..44d202aa55b 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -796,7 +796,7 @@ static int batch_objects(struct batch_options *opt)
 		if (!memcmp(&data.info, &empty, sizeof(empty)))
 			data.skip_object_info = 1;
 
-		if (has_promisor_remote())
+		if (repo_has_promisor_remote(the_repository))
 			warning("This repository uses promisor remotes. Some objects may not be loaded.");
 
 		read_replace_refs = 0;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 0ee5d269768..4198e1c1a84 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2015,7 +2015,7 @@ static inline void fetch_one_setup_partial(struct remote *remote)
 	 * If no prior partial clone/fetch and the current fetch DID NOT
 	 * request a partial-fetch, do a normal fetch.
 	 */
-	if (!has_promisor_remote() && !filter_options.choice)
+	if (!repo_has_promisor_remote(the_repository) && !filter_options.choice)
 		return;
 
 	/*
@@ -2271,7 +2271,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 			printf("%s\n", oid_to_hex(oid));
 		oidset_clear(&acked_commits);
 	} else if (remote) {
-		if (filter_options.choice || has_promisor_remote())
+		if (filter_options.choice || repo_has_promisor_remote(the_repository))
 			fetch_one_setup_partial(remote);
 		result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs);
 	} else {
diff --git a/builtin/gc.c b/builtin/gc.c
index a61d62bcf7b..a204b301ac4 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -700,7 +700,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 			strvec_push(&prune, prune_expire);
 			if (quiet)
 				strvec_push(&prune, "--no-progress");
-			if (has_promisor_remote())
+			if (repo_has_promisor_remote(the_repository))
 				strvec_push(&prune,
 					    "--exclude-promisor-objects");
 			prune_cmd.git_cmd = 1;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index e823a73b357..6bd95f54d6e 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1393,7 +1393,7 @@ static void fix_unresolved_deltas(struct hashfile *f)
 		sorted_by_pos[i] = &ref_deltas[i];
 	QSORT(sorted_by_pos, nr_ref_deltas, delta_pos_compare);
 
-	if (has_promisor_remote()) {
+	if (repo_has_promisor_remote(the_repository)) {
 		/*
 		 * Prefetch the delta bases.
 		 */
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 068e6326c1d..bcf10d543f1 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2080,7 +2080,7 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
 
 	if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
 				     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
-		if (has_promisor_remote()) {
+		if (repo_has_promisor_remote(the_repository)) {
 			prefetch_to_pack(object_index);
 			if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
 						     OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
diff --git a/builtin/repack.c b/builtin/repack.c
index 87f73c8923a..ab4c55b50fc 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -903,7 +903,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		strvec_push(&cmd.args, "--reflog");
 		strvec_push(&cmd.args, "--indexed-objects");
 	}
-	if (has_promisor_remote())
+	if (repo_has_promisor_remote(the_repository))
 		strvec_push(&cmd.args, "--exclude-promisor-objects");
 	if (!write_midx) {
 		if (write_bitmaps > 0)
diff --git a/cache-tree.c b/cache-tree.c
index d71b9befd9a..12206eeaa3c 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -242,7 +242,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
 
 static int must_check_existence(const struct cache_entry *ce)
 {
-	return !(has_promisor_remote() && ce_skip_worktree(ce));
+	return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce));
 }
 
 static int update_one(struct cache_tree *it,
@@ -472,7 +472,7 @@ int cache_tree_update(struct index_state *istate, int flags)
 	if (!istate->cache_tree)
 		istate->cache_tree = cache_tree();
 
-	if (!(flags & WRITE_TREE_MISSING_OK) && has_promisor_remote())
+	if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(the_repository))
 		prefetch_cache_entries(istate, must_check_existence);
 
 	trace_performance_enter();
diff --git a/connected.c b/connected.c
index 39cb1e1074d..0b7be81237d 100644
--- a/connected.c
+++ b/connected.c
@@ -55,7 +55,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
 		strbuf_release(&idx_file);
 	}
 
-	if (has_promisor_remote()) {
+	if (repo_has_promisor_remote(the_repository)) {
 		/*
 		 * For partial clones, we don't want to have to do a regular
 		 * connectivity check because we have to enumerate and exclude
@@ -98,7 +98,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
 	strvec_push(&rev_list.args,"rev-list");
 	strvec_push(&rev_list.args, "--objects");
 	strvec_push(&rev_list.args, "--stdin");
-	if (has_promisor_remote())
+	if (repo_has_promisor_remote(the_repository))
 		strvec_push(&rev_list.args, "--exclude-promisor-objects");
 	if (!opt->is_deepening_fetch) {
 		strvec_push(&rev_list.args, "--not");
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index a325361f961..d5b644a8687 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -95,6 +95,16 @@
 |
 - approximate_object_count
 + repo_approximate_object_count
+// promisor-remote.h
+|
+- promisor_remote_reinit
++ repo_promisor_remote_reinit
+|
+- promisor_remote_find
++ repo_promisor_remote_find
+|
+- has_promisor_remote
++ repo_has_promisor_remote
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 9b426e49e66..e17a60198c5 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,17 +5,7 @@
 @@
 @@
 (
-// promisor-remote.h
-- promisor_remote_reinit
-+ repo_promisor_remote_reinit
-|
-- promisor_remote_find
-+ repo_promisor_remote_find
-|
-- has_promisor_remote
-+ repo_has_promisor_remote
 // refs.h
-|
 - dwim_ref
 + repo_dwim_ref
 // rerere.h
diff --git a/diff.c b/diff.c
index 81f115d32c9..b0a810fbee3 100644
--- a/diff.c
+++ b/diff.c
@@ -6885,7 +6885,7 @@ void diffcore_std(struct diff_options *options)
 	 * If no prefetching occurs, diffcore_rename() will prefetch if it
 	 * decides that it needs inexact rename detection.
 	 */
-	if (options->repo == the_repository && has_promisor_remote() &&
+	if (options->repo == the_repository && repo_has_promisor_remote(the_repository) &&
 	    (options->output_format & output_formats_to_prefetch ||
 	     options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
 		diff_queued_diff_prefetch(options->repo);
diff --git a/diffcore-break.c b/diffcore-break.c
index 0d4a14964d0..5462420bbbe 100644
--- a/diffcore-break.c
+++ b/diffcore-break.c
@@ -65,7 +65,7 @@ static int should_break(struct repository *r,
 	    oideq(&src->oid, &dst->oid))
 		return 0; /* they are the same */
 
-	if (r == the_repository && has_promisor_remote()) {
+	if (r == the_repository && repo_has_promisor_remote(the_repository)) {
 		options.missing_object_cb = diff_queued_diff_prefetch;
 		options.missing_object_data = r;
 	}
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 7e9ff96d435..8e2e7a3ad73 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -986,7 +986,7 @@ static int find_basename_matches(struct diff_options *options,
 			strintmap_set(&dests, base, i);
 	}
 
-	if (options->repo == the_repository && has_promisor_remote()) {
+	if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {
 		dpf_options.missing_object_cb = basename_prefetch;
 		dpf_options.missing_object_data = &prefetch_options;
 	}
@@ -1572,7 +1572,7 @@ void diffcore_rename_extended(struct diff_options *options,
 
 	/* Finish setting up dpf_options */
 	prefetch_options.skip_unmodified = skip_unmodified;
-	if (options->repo == the_repository && has_promisor_remote()) {
+	if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {
 		dpf_options.missing_object_cb = inexact_prefetch;
 		dpf_options.missing_object_data = &prefetch_options;
 	}
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index 1d25a5737db..b82ba0a2e5b 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -343,7 +343,7 @@ void partial_clone_register(
 	char *filter_name;
 
 	/* Check if it is already registered */
-	if ((promisor_remote = promisor_remote_find(remote))) {
+	if ((promisor_remote = repo_promisor_remote_find(the_repository, remote))) {
 		if (promisor_remote->partial_clone_filter)
 			/*
 			 * Remote is already registered and a filter is already
@@ -371,14 +371,15 @@ void partial_clone_register(
 	free(filter_name);
 
 	/* Make sure the config info are reset */
-	promisor_remote_reinit();
+	repo_promisor_remote_reinit(the_repository);
 }
 
 void partial_clone_get_default_filter_spec(
 	struct list_objects_filter_options *filter_options,
 	const char *remote)
 {
-	struct promisor_remote *promisor = promisor_remote_find(remote);
+	struct promisor_remote *promisor = repo_promisor_remote_find(the_repository,
+								     remote);
 	struct strbuf errbuf = STRBUF_INIT;
 
 	/*
diff --git a/merge-ort.c b/merge-ort.c
index 607e2c263f1..dace4073a06 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4217,7 +4217,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,
 	struct string_list_item *e;
 	struct oid_array to_fetch = OID_ARRAY_INIT;
 
-	if (opt->repo != the_repository || !has_promisor_remote())
+	if (opt->repo != the_repository || !repo_has_promisor_remote(the_repository))
 		return;
 
 	for (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {
diff --git a/packfile.c b/packfile.c
index 2023df1b75b..53fcc0f44c9 100644
--- a/packfile.c
+++ b/packfile.c
@@ -2275,7 +2275,7 @@ int is_promisor_object(const struct object_id *oid)
 	static int promisor_objects_prepared;
 
 	if (!promisor_objects_prepared) {
-		if (has_promisor_remote()) {
+		if (repo_has_promisor_remote(the_repository)) {
 			for_each_packed_object(add_promisor_object,
 					       &promisor_objects,
 					       FOR_EACH_OBJECT_PROMISOR_ONLY |
diff --git a/promisor-remote.h b/promisor-remote.h
index df36eb08efc..2cb9eda9ea4 100644
--- a/promisor-remote.h
+++ b/promisor-remote.h
@@ -18,24 +18,9 @@ struct promisor_remote {
 };
 
 void repo_promisor_remote_reinit(struct repository *r);
-static inline void promisor_remote_reinit(void)
-{
-	repo_promisor_remote_reinit(the_repository);
-}
-
 void promisor_remote_clear(struct promisor_remote_config *config);
-
 struct promisor_remote *repo_promisor_remote_find(struct repository *r, const char *remote_name);
-static inline struct promisor_remote *promisor_remote_find(const char *remote_name)
-{
-	return repo_promisor_remote_find(the_repository, remote_name);
-}
-
 int repo_has_promisor_remote(struct repository *r);
-static inline int has_promisor_remote(void)
-{
-	return repo_has_promisor_remote(the_repository);
-}
 
 /*
  * Fetches all requested objects from all promisor remotes, trying them one at
diff --git a/unpack-trees.c b/unpack-trees.c
index a75fb9f05b4..8a284d8a4da 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -459,7 +459,7 @@ static int check_updates(struct unpack_trees_options *o,
 	if (should_update_submodules())
 		load_gitmodules_file(index, &state);
 
-	if (has_promisor_remote())
+	if (repo_has_promisor_remote(the_repository))
 		/*
 		 * Prefetch the objects that are to be checked out in the loop
 		 * below.
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 13/17] cocci: apply the "refs.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (11 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 12/17] cocci: apply the "promisor-remote.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 14/17] cocci: apply the "rerere.h" " Ævar Arnfjörð Bjarmason
                     ` (5 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"refs.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 archive.c                                       | 5 +++--
 branch.c                                        | 3 ++-
 builtin/checkout.c                              | 6 ++++--
 builtin/fast-export.c                           | 3 ++-
 builtin/log.c                                   | 3 ++-
 builtin/merge.c                                 | 3 ++-
 builtin/reset.c                                 | 3 ++-
 builtin/rev-parse.c                             | 4 +++-
 builtin/show-branch.c                           | 3 ++-
 builtin/stash.c                                 | 3 ++-
 bundle.c                                        | 3 ++-
 commit.c                                        | 3 ++-
 contrib/coccinelle/the_repository.cocci         | 4 ++++
 contrib/coccinelle/the_repository.pending.cocci | 4 ----
 refs.h                                          | 6 ------
 remote.c                                        | 5 +++--
 wt-status.c                                     | 3 ++-
 17 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/archive.c b/archive.c
index 98de324362a..933e5b39b92 100644
--- a/archive.c
+++ b/archive.c
@@ -458,10 +458,11 @@ static void parse_treeish_arg(const char **argv,
 		const char *colon = strchrnul(name, ':');
 		int refnamelen = colon - name;
 
-		if (!dwim_ref(name, refnamelen, &oid, &ref, 0))
+		if (!repo_dwim_ref(the_repository, name, refnamelen, &oid, &ref, 0))
 			die(_("no such ref: %.*s"), refnamelen, name);
 	} else {
-		dwim_ref(name, strlen(name), &oid, &ref, 0);
+		repo_dwim_ref(the_repository, name, strlen(name), &oid, &ref,
+			      0);
 	}
 
 	if (repo_get_oid(the_repository, name, &oid))
diff --git a/branch.c b/branch.c
index efea29af1ac..179353e7653 100644
--- a/branch.c
+++ b/branch.c
@@ -542,7 +542,8 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
 		die(_("not a valid object name: '%s'"), start_name);
 	}
 
-	switch (dwim_ref(start_name, strlen(start_name), &oid, &real_ref, 0)) {
+	switch (repo_dwim_ref(the_repository, start_name, strlen(start_name),
+			      &oid, &real_ref, 0)) {
 	case 0:
 		/* Not branching from any existing branch */
 		if (explicit_tracking)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index ad6d5304b64..fcede4600a5 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -717,7 +717,8 @@ static void setup_branch_path(struct branch_info *branch)
 	 * If this is a ref, resolve it; otherwise, look up the OID for our
 	 * expression.  Failure here is okay.
 	 */
-	if (!dwim_ref(branch->name, strlen(branch->name), &branch->oid, &branch->refname, 0))
+	if (!repo_dwim_ref(the_repository, branch->name, strlen(branch->name),
+			   &branch->oid, &branch->refname, 0))
 		repo_get_oid_committish(the_repository, branch->name, &branch->oid);
 
 	strbuf_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL);
@@ -1438,7 +1439,8 @@ static void die_expecting_a_branch(const struct branch_info *branch_info)
 	char *to_free;
 	int code;
 
-	if (dwim_ref(branch_info->name, strlen(branch_info->name), &oid, &to_free, 0) == 1) {
+	if (repo_dwim_ref(the_repository, branch_info->name,
+			  strlen(branch_info->name), &oid, &to_free, 0) == 1) {
 		const char *ref = to_free;
 
 		if (skip_prefix(ref, "refs/tags/", &ref))
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 166f51b100a..2f728a44115 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -919,7 +919,8 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
 		if (e->flags & UNINTERESTING)
 			continue;
 
-		if (dwim_ref(e->name, strlen(e->name), &oid, &full_name, 0) != 1)
+		if (repo_dwim_ref(the_repository, e->name, strlen(e->name),
+				  &oid, &full_name, 0) != 1)
 			continue;
 
 		if (refspecs.nr) {
diff --git a/builtin/log.c b/builtin/log.c
index 28085547aa8..ba24fa4bfdb 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1218,7 +1218,8 @@ static char *find_branch_name(struct rev_info *rev)
 		return NULL;
 	ref = rev->cmdline.rev[positive].name;
 	tip_oid = &rev->cmdline.rev[positive].item->oid;
-	if (dwim_ref(ref, strlen(ref), &branch_oid, &full_ref, 0) &&
+	if (repo_dwim_ref(the_repository, ref, strlen(ref), &branch_oid,
+			  &full_ref, 0) &&
 	    skip_prefix(full_ref, "refs/heads/", &v) &&
 	    oideq(tip_oid, &branch_oid))
 		branch = xstrdup(v);
diff --git a/builtin/merge.c b/builtin/merge.c
index 559aab1c380..6538a4bae95 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -519,7 +519,8 @@ static void merge_name(const char *remote, struct strbuf *msg)
 	if (!remote_head)
 		die(_("'%s' does not point to a commit"), remote);
 
-	if (dwim_ref(remote, strlen(remote), &branch_head, &found_ref, 0) > 0) {
+	if (repo_dwim_ref(the_repository, remote, strlen(remote), &branch_head,
+			  &found_ref, 0) > 0) {
 		if (starts_with(found_ref, "refs/heads/")) {
 			strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
 				    oid_to_hex(&branch_head), remote);
diff --git a/builtin/reset.c b/builtin/reset.c
index cd4165537c5..c2a390b3a01 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -467,7 +467,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 			char *ref = NULL;
 			int err;
 
-			dwim_ref(rev, strlen(rev), &dummy, &ref, 0);
+			repo_dwim_ref(the_repository, rev, strlen(rev),
+				      &dummy, &ref, 0);
 			if (ref && !starts_with(ref, "refs/"))
 				FREE_AND_NULL(ref);
 
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 4969815ca79..5662101a102 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -138,7 +138,9 @@ static void show_rev(int type, const struct object_id *oid, const char *name)
 			struct object_id discard;
 			char *full;
 
-			switch (dwim_ref(name, strlen(name), &discard, &full, 0)) {
+			switch (repo_dwim_ref(the_repository, name,
+					      strlen(name), &discard, &full,
+					      0)) {
 			case 0:
 				/*
 				 * Not found -- not a ref.  We could
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 7aea28f5b06..70bc461638c 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -747,7 +747,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 			die(Q_("only %d entry can be shown at one time.",
 			       "only %d entries can be shown at one time.",
 			       MAX_REVS), MAX_REVS);
-		if (!dwim_ref(*av, strlen(*av), &oid, &ref, 0))
+		if (!repo_dwim_ref(the_repository, *av, strlen(*av), &oid,
+				   &ref, 0))
 			die(_("no such ref %s"), *av);
 
 		/* Has the base been specified? */
diff --git a/builtin/stash.c b/builtin/stash.c
index 447c3b678f3..60052ec9d7b 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -212,7 +212,8 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
 	end_of_rev = strchrnul(revision, '@');
 	strbuf_add(&symbolic, revision, end_of_rev - revision);
 
-	ret = dwim_ref(symbolic.buf, symbolic.len, &dummy, &expanded_ref, 0);
+	ret = repo_dwim_ref(the_repository, symbolic.buf, symbolic.len,
+			    &dummy, &expanded_ref, 0);
 	strbuf_release(&symbolic);
 	switch (ret) {
 	case 0: /* Not found, but valid ref */
diff --git a/bundle.c b/bundle.c
index bce0c7f99e8..73f0b1b89d6 100644
--- a/bundle.c
+++ b/bundle.c
@@ -383,7 +383,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 
 		if (e->item->flags & UNINTERESTING)
 			continue;
-		if (dwim_ref(e->name, strlen(e->name), &oid, &ref, 0) != 1)
+		if (repo_dwim_ref(the_repository, e->name, strlen(e->name),
+				  &oid, &ref, 0) != 1)
 			goto skip_write_ref;
 		if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flag))
 			flag = 0;
diff --git a/commit.c b/commit.c
index cfd14f7d975..8e22bebd0e1 100644
--- a/commit.c
+++ b/commit.c
@@ -999,7 +999,8 @@ struct commit *get_fork_point(const char *refname, struct commit *commit)
 	struct commit *ret = NULL;
 	char *full_refname;
 
-	switch (dwim_ref(refname, strlen(refname), &oid, &full_refname, 0)) {
+	switch (repo_dwim_ref(the_repository, refname, strlen(refname), &oid,
+			      &full_refname, 0)) {
 	case 0:
 		die("No such ref: '%s'", refname);
 	case 1:
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index d5b644a8687..b20a3e70845 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -105,6 +105,10 @@
 |
 - has_promisor_remote
 + repo_has_promisor_remote
+// refs.h
+|
+- dwim_ref
++ repo_dwim_ref
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index e17a60198c5..8bf30798a04 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// refs.h
-- dwim_ref
-+ repo_dwim_ref
 // rerere.h
-|
 - rerere
 + repo_rerere
 // revision.h
diff --git a/refs.h b/refs.h
index 935cdd1ece3..2998244b615 100644
--- a/refs.h
+++ b/refs.h
@@ -159,12 +159,6 @@ int expand_ref(struct repository *r, const char *str, int len, struct object_id
 int repo_dwim_ref(struct repository *r, const char *str, int len,
 		  struct object_id *oid, char **ref, int nonfatal_dangling_mark);
 int repo_dwim_log(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
-static inline int dwim_ref(const char *str, int len, struct object_id *oid,
-			   char **ref, int nonfatal_dangling_mark)
-{
-	return repo_dwim_ref(the_repository, str, len, oid, ref,
-			     nonfatal_dangling_mark);
-}
 int dwim_log(const char *str, int len, struct object_id *oid, char **ref);
 
 /*
diff --git a/remote.c b/remote.c
index 9219ebb8962..c51180bebb4 100644
--- a/remote.c
+++ b/remote.c
@@ -1810,8 +1810,9 @@ static void set_merge(struct remote_state *remote_state, struct branch *ret)
 		if (!remote_find_tracking(remote, ret->merge[i]) ||
 		    strcmp(ret->remote_name, "."))
 			continue;
-		if (dwim_ref(ret->merge_name[i], strlen(ret->merge_name[i]),
-			     &oid, &ref, 0) == 1)
+		if (repo_dwim_ref(the_repository, ret->merge_name[i],
+				  strlen(ret->merge_name[i]), &oid, &ref,
+				  0) == 1)
 			ret->merge[i]->dst = ref;
 		else
 			ret->merge[i]->dst = xstrdup(ret->merge_name[i]);
diff --git a/wt-status.c b/wt-status.c
index 0f0b92eece4..84726d26dc9 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1665,7 +1665,8 @@ static void wt_status_get_detached_from(struct repository *r,
 		return;
 	}
 
-	if (dwim_ref(cb.buf.buf, cb.buf.len, &oid, &ref, 1) == 1 &&
+	if (repo_dwim_ref(the_repository, cb.buf.buf, cb.buf.len, &oid, &ref,
+			  1) == 1 &&
 	    /* oid is a commit? match without further lookup */
 	    (oideq(&cb.noid, &oid) ||
 	     /* perhaps oid is a tag, try to dereference to a commit */
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 14/17] cocci: apply the "rerere.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (12 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 13/17] cocci: apply the "refs.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 15/17] cocci: apply the "revision.h" " Ævar Arnfjörð Bjarmason
                     ` (4 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"rerere.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/stash.c                                 | 2 +-
 contrib/coccinelle/the_repository.cocci         | 4 ++++
 contrib/coccinelle/the_repository.pending.cocci | 4 ----
 rerere.h                                        | 3 ---
 4 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/builtin/stash.c b/builtin/stash.c
index 60052ec9d7b..b60c82f7af2 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -602,7 +602,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
 		ret = error(_("could not write index"));
 
 	if (ret) {
-		rerere(0);
+		repo_rerere(the_repository, 0);
 
 		if (index)
 			fprintf_ln(stderr, _("Index was not unstashed."));
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index b20a3e70845..1d1ac7d4fc5 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -109,6 +109,10 @@
 |
 - dwim_ref
 + repo_dwim_ref
+// rerere.h
+|
+- rerere
++ repo_rerere
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index 8bf30798a04..1190a3312bd 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -5,11 +5,7 @@
 @@
 @@
 (
-// rerere.h
-- rerere
-+ repo_rerere
 // revision.h
-|
 - init_revisions
 + repo_init_revisions
 )
diff --git a/rerere.h b/rerere.h
index c32d79c3bd8..876c316321e 100644
--- a/rerere.h
+++ b/rerere.h
@@ -24,9 +24,6 @@ struct rerere_id {
 };
 
 int setup_rerere(struct repository *,struct string_list *, int);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define rerere(flags) repo_rerere(the_repository, flags)
-#endif
 int repo_rerere(struct repository *, int);
 /*
  * Given the conflict ID and the name of a "file" used for replaying
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 15/17] cocci: apply the "revision.h" part of "the_repository.pending"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (13 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 14/17] cocci: apply the "rerere.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 13:58   ` [PATCH v2 16/17] post-cocci: adjust comments for recent repo_* migration Ævar Arnfjörð Bjarmason
                     ` (3 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

Apply the part of "the_repository.pending.cocci" pertaining to
"revision.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 add-interactive.c                               |  2 +-
 builtin/bisect.c                                |  4 ++--
 builtin/stash.c                                 |  6 +++---
 builtin/submodule--helper.c                     |  2 +-
 contrib/coccinelle/the_repository.cocci         |  4 ++++
 contrib/coccinelle/the_repository.pending.cocci | 14 --------------
 range-diff.c                                    |  2 +-
 revision.h                                      |  3 ---
 8 files changed, 12 insertions(+), 25 deletions(-)
 delete mode 100644 contrib/coccinelle/the_repository.pending.cocci

diff --git a/add-interactive.c b/add-interactive.c
index ae25ec50bce..313cfd39d8e 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -552,7 +552,7 @@ static int get_modified_files(struct repository *r,
 		opt.def = is_initial ?
 			empty_tree_oid_hex() : oid_to_hex(&head_oid);
 
-		init_revisions(&rev, NULL);
+		repo_init_revisions(the_repository, &rev, NULL);
 		setup_revisions(0, NULL, &rev, &opt);
 
 		rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 6b01e3c3e8e..c77564053a1 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -570,7 +570,7 @@ static int prepare_revs(struct bisect_terms *terms, struct rev_info *revs)
 	 * sets up a revision walk.
 	 */
 	reset_revision_walk();
-	init_revisions(revs, NULL);
+	repo_init_revisions(the_repository, revs, NULL);
 	setup_revisions(0, NULL, revs, NULL);
 	for_each_glob_ref_in(add_bisect_ref, bad, "refs/bisect/", &cb);
 	cb.object_flags = UNINTERESTING;
@@ -1097,7 +1097,7 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, int argc,
 			struct rev_info revs;
 			struct commit *commit;
 
-			init_revisions(&revs, NULL);
+			repo_init_revisions(the_repository, &revs, NULL);
 			setup_revisions(2, argv + i - 1, &revs, NULL);
 
 			if (prepare_revision_walk(&revs))
diff --git a/builtin/stash.c b/builtin/stash.c
index b60c82f7af2..5e9fe6b4623 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -902,7 +902,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
 
 	init_diff_ui_defaults();
 	git_config(git_diff_ui_config, NULL);
-	init_revisions(&rev, prefix);
+	repo_init_revisions(the_repository, &rev, prefix);
 
 	argc = parse_options(argc, argv, prefix, options, git_stash_show_usage,
 			     PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT |
@@ -1091,7 +1091,7 @@ static int check_changes_tracked_files(const struct pathspec *ps)
 	if (repo_read_index(the_repository) < 0)
 		return -1;
 
-	init_revisions(&rev, NULL);
+	repo_init_revisions(the_repository, &rev, NULL);
 	copy_pathspec(&rev.prune_data, ps);
 
 	rev.diffopt.flags.quick = 1;
@@ -1278,7 +1278,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
 	struct strbuf diff_output = STRBUF_INIT;
 	struct index_state istate = INDEX_STATE_INIT(the_repository);
 
-	init_revisions(&rev, NULL);
+	repo_init_revisions(the_repository, &rev, NULL);
 	copy_pathspec(&rev.prune_data, ps);
 
 	set_alternate_index_output(stash_index_path.buf);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index b21857479de..3833c47aa1f 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1110,7 +1110,7 @@ static int compute_summary_module_list(struct object_id *head_oid,
 		strvec_pushv(&diff_args, info->argv);
 
 	git_config(git_diff_basic_config, NULL);
-	init_revisions(&rev, info->prefix);
+	repo_init_revisions(the_repository, &rev, info->prefix);
 	rev.abbrev = 0;
 	precompose_argv_prefix(diff_args.nr, diff_args.v, NULL);
 	setup_revisions(diff_args.nr, diff_args.v, &rev, &opt);
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index 1d1ac7d4fc5..765ad689678 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -113,6 +113,10 @@
 |
 - rerere
 + repo_rerere
+// revision.h
+|
+- init_revisions
++ repo_init_revisions
 )
   (
 + the_repository,
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
deleted file mode 100644
index 1190a3312bd..00000000000
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ /dev/null
@@ -1,14 +0,0 @@
-// This file is used for the ongoing refactoring of
-// bringing the index or repository struct in all of
-// our code base.
-
-@@
-@@
-(
-// revision.h
-- init_revisions
-+ repo_init_revisions
-)
-  (
-+ the_repository,
-  ...)
diff --git a/range-diff.c b/range-diff.c
index 15d0bc35a87..ff5d19f8add 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -588,7 +588,7 @@ int is_range_diff_range(const char *arg)
 	int i, positive = 0, negative = 0;
 	struct rev_info revs;
 
-	init_revisions(&revs, NULL);
+	repo_init_revisions(the_repository, &revs, NULL);
 	if (setup_revisions(3, argv, &revs, NULL) == 1) {
 		for (i = 0; i < revs.pending.nr; i++)
 			if (revs.pending.objects[i].item->flags & UNINTERESTING)
diff --git a/revision.h b/revision.h
index ab71443696d..742700504a7 100644
--- a/revision.h
+++ b/revision.h
@@ -416,9 +416,6 @@ struct rev_info {
 void repo_init_revisions(struct repository *r,
 			 struct rev_info *revs,
 			 const char *prefix);
-#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
-#define init_revisions(revs, prefix) repo_init_revisions(the_repository, revs, prefix)
-#endif
 
 /**
  * Parse revision information, filling in the `rev_info` structure, and
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 16/17] post-cocci: adjust comments for recent repo_* migration
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (14 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 15/17] cocci: apply the "revision.h" " Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-29 20:50     ` Taylor Blau
  2023-03-28 13:58   ` [PATCH v2 17/17] libs: use "struct repository *" argument, not "the_repository" Ævar Arnfjörð Bjarmason
                     ` (2 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

In preceding commits we changed many calls to macros that were
providing a "the_repository" argument to invoke corresponding repo_*()
function instead. Let's follow-up and adjust references to those in
comments, which coccinelle didn't (and inherently can't) catch.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/branch.c   | 2 +-
 builtin/shortlog.c | 2 +-
 cache.h            | 4 ++--
 commit.h           | 4 ++--
 diff.h             | 2 +-
 object-file.c      | 2 +-
 object-store.h     | 4 ++--
 pretty.c           | 2 +-
 refs.c             | 2 +-
 sequencer.c        | 6 +++---
 strbuf.h           | 6 +++---
 11 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index bbcfb34b3c6..45910039e6b 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -156,7 +156,7 @@ static int branch_merged(int kind, const char *name,
 	/*
 	 * After the safety valve is fully redefined to "check with
 	 * upstream, if any, otherwise with HEAD", we should just
-	 * return the result of the in_merge_bases() above without
+	 * return the result of the repo_in_merge_bases() above without
 	 * any of the following code, but during the transition period,
 	 * a gentle reminder is in order.
 	 */
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 62f91b8b932..f287a6acd03 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -176,7 +176,7 @@ static void insert_records_from_trailers(struct shortlog *log,
 		return;
 
 	/*
-	 * Using format_commit_message("%B") would be simpler here, but
+	 * Using repo_format_commit_message("%B") would be simpler here, but
 	 * this saves us copying the message.
 	 */
 	commit_buffer = repo_logmsg_reencode(the_repository, commit, NULL,
diff --git a/cache.h b/cache.h
index 1d05a8e945f..0ede8856562 100644
--- a/cache.h
+++ b/cache.h
@@ -435,7 +435,7 @@ void validate_cache_entries(const struct index_state *istate);
 /*
  * Bulk prefetch all missing cache entries that are not GITLINKs and that match
  * the given predicate. This function should only be called if
- * has_promisor_remote() returns true.
+ * repo_has_promisor_remote() returns true.
  */
 typedef int (*must_prefetch_predicate)(const struct cache_entry *);
 void prefetch_cache_entries(const struct index_state *istate,
@@ -1093,7 +1093,7 @@ void check_repository_format(struct repository_format *fmt);
  * terminated.
  *
  * The non-`_r` version returns a static buffer which remains valid until 4
- * more calls to find_unique_abbrev are made.
+ * more calls to repo_find_unique_abbrev are made.
  *
  * The `_r` variant writes to a buffer supplied by the caller, which must be at
  * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
diff --git a/commit.h b/commit.h
index d87d5cd2a09..69b2f376e9d 100644
--- a/commit.h
+++ b/commit.h
@@ -130,7 +130,7 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,
 /*
  * Get the commit's object contents, either from cache or by reading the object
  * from disk. The resulting memory should not be modified, and must be given
- * to unuse_commit_buffer when the caller is done.
+ * to repo_unuse_commit_buffer when the caller is done.
  */
 const void *repo_get_commit_buffer(struct repository *r,
 				   const struct commit *,
@@ -139,7 +139,7 @@ const void *repo_get_commit_buffer(struct repository *r,
 /*
  * Tell the commit subsystem that we are done with a particular commit buffer.
  * The commit and buffer should be the input and return value, respectively,
- * from an earlier call to get_commit_buffer.  The buffer may or may not be
+ * from an earlier call to repo_get_commit_buffer.  The buffer may or may not be
  * freed by this call; callers should not access the memory afterwards.
  */
 void repo_unuse_commit_buffer(struct repository *r,
diff --git a/diff.h b/diff.h
index c759bedc269..6a0737b9c34 100644
--- a/diff.h
+++ b/diff.h
@@ -615,7 +615,7 @@ void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc);
 #define DIFF_STATUS_FILTER_BROKEN	'B'
 
 /*
- * This is different from find_unique_abbrev() in that
+ * This is different from repo_find_unique_abbrev() in that
  * it stuffs the result with dots for alignment.
  */
 const char *diff_aligned_abbrev(const struct object_id *sha1, int);
diff --git a/object-file.c b/object-file.c
index 5944f51a3e0..bd9741c7f36 100644
--- a/object-file.c
+++ b/object-file.c
@@ -269,7 +269,7 @@ int hash_algo_by_length(int len)
 
 /*
  * This is meant to hold a *small* number of objects that you would
- * want read_object_file() to be able to return, but yet you do not want
+ * want repo_read_object_file() to be able to return, but yet you do not want
  * to write them into the object store (e.g. a browse-only
  * application).
  */
diff --git a/object-store.h b/object-store.h
index 62a683af4d6..f9d225783ae 100644
--- a/object-store.h
+++ b/object-store.h
@@ -216,7 +216,7 @@ struct raw_object_store {
 	/*
 	 * A fast, rough count of the number of objects in the repository.
 	 * These two fields are not meant for direct access. Use
-	 * approximate_object_count() instead.
+	 * repo_approximate_object_count() instead.
 	 */
 	unsigned long approximate_object_count;
 	unsigned approximate_object_count_valid : 1;
@@ -406,7 +406,7 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect);
 
 /*
  * Enabling the object read lock allows multiple threads to safely call the
- * following functions in parallel: repo_read_object_file(), read_object_file(),
+ * following functions in parallel: repo_read_object_file(),
  * read_object_with_reference(), oid_object_info() and oid_object_info_extended().
  *
  * obj_read_lock() and obj_read_unlock() may also be used to protect other
diff --git a/pretty.c b/pretty.c
index 0ce6ab7e196..494932da20d 100644
--- a/pretty.c
+++ b/pretty.c
@@ -721,7 +721,7 @@ const char *repo_logmsg_reencode(struct repository *r,
 		 * Otherwise, we still want to munge the encoding header in the
 		 * result, which will be done by modifying the buffer. If we
 		 * are using a fresh copy, we can reuse it. But if we are using
-		 * the cached copy from get_commit_buffer, we need to duplicate it
+		 * the cached copy from repo_get_commit_buffer, we need to duplicate it
 		 * to avoid munging the cached copy.
 		 */
 		if (msg == get_cached_commit_buffer(r, commit, NULL))
diff --git a/refs.c b/refs.c
index 53240bcc07b..1e1c76d1eca 100644
--- a/refs.c
+++ b/refs.c
@@ -1823,7 +1823,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
 			return NULL;
 
 		/*
-		 * dwim_ref() uses REF_ISBROKEN to distinguish between
+		 * repo_dwim_ref() uses REF_ISBROKEN to distinguish between
 		 * missing refs and refs that were present but invalid,
 		 * to complain about the latter to stderr.
 		 *
diff --git a/sequencer.c b/sequencer.c
index d0ad37700fd..84b07b818f0 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -766,9 +766,9 @@ static int is_index_unchanged(struct repository *r)
 	/*
 	 * If head_commit is NULL, check_commit, called from
 	 * lookup_commit, would have indicated that head_commit is not
-	 * a commit object already.  parse_commit() will return failure
+	 * a commit object already.  repo_parse_commit() will return failure
 	 * without further complaints in such a case.  Otherwise, if
-	 * the commit is invalid, parse_commit() will complain.  So
+	 * the commit is invalid, repo_parse_commit() will complain.  So
 	 * there is nothing for us to say here.  Just return failure.
 	 */
 	if (repo_parse_commit(the_repository, head_commit))
@@ -5368,7 +5368,7 @@ static const char *label_oid(struct object_id *oid, const char *label,
 	 * For "uninteresting" commits, i.e. commits that are not to be
 	 * rebased, and which can therefore not be labeled, we use a unique
 	 * abbreviation of the commit name. This is slightly more complicated
-	 * than calling find_unique_abbrev() because we also need to make
+	 * than calling repo_find_unique_abbrev() because we also need to make
 	 * sure that the abbreviation does not conflict with any other
 	 * label.
 	 *
diff --git a/strbuf.h b/strbuf.h
index f6dbb9681ee..b980f9edc6d 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -631,7 +631,7 @@ void strbuf_add_separated_string_list(struct strbuf *str,
 void strbuf_list_free(struct strbuf **list);
 
 /**
- * Add the abbreviation, as generated by find_unique_abbrev, of `sha1` to
+ * Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
  * the strbuf `sb`.
  */
 struct repository;
@@ -706,14 +706,14 @@ static inline void strbuf_complete_line(struct strbuf *sb)
 
 /*
  * Copy "name" to "sb", expanding any special @-marks as handled by
- * interpret_branch_name(). The result is a non-qualified branch name
+ * repo_interpret_branch_name(). The result is a non-qualified branch name
  * (so "foo" or "origin/master" instead of "refs/heads/foo" or
  * "refs/remotes/origin/master").
  *
  * Note that the resulting name may not be a syntactically valid refname.
  *
  * If "allowed" is non-zero, restrict the set of allowed expansions. See
- * interpret_branch_name() for details.
+ * repo_interpret_branch_name() for details.
  */
 void strbuf_branchname(struct strbuf *sb, const char *name,
 		       unsigned allowed);
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH v2 17/17] libs: use "struct repository *" argument, not "the_repository"
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (15 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 16/17] post-cocci: adjust comments for recent repo_* migration Ævar Arnfjörð Bjarmason
@ 2023-03-28 13:58   ` Ævar Arnfjörð Bjarmason
  2023-03-28 14:09   ` [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros Junio C Hamano
  2023-03-29 19:02   ` Junio C Hamano
  18 siblings, 0 replies; 60+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-03-28 13:58 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Glen Choo, Elijah Newren,
	Ævar Arnfjörð Bjarmason

As can easily be seen from grepping in our sources, we had these uses
of "the_repository" in various library code in cases where the
function in question was already getting a "struct repository *"
argument. Let's use that argument instead.

Out of these changes only the changes to "cache-tree.c",
"commit-reach.c", "shallow.c" and "upload-pack.c" would have cleanly
applied before the migration away from the "repo_*()" wrapper macros
in the preceding commits.

The rest aren't new, as we'd previously implicitly refer to
"the_repository", but it's now more obvious that we were doing the
wrong thing all along, and should have used the parameter instead.

The change to change "get_index_format_default(the_repository)" in
"read-cache.c" to use the "r" variable instead should arguably have
been part of [1], or in the subsequent cleanup in [2]. Let's do it
here, as can be seen from the initial code in [3] it's not important
that we use "the_repository" there, but would prefer to always use the
current repository.

This change excludes the "the_repository" use in "upload-pack.c"'s
upload_pack_advertise(), as the in-flight [4] makes that change.

1. ee1f0c242ef (read-cache: add index.skipHash config option,
   2023-01-06)
2. 6269f8eaad0 (treewide: always have a valid "index_state.repo"
   member, 2023-01-17)
3. 7211b9e7534 (repo-settings: consolidate some config settings,
   2019-08-13)
4. <Y/hbUsGPVNAxTdmS@coredump.intra.peff.net>

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 add-interactive.c |   2 +-
 branch.c          |   8 ++--
 builtin/replace.c |   2 +-
 cache-tree.c      |   4 +-
 combine-diff.c    |   2 +-
 commit-graph.c    |   2 +-
 commit-reach.c    |   2 +-
 merge-recursive.c |   2 +-
 notes-cache.c     |   2 +-
 notes-utils.c     |   2 +-
 object-name.c     |   8 ++--
 read-cache.c      |   4 +-
 reset.c           |   2 +-
 sequencer.c       | 102 ++++++++++++++++++++++------------------------
 shallow.c         |   2 +-
 tree.c            |   2 +-
 wt-status.c       |  10 ++---
 17 files changed, 76 insertions(+), 82 deletions(-)

diff --git a/add-interactive.c b/add-interactive.c
index 313cfd39d8e..14ccea150a0 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -552,7 +552,7 @@ static int get_modified_files(struct repository *r,
 		opt.def = is_initial ?
 			empty_tree_oid_hex() : oid_to_hex(&head_oid);
 
-		repo_init_revisions(the_repository, &rev, NULL);
+		repo_init_revisions(r, &rev, NULL);
 		setup_revisions(0, NULL, &rev, &opt);
 
 		rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
diff --git a/branch.c b/branch.c
index 179353e7653..6fa61d1251d 100644
--- a/branch.c
+++ b/branch.c
@@ -532,7 +532,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
 		explicit_tracking = 1;
 
 	real_ref = NULL;
-	if (repo_get_oid_mb(the_repository, start_name, &oid)) {
+	if (repo_get_oid_mb(r, start_name, &oid)) {
 		if (explicit_tracking) {
 			int code = die_message(_(upstream_missing), start_name);
 			advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
@@ -542,8 +542,8 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
 		die(_("not a valid object name: '%s'"), start_name);
 	}
 
-	switch (repo_dwim_ref(the_repository, start_name, strlen(start_name),
-			      &oid, &real_ref, 0)) {
+	switch (repo_dwim_ref(r, start_name, strlen(start_name), &oid,
+			      &real_ref, 0)) {
 	case 0:
 		/* Not branching from any existing branch */
 		if (explicit_tracking)
@@ -774,7 +774,7 @@ void create_branches_recursively(struct repository *r, const char *name,
 			    name);
 	}
 
-	create_branch(the_repository, name, start_commitish, force, 0, reflog, quiet,
+	create_branch(r, name, start_commitish, force, 0, reflog, quiet,
 		      BRANCH_TRACK_NEVER, dry_run);
 	if (dry_run)
 		return;
diff --git a/builtin/replace.c b/builtin/replace.c
index ef70f2d1005..44ec1709676 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -56,7 +56,7 @@ static int show_reference(struct repository *r, const char *refname,
 			struct object_id object;
 			enum object_type obj_type, repl_type;
 
-			if (repo_get_oid(the_repository, refname, &object))
+			if (repo_get_oid(r, refname, &object))
 				return error(_("failed to resolve '%s' as a valid ref"), refname);
 
 			obj_type = oid_object_info(r, &object, NULL);
diff --git a/cache-tree.c b/cache-tree.c
index 12206eeaa3c..29ea7bd3646 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -816,14 +816,14 @@ void prime_cache_tree(struct repository *r,
 {
 	struct strbuf tree_path = STRBUF_INIT;
 
-	trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
+	trace2_region_enter("cache-tree", "prime_cache_tree", r);
 	cache_tree_free(&istate->cache_tree);
 	istate->cache_tree = cache_tree();
 
 	prime_cache_tree_rec(r, istate->cache_tree, tree, &tree_path);
 	strbuf_release(&tree_path);
 	istate->cache_changed |= CACHE_TREE_CHANGED;
-	trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
+	trace2_region_leave("cache-tree", "prime_cache_tree", r);
 }
 
 /*
diff --git a/combine-diff.c b/combine-diff.c
index 6077d4ec498..20953963946 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -333,7 +333,7 @@ static char *grab_blob(struct repository *r,
 		*size = fill_textconv(r, textconv, df, &blob);
 		free_filespec(df);
 	} else {
-		blob = repo_read_object_file(the_repository, oid, &type, size);
+		blob = repo_read_object_file(r, oid, &type, size);
 		if (type != OBJ_BLOB)
 			die("object '%s' is not a blob!", oid_to_hex(oid));
 	}
diff --git a/commit-graph.c b/commit-graph.c
index 6403567dfee..a394cee4f10 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2550,7 +2550,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
 
 		graph_commit = lookup_commit(r, &cur_oid);
 		odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
-		if (repo_parse_commit_internal(the_repository, odb_commit, 0, 0)) {
+		if (repo_parse_commit_internal(r, odb_commit, 0, 0)) {
 			graph_report(_("failed to parse commit %s from object database for commit-graph"),
 				     oid_to_hex(&cur_oid));
 			continue;
diff --git a/commit-reach.c b/commit-reach.c
index b9eb0952d7b..5957a8e950f 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -450,7 +450,7 @@ int repo_is_descendant_of(struct repository *r,
 	if (!with_commit)
 		return 1;
 
-	if (generation_numbers_enabled(the_repository)) {
+	if (generation_numbers_enabled(r)) {
 		struct commit_list *from_list = NULL;
 		int result;
 		commit_list_insert(commit, &from_list);
diff --git a/merge-recursive.c b/merge-recursive.c
index 9c80b7aa3a7..e3244721462 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3798,7 +3798,7 @@ static struct commit *get_ref(struct repository *repo,
 		return make_virtual_commit(repo, (struct tree*)object, name);
 	if (object->type != OBJ_COMMIT)
 		return NULL;
-	if (repo_parse_commit(the_repository, (struct commit *)object))
+	if (repo_parse_commit(repo, (struct commit *)object))
 		return NULL;
 	return (struct commit *)object;
 }
diff --git a/notes-cache.c b/notes-cache.c
index e5e9092d367..1a6e214ea79 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -23,7 +23,7 @@ static int notes_cache_match_validity(struct repository *r,
 		return 0;
 
 	memset(&pretty_ctx, 0, sizeof(pretty_ctx));
-	repo_format_commit_message(the_repository, commit, "%s", &msg,
+	repo_format_commit_message(r, commit, "%s", &msg,
 				   &pretty_ctx);
 	strbuf_trim(&msg);
 
diff --git a/notes-utils.c b/notes-utils.c
index 0550cfded86..4be0aaa6de9 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -23,7 +23,7 @@ void create_notes_commit(struct repository *r,
 		struct object_id parent_oid;
 		if (!read_ref(t->ref, &parent_oid)) {
 			struct commit *parent = lookup_commit(r, &parent_oid);
-			if (repo_parse_commit(the_repository, parent))
+			if (repo_parse_commit(r, parent))
 				die("Failed to find/parse commit %s", t->ref);
 			commit_list_insert(parent, &parents);
 		}
diff --git a/object-name.c b/object-name.c
index c7cef682f20..d63141bd043 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1039,7 +1039,7 @@ static enum get_oid_result get_parent(struct repository *r,
 	if (ret)
 		return ret;
 	commit = lookup_commit_reference(r, &oid);
-	if (repo_parse_commit(the_repository, commit))
+	if (repo_parse_commit(r, commit))
 		return MISSING_OBJECT;
 	if (!idx) {
 		oidcpy(result, &commit->object.oid);
@@ -1073,7 +1073,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r,
 		return MISSING_OBJECT;
 
 	while (generation--) {
-		if (repo_parse_commit(the_repository, commit) || !commit->parents)
+		if (repo_parse_commit(r, commit) || !commit->parents)
 			return MISSING_OBJECT;
 		commit = commit->parents->item;
 	}
@@ -1364,10 +1364,10 @@ static int get_oid_oneline(struct repository *r,
 		commit = pop_most_recent_commit(&list, ONELINE_SEEN);
 		if (!parse_object(r, &commit->object.oid))
 			continue;
-		buf = repo_get_commit_buffer(the_repository, commit, NULL);
+		buf = repo_get_commit_buffer(r, commit, NULL);
 		p = strstr(buf, "\n\n");
 		matches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));
-		repo_unuse_commit_buffer(the_repository, commit, buf);
+		repo_unuse_commit_buffer(r, commit, buf);
 
 		if (matches) {
 			oidcpy(oid, &commit->object.oid);
diff --git a/read-cache.c b/read-cache.c
index 4518a40ac06..0a336934a76 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2630,7 +2630,7 @@ int repo_index_has_changes(struct repository *repo,
 
 	if (tree)
 		cmp = tree->object.oid;
-	if (tree || !repo_get_oid_tree(the_repository, "HEAD", &cmp)) {
+	if (tree || !repo_get_oid_tree(repo, "HEAD", &cmp)) {
 		struct diff_options opt;
 
 		repo_diff_setup(repo, &opt);
@@ -2949,7 +2949,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
 	}
 
 	if (!istate->version)
-		istate->version = get_index_format_default(the_repository);
+		istate->version = get_index_format_default(r);
 
 	/* demote version 3 to version 2 when the latter suffices */
 	if (istate->version == 3 || istate->version == 2)
diff --git a/reset.c b/reset.c
index 8c471e22d99..b1234807188 100644
--- a/reset.c
+++ b/reset.c
@@ -107,7 +107,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
 		goto leave_reset_head;
 	}
 
-	if (!repo_get_oid(the_repository, "HEAD", &head_oid)) {
+	if (!repo_get_oid(r, "HEAD", &head_oid)) {
 		head = &head_oid;
 	} else if (!oid || !reset_hard) {
 		ret = error(_("could not determine HEAD revision"));
diff --git a/sequencer.c b/sequencer.c
index 84b07b818f0..c23f3e5fa67 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -692,8 +692,8 @@ static int do_recursive_merge(struct repository *r,
 	o.show_rename_progress = 1;
 
 	head_tree = parse_tree_indirect(head);
-	next_tree = next ? repo_get_commit_tree(the_repository, next) : empty_tree(r);
-	base_tree = base ? repo_get_commit_tree(the_repository, base) : empty_tree(r);
+	next_tree = next ? repo_get_commit_tree(r, next) : empty_tree(r);
+	base_tree = base ? repo_get_commit_tree(r, base) : empty_tree(r);
 
 	for (i = 0; i < opts->xopts_nr; i++)
 		parse_merge_opt(&o, opts->xopts[i]);
@@ -771,7 +771,7 @@ static int is_index_unchanged(struct repository *r)
 	 * the commit is invalid, repo_parse_commit() will complain.  So
 	 * there is nothing for us to say here.  Just return failure.
 	 */
-	if (repo_parse_commit(the_repository, head_commit))
+	if (repo_parse_commit(r, head_commit))
 		return -1;
 
 	if (!(cache_tree_oid = get_cache_tree_oid(istate)))
@@ -1336,15 +1336,15 @@ void print_commit_summary(struct repository *r,
 	commit = lookup_commit(r, oid);
 	if (!commit)
 		die(_("couldn't look up newly created commit"));
-	if (repo_parse_commit(the_repository, commit))
+	if (repo_parse_commit(r, commit))
 		die(_("could not parse newly created commit"));
 
 	strbuf_addstr(&format, "format:%h] %s");
 
-	repo_format_commit_message(the_repository, commit, "%an <%ae>",
-				   &author_ident, &pctx);
-	repo_format_commit_message(the_repository, commit, "%cn <%ce>",
-				   &committer_ident, &pctx);
+	repo_format_commit_message(r, commit, "%an <%ae>", &author_ident,
+				   &pctx);
+	repo_format_commit_message(r, commit, "%cn <%ce>", &committer_ident,
+				   &pctx);
 	if (strbuf_cmp(&author_ident, &committer_ident)) {
 		strbuf_addstr(&format, "\n Author: ");
 		strbuf_addbuf_percentquote(&format, &author_ident);
@@ -1352,8 +1352,7 @@ void print_commit_summary(struct repository *r,
 	if (flags & SUMMARY_SHOW_AUTHOR_DATE) {
 		struct strbuf date = STRBUF_INIT;
 
-		repo_format_commit_message(the_repository, commit, "%ad",
-					   &date, &pctx);
+		repo_format_commit_message(r, commit, "%ad", &date, &pctx);
 		strbuf_addstr(&format, "\n Date: ");
 		strbuf_addbuf_percentquote(&format, &date);
 		strbuf_release(&date);
@@ -1383,7 +1382,7 @@ void print_commit_summary(struct repository *r,
 	rev.diffopt.detect_rename = DIFF_DETECT_RENAME;
 	diff_setup_done(&rev.diffopt);
 
-	refs = get_main_ref_store(the_repository);
+	refs = get_main_ref_store(r);
 	head = refs_resolve_ref_unsafe(refs, "HEAD", 0, NULL, NULL);
 	if (!head)
 		die(_("unable to resolve HEAD after creating commit"));
@@ -1409,7 +1408,7 @@ static int parse_head(struct repository *r, struct commit **head)
 	struct commit *current_head;
 	struct object_id oid;
 
-	if (repo_get_oid(the_repository, "HEAD", &oid)) {
+	if (repo_get_oid(r, "HEAD", &oid)) {
 		current_head = NULL;
 	} else {
 		current_head = lookup_commit_reference(r, &oid);
@@ -1419,7 +1418,7 @@ static int parse_head(struct repository *r, struct commit **head)
 			warning(_("HEAD %s is not a commit!"),
 				oid_to_hex(&oid));
 		}
-		if (repo_parse_commit(the_repository, current_head))
+		if (repo_parse_commit(r, current_head))
 			return error(_("could not parse HEAD commit"));
 	}
 	*head = current_head;
@@ -1462,9 +1461,8 @@ static int try_to_commit(struct repository *r,
 	if (flags & AMEND_MSG) {
 		const char *exclude_gpgsig[] = { "gpgsig", "gpgsig-sha256", NULL };
 		const char *out_enc = get_commit_output_encoding();
-		const char *message = repo_logmsg_reencode(the_repository,
-							   current_head, NULL,
-							   out_enc);
+		const char *message = repo_logmsg_reencode(r, current_head,
+							   NULL, out_enc);
 
 		if (!msg) {
 			const char *orig_message = NULL;
@@ -1475,7 +1473,7 @@ static int try_to_commit(struct repository *r,
 			hook_commit = "HEAD";
 		}
 		author = amend_author = get_author(message);
-		repo_unuse_commit_buffer(the_repository, current_head,
+		repo_unuse_commit_buffer(r, current_head,
 					 message);
 		if (!author) {
 			res = error(_("unable to parse commit author"));
@@ -2002,18 +2000,18 @@ static int update_squash_messages(struct repository *r,
 		struct commit *head_commit;
 		const char *head_message, *body;
 
-		if (repo_get_oid(the_repository, "HEAD", &head))
+		if (repo_get_oid(r, "HEAD", &head))
 			return error(_("need a HEAD to fixup"));
 		if (!(head_commit = lookup_commit_reference(r, &head)))
 			return error(_("could not read HEAD"));
-		if (!(head_message = repo_logmsg_reencode(the_repository, head_commit, NULL, encoding)))
+		if (!(head_message = repo_logmsg_reencode(r, head_commit, NULL,
+							  encoding)))
 			return error(_("could not read HEAD's commit message"));
 
 		find_commit_subject(head_message, &body);
 		if (command == TODO_FIXUP && !flag && write_message(body, strlen(body),
 							rebase_path_fixup_msg(), 0) < 0) {
-			repo_unuse_commit_buffer(the_repository, head_commit,
-						 head_message);
+			repo_unuse_commit_buffer(r, head_commit, head_message);
 			return error(_("cannot write '%s'"), rebase_path_fixup_msg());
 		}
 		strbuf_addf(&buf, "%c ", comment_line_char);
@@ -2028,11 +2026,10 @@ static int update_squash_messages(struct repository *r,
 		else
 			strbuf_addstr(&buf, body);
 
-		repo_unuse_commit_buffer(the_repository, head_commit,
-					 head_message);
+		repo_unuse_commit_buffer(r, head_commit, head_message);
 	}
 
-	if (!(message = repo_logmsg_reencode(the_repository, commit, NULL, encoding)))
+	if (!(message = repo_logmsg_reencode(r, commit, NULL, encoding)))
 		return error(_("could not read commit message of %s"),
 			     oid_to_hex(&commit->object.oid));
 	find_commit_subject(message, &body);
@@ -2047,7 +2044,7 @@ static int update_squash_messages(struct repository *r,
 		strbuf_add_commented_lines(&buf, body, strlen(body));
 	} else
 		return error(_("unknown command: %d"), command);
-	repo_unuse_commit_buffer(the_repository, commit, message);
+	repo_unuse_commit_buffer(r, commit, message);
 
 	if (!res)
 		res = write_message(buf.buf, buf.len, rebase_path_squash_msg(),
@@ -2160,7 +2157,7 @@ static int do_pick_commit(struct repository *r,
 		if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL))
 			return error(_("your index file is unmerged."));
 	} else {
-		unborn = repo_get_oid(the_repository, "HEAD", &head);
+		unborn = repo_get_oid(r, "HEAD", &head);
 		/* Do we want to generate a root commit? */
 		if (is_pick_or_similar(command) && opts->have_squash_onto &&
 		    oideq(&head, &opts->squash_onto)) {
@@ -2222,7 +2219,7 @@ static int do_pick_commit(struct repository *r,
 		msg_file = NULL;
 		goto fast_forward_edit;
 	}
-	if (parent && repo_parse_commit(the_repository, parent) < 0)
+	if (parent && repo_parse_commit(r, parent) < 0)
 		/* TRANSLATORS: The first %s will be a "todo" command like
 		   "revert" or "pick", the second %s a SHA1. */
 		return error(_("%s: cannot parse parent commit %s"),
@@ -2614,7 +2611,7 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
 	end_of_object_name = (char *) bol + strcspn(bol, " \t\n");
 	saved = *end_of_object_name;
 	*end_of_object_name = '\0';
-	status = repo_get_oid(the_repository, bol, &commit_oid);
+	status = repo_get_oid(r, bol, &commit_oid);
 	if (status < 0)
 		error(_("could not parse '%s'"), bol); /* return later */
 	*end_of_object_name = saved;
@@ -3534,12 +3531,12 @@ static int make_patch(struct repository *r,
 	strbuf_addf(&buf, "%s/message", get_dir(opts));
 	if (!file_exists(buf.buf)) {
 		const char *encoding = get_commit_output_encoding();
-		const char *commit_buffer = repo_logmsg_reencode(the_repository,
+		const char *commit_buffer = repo_logmsg_reencode(r,
 								 commit, NULL,
 								 encoding);
 		find_commit_subject(commit_buffer, &subject);
 		res |= write_message(subject, strlen(subject), buf.buf, 1);
-		repo_unuse_commit_buffer(the_repository, commit,
+		repo_unuse_commit_buffer(r, commit,
 					 commit_buffer);
 	}
 	strbuf_release(&buf);
@@ -3719,7 +3716,7 @@ static int do_label(struct repository *r, const char *name, int len)
 	if (!transaction) {
 		error("%s", err.buf);
 		ret = -1;
-	} else if (repo_get_oid(the_repository, "HEAD", &head_oid)) {
+	} else if (repo_get_oid(r, "HEAD", &head_oid)) {
 		error(_("could not read HEAD"));
 		ret = -1;
 	} else if (ref_transaction_update(transaction, ref_name.buf, &head_oid,
@@ -4007,8 +4004,7 @@ static int do_merge(struct repository *r,
 
 	if (commit) {
 		const char *encoding = get_commit_output_encoding();
-		const char *message = repo_logmsg_reencode(the_repository,
-							   commit, NULL,
+		const char *message = repo_logmsg_reencode(r, commit, NULL,
 							   encoding);
 		const char *body;
 		int len;
@@ -4022,7 +4018,7 @@ static int do_merge(struct repository *r,
 		find_commit_subject(message, &body);
 		len = strlen(body);
 		ret = write_message(body, len, git_path_merge_msg(r), 0);
-		repo_unuse_commit_buffer(the_repository, commit, message);
+		repo_unuse_commit_buffer(r, commit, message);
 		if (ret) {
 			error_errno(_("could not write '%s'"),
 				    git_path_merge_msg(r));
@@ -4122,8 +4118,7 @@ static int do_merge(struct repository *r,
 	}
 
 	merge_commit = to_merge->item;
-	bases = repo_get_merge_bases(the_repository, head_commit,
-				     merge_commit);
+	bases = repo_get_merge_bases(r, head_commit, merge_commit);
 	if (bases && oideq(&merge_commit->object.oid,
 			   &bases->item->object.oid)) {
 		ret = 0;
@@ -4478,7 +4473,7 @@ void create_autostash(struct repository *r, const char *path)
 		if (capture_command(&stash, &buf, GIT_MAX_HEXSZ))
 			die(_("Cannot autostash"));
 		strbuf_trim_trailing_newline(&buf);
-		if (repo_get_oid(the_repository, buf.buf, &oid))
+		if (repo_get_oid(r, buf.buf, &oid))
 			die(_("Unexpected stash response: '%s'"),
 			    buf.buf);
 		strbuf_reset(&buf);
@@ -4603,9 +4598,9 @@ static int stopped_at_head(struct repository *r)
 	struct commit *commit;
 	struct commit_message message;
 
-	if (repo_get_oid(the_repository, "HEAD", &head) ||
+	if (repo_get_oid(r, "HEAD", &head) ||
 	    !(commit = lookup_commit(r, &head)) ||
-	    repo_parse_commit(the_repository, commit) || get_message(commit, &message))
+	    repo_parse_commit(r, commit) || get_message(commit, &message))
 		fprintf(stderr, _("Stopped at HEAD\n"));
 	else {
 		fprintf(stderr, _("Stopped at %s\n"), message.label);
@@ -4753,7 +4748,7 @@ static int pick_commits(struct repository *r,
 				 * otherwise we do not.
 				 */
 				if (item->command == TODO_REWORD &&
-				    !repo_get_oid(the_repository, "HEAD", &oid) &&
+				    !repo_get_oid(r, "HEAD", &oid) &&
 				    (oideq(&item->commit->object.oid, &oid) ||
 				     (opts->have_squash_onto &&
 				      oideq(&opts->squash_onto, &oid))))
@@ -4842,7 +4837,7 @@ static int pick_commits(struct repository *r,
 			struct object_id head, orig;
 			int res;
 
-			if (repo_get_oid(the_repository, "HEAD", &head)) {
+			if (repo_get_oid(r, "HEAD", &head)) {
 				res = error(_("cannot read HEAD"));
 cleanup_head_ref:
 				strbuf_release(&head_ref);
@@ -4889,8 +4884,8 @@ static int pick_commits(struct repository *r,
 			log_tree_opt.disable_stdin = 1;
 
 			if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
-			    !repo_get_oid(the_repository, buf.buf, &orig) &&
-			    !repo_get_oid(the_repository, "HEAD", &head)) {
+			    !repo_get_oid(r, buf.buf, &orig) &&
+			    !repo_get_oid(r, "HEAD", &head)) {
 				diff_tree_oid(&orig, &head, "",
 					      &log_tree_opt.diffopt);
 				log_tree_diff_flush(&log_tree_opt);
@@ -4982,7 +4977,7 @@ static int commit_staged_changes(struct repository *r,
 		struct strbuf rev = STRBUF_INIT;
 		struct object_id head, to_amend;
 
-		if (repo_get_oid(the_repository, "HEAD", &head))
+		if (repo_get_oid(r, "HEAD", &head))
 			return error(_("cannot amend non-existing commit"));
 		if (!read_oneliner(&rev, rebase_path_amend(), 0))
 			return error(_("invalid file: '%s'"), rebase_path_amend());
@@ -5062,14 +5057,13 @@ static int commit_staged_changes(struct repository *r,
 				const char *encoding = get_commit_output_encoding();
 
 				if (parse_head(r, &commit) ||
-				    !(p = repo_logmsg_reencode(the_repository, commit, NULL, encoding)) ||
+				    !(p = repo_logmsg_reencode(r, commit, NULL, encoding)) ||
 				    write_message(p, strlen(p), path, 0)) {
-					repo_unuse_commit_buffer(the_repository,
-								 commit, p);
+					repo_unuse_commit_buffer(r, commit, p);
 					return error(_("could not write file: "
 						       "'%s'"), path);
 				}
-				repo_unuse_commit_buffer(the_repository,
+				repo_unuse_commit_buffer(r,
 							 commit, p);
 			}
 		}
@@ -5209,7 +5203,7 @@ int sequencer_pick_revisions(struct repository *r,
 		if (!strlen(name))
 			continue;
 
-		if (!repo_get_oid(the_repository, name, &oid)) {
+		if (!repo_get_oid(r, name, &oid)) {
 			if (!lookup_commit_reference_gently(r, &oid, 1)) {
 				enum object_type type = oid_object_info(r,
 									&oid,
@@ -5252,7 +5246,7 @@ int sequencer_pick_revisions(struct repository *r,
 	if (walk_revs_populate_todo(&todo_list, opts) ||
 			create_seq_dir(r) < 0)
 		return -1;
-	if (repo_get_oid(the_repository, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
+	if (repo_get_oid(r, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
 		return error(_("can't revert as initial commit"));
 	if (save_head(oid_to_hex(&oid)))
 		return -1;
@@ -5947,7 +5941,7 @@ static int skip_unnecessary_picks(struct repository *r,
 			continue;
 		if (item->command != TODO_PICK)
 			break;
-		if (repo_parse_commit(the_repository, item->commit)) {
+		if (repo_parse_commit(r, item->commit)) {
 			return error(_("could not parse commit '%s'"),
 				oid_to_hex(&item->commit->object.oid));
 		}
@@ -6118,7 +6112,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
 	struct object_id oid = onto->object.oid;
 	int res;
 
-	repo_find_unique_abbrev_r(the_repository, shortonto, &oid,
+	repo_find_unique_abbrev_r(r, shortonto, &oid,
 				  DEFAULT_ABBREV);
 
 	if (buf->len == 0) {
@@ -6398,8 +6392,8 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
 		if (file_exists(git_path_seq_dir()))
 			*whence = FROM_CHERRY_PICK_MULTI;
 		if (file_exists(rebase_path()) &&
-		    !repo_get_oid(the_repository, "REBASE_HEAD", &rebase_head) &&
-		    !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
+		    !repo_get_oid(r, "REBASE_HEAD", &rebase_head) &&
+		    !repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
 		    oideq(&rebase_head, &cherry_pick_head))
 			*whence = FROM_REBASE_PICK;
 		else
diff --git a/shallow.c b/shallow.c
index ce21f66e5e1..4f34861423f 100644
--- a/shallow.c
+++ b/shallow.c
@@ -32,7 +32,7 @@ int register_shallow(struct repository *r, const struct object_id *oid)
 {
 	struct commit_graft *graft =
 		xmalloc(sizeof(struct commit_graft));
-	struct commit *commit = lookup_commit(the_repository, oid);
+	struct commit *commit = lookup_commit(r, oid);
 
 	oidcpy(&graft->oid, oid);
 	graft->nr_parent = -1;
diff --git a/tree.c b/tree.c
index 955b53f6a57..2b78708766b 100644
--- a/tree.c
+++ b/tree.c
@@ -59,7 +59,7 @@ int read_tree_at(struct repository *r,
 				    oid_to_hex(&entry.oid),
 				    base->buf, entry.path);
 
-			if (repo_parse_commit(the_repository, commit))
+			if (repo_parse_commit(r, commit))
 				die("Invalid commit %s in submodule path %s%s",
 				    oid_to_hex(&entry.oid),
 				    base->buf, entry.path);
diff --git a/wt-status.c b/wt-status.c
index 84726d26dc9..151b94aa369 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1665,7 +1665,7 @@ static void wt_status_get_detached_from(struct repository *r,
 		return;
 	}
 
-	if (repo_dwim_ref(the_repository, cb.buf.buf, cb.buf.len, &oid, &ref,
+	if (repo_dwim_ref(r, cb.buf.buf, cb.buf.len, &oid, &ref,
 			  1) == 1 &&
 	    /* oid is a commit? match without further lookup */
 	    (oideq(&cb.noid, &oid) ||
@@ -1678,9 +1678,9 @@ static void wt_status_get_detached_from(struct repository *r,
 		state->detached_from = xstrdup(from);
 	} else
 		state->detached_from =
-			xstrdup(repo_find_unique_abbrev(the_repository, &cb.noid, DEFAULT_ABBREV));
+			xstrdup(repo_find_unique_abbrev(r, &cb.noid, DEFAULT_ABBREV));
 	oidcpy(&state->detached_oid, &cb.noid);
-	state->detached_at = !repo_get_oid(the_repository, "HEAD", &oid) &&
+	state->detached_at = !repo_get_oid(r, "HEAD", &oid) &&
 			     oideq(&oid, &state->detached_oid);
 
 	free(ref);
@@ -1771,13 +1771,13 @@ void wt_status_get_state(struct repository *r,
 	} else if (wt_status_check_rebase(NULL, state)) {
 		;		/* all set */
 	} else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
-		   !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &oid)) {
+		   !repo_get_oid(r, "CHERRY_PICK_HEAD", &oid)) {
 		state->cherry_pick_in_progress = 1;
 		oidcpy(&state->cherry_pick_head_oid, &oid);
 	}
 	wt_status_check_bisect(NULL, state);
 	if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") &&
-	    !repo_get_oid(the_repository, "REVERT_HEAD", &oid)) {
+	    !repo_get_oid(r, "REVERT_HEAD", &oid)) {
 		state->revert_in_progress = 1;
 		oidcpy(&state->revert_head_oid, &oid);
 	}
-- 
2.40.0.rc1.1034.g5867a1b10c5


^ permalink raw reply related	[flat|nested] 60+ messages in thread

* Re: [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (16 preceding siblings ...)
  2023-03-28 13:58   ` [PATCH v2 17/17] libs: use "struct repository *" argument, not "the_repository" Ævar Arnfjörð Bjarmason
@ 2023-03-28 14:09   ` Junio C Hamano
  2023-03-28 14:34     ` Junio C Hamano
  2023-03-29 19:02   ` Junio C Hamano
  18 siblings, 1 reply; 60+ messages in thread
From: Junio C Hamano @ 2023-03-28 14:09 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Glen Choo, Elijah Newren

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> A v2 of the removal of "the_repository" wrapper macros and adjacent
> cleanups. The v1 subject for this said "the_index", sorry!
>
> See v1 [1] for a more general overview. The changes since v1 are
> trivial & best skimmed from the range-diff, just a rebasing,
> clarification in a commit message, and a typo fix, thanks all!
>
> As before this has a trivial conflict with "seen", but this time
> around the conflict is different, but it's trivially solved as before,

On what commit is this targetted to be applied in the first place?
It does not look like it would apply on the same base as the
previous one is queued.

Thanks.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros
  2023-03-28 14:09   ` [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros Junio C Hamano
@ 2023-03-28 14:34     ` Junio C Hamano
  0 siblings, 0 replies; 60+ messages in thread
From: Junio C Hamano @ 2023-03-28 14:34 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Glen Choo, Elijah Newren

Junio C Hamano <gitster@pobox.com> writes:

> On what commit is this targetted to be applied in the first place?
> It does not look like it would apply on the same base as the
> previous one is queued.

OK, I managed to backport them to the same base before replacing.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros
  2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
                     ` (17 preceding siblings ...)
  2023-03-28 14:09   ` [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros Junio C Hamano
@ 2023-03-29 19:02   ` Junio C Hamano
  2023-03-29 22:04     ` Taylor Blau
                       ` (2 more replies)
  18 siblings, 3 replies; 60+ messages in thread
From: Junio C Hamano @ 2023-03-29 19:02 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Glen Choo, Elijah Newren

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

>  1:  c167bde3c0c !  1:  e1e27490d60 cocci: remove dead rule from "the_repository.pending.cocci"
>     @@ Commit message
>          cocci: remove dead rule from "the_repository.pending.cocci"
>      
>          The "parse_commit_gently" macro went away in [1], so we don't need to
>     -    carry his for its migration.
>     +    carry this for its migration.
>      
>          1. ea3f7e598c8 (revision: use repository from rev_info when parsing
>             commits, 2020-06-23)
>  2:  1b1fc5d41f5 =  2:  5ac9d5b8905 cocci: fix incorrect & verbose "the_repository" rules
>  3:  34c6b8afd6c !  3:  a3fcd19d744 cocci: sort "the_repository" rules by header
>     @@ Commit message
>          rules. This will make subsequent commits easier to follow, as we'll be
>          applying these rules on a header-by-header basis.
>      
>     +    Once we've fully applied "the_repository.pending.cocci" we'll keep
>     +    this rules around for a while in "the_repository.cocci", to help any
>     +    outstanding topics and out-of-tree code to resolve textual or semantic
>     +    conflicts with these changes, but eventually we'll remove the
>     +    "the_repository.cocci" as a follow-up.
>     +
>     +    So even if some of these functions are subsequently moved and/or split
>     +    into other or new headers there's no risk of this becoming stale, if
>     +    and when that happens the we should be removing these rules anyway.
>     +
>          Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>      
>       ## contrib/coccinelle/the_repository.pending.cocci ##

After removing the rebase noise from later steps, the above two are
the real changes compared to the previous round.

Are people happy with the result?  I think the previous round was
both read carefully on the central piece of the series, with some
spot checks to mechanical parts, and with the above clarification
the series is ready to be merged down to 'next'.

If I am grossly off base in the above assessment, please holler
soonish.  Thanks.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH v2 02/17] cocci: fix incorrect & verbose "the_repository" rules
  2023-03-28 13:58   ` [PATCH v2 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
@ 2023-03-29 20:35     ` Taylor Blau
  0 siblings, 0 replies; 60+ messages in thread
From: Taylor Blau @ 2023-03-29 20:35 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, Glen Choo, Elijah Newren

On Tue, Mar 28, 2023 at 03:58:43PM +0200, Ævar Arnfjörð Bjarmason wrote:
>  .../coccinelle/the_repository.pending.cocci   | 160 +++++-------------
>  1 file changed, 46 insertions(+), 114 deletions(-)

I resonate with Elijah's "I know nothing about Coccinelle" statement in
v1 of this patch more than I am willing to admit ;-).

I am glad that Coccinelle has some better tools for us to more easily
express these macros. The end-result is very nice and has a clear
interpretation.

Thanks for cleaning these up.

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH v2 16/17] post-cocci: adjust comments for recent repo_* migration
  2023-03-28 13:58   ` [PATCH v2 16/17] post-cocci: adjust comments for recent repo_* migration Ævar Arnfjörð Bjarmason
@ 2023-03-29 20:50     ` Taylor Blau
  0 siblings, 0 replies; 60+ messages in thread
From: Taylor Blau @ 2023-03-29 20:50 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, Glen Choo, Elijah Newren

On Tue, Mar 28, 2023 at 03:58:57PM +0200, Ævar Arnfjörð Bjarmason wrote:
> In preceding commits we changed many calls to macros that were
> providing a "the_repository" argument to invoke corresponding repo_*()
> function instead. Let's follow-up and adjust references to those in
> comments, which coccinelle didn't (and inherently can't) catch.

Thanks for being extra meticulous here.

Did you write a script to catch any of these? Asking partly to satisfy
my own curiosity, but I also think that it might be worth including in
this patch if you did do something other than manual inspection.

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros
  2023-03-29 19:02   ` Junio C Hamano
@ 2023-03-29 22:04     ` Taylor Blau
  2023-03-30  3:55     ` Elijah Newren
  2023-03-30 18:08     ` Glen Choo
  2 siblings, 0 replies; 60+ messages in thread
From: Taylor Blau @ 2023-03-29 22:04 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Ævar Arnfjörð Bjarmason, git, Glen Choo,
	Elijah Newren

On Wed, Mar 29, 2023 at 12:02:29PM -0700, Junio C Hamano wrote:
> Are people happy with the result?  I think the previous round was
> both read carefully on the central piece of the series, with some
> spot checks to mechanical parts, and with the above clarification
> the series is ready to be merged down to 'next'.

I didn't review v1, so take this email with a grain of salt, but I am
happy with the current round and would be happy to see it go to 'next'.

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros
  2023-03-29 19:02   ` Junio C Hamano
  2023-03-29 22:04     ` Taylor Blau
@ 2023-03-30  3:55     ` Elijah Newren
  2023-03-30 18:08     ` Glen Choo
  2 siblings, 0 replies; 60+ messages in thread
From: Elijah Newren @ 2023-03-30  3:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ævar Arnfjörð Bjarmason, git, Glen Choo

On Wed, Mar 29, 2023 at 12:02 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
> >  1:  c167bde3c0c !  1:  e1e27490d60 cocci: remove dead rule from "the_repository.pending.cocci"
> >     @@ Commit message
> >          cocci: remove dead rule from "the_repository.pending.cocci"
> >
> >          The "parse_commit_gently" macro went away in [1], so we don't need to
> >     -    carry his for its migration.
> >     +    carry this for its migration.
> >
> >          1. ea3f7e598c8 (revision: use repository from rev_info when parsing
> >             commits, 2020-06-23)
> >  2:  1b1fc5d41f5 =  2:  5ac9d5b8905 cocci: fix incorrect & verbose "the_repository" rules
> >  3:  34c6b8afd6c !  3:  a3fcd19d744 cocci: sort "the_repository" rules by header
> >     @@ Commit message
> >          rules. This will make subsequent commits easier to follow, as we'll be
> >          applying these rules on a header-by-header basis.
> >
> >     +    Once we've fully applied "the_repository.pending.cocci" we'll keep
> >     +    this rules around for a while in "the_repository.cocci", to help any
> >     +    outstanding topics and out-of-tree code to resolve textual or semantic
> >     +    conflicts with these changes, but eventually we'll remove the
> >     +    "the_repository.cocci" as a follow-up.
> >     +
> >     +    So even if some of these functions are subsequently moved and/or split
> >     +    into other or new headers there's no risk of this becoming stale, if
> >     +    and when that happens the we should be removing these rules anyway.
> >     +
> >          Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> >
> >       ## contrib/coccinelle/the_repository.pending.cocci ##
>
> After removing the rebase noise from later steps, the above two are
> the real changes compared to the previous round.
>
> Are people happy with the result?  I think the previous round was
> both read carefully on the central piece of the series, with some
> spot checks to mechanical parts, and with the above clarification
> the series is ready to be merged down to 'next'.
>
> If I am grossly off base in the above assessment, please holler
> soonish.  Thanks.

These two changes address the only minor points I had with the series.
My other comments were either being happy about the changes, or noting
some other things outside the scope of this series that would also be
nice to cleanup.  So I'm happy with merging down.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros
  2023-03-29 19:02   ` Junio C Hamano
  2023-03-29 22:04     ` Taylor Blau
  2023-03-30  3:55     ` Elijah Newren
@ 2023-03-30 18:08     ` Glen Choo
  2 siblings, 0 replies; 60+ messages in thread
From: Glen Choo @ 2023-03-30 18:08 UTC (permalink / raw)
  To: Junio C Hamano, Ævar Arnfjörð Bjarmason; +Cc: git, Elijah Newren

Junio C Hamano <gitster@pobox.com> writes:

>>     +    Once we've fully applied "the_repository.pending.cocci" we'll keep
>>     +    this rules around for a while in "the_repository.cocci", to help any
>>     +    outstanding topics and out-of-tree code to resolve textual or semantic
>>     +    conflicts with these changes, but eventually we'll remove the
>>     +    "the_repository.cocci" as a follow-up.
>>     +
>>     +    So even if some of these functions are subsequently moved and/or split
>>     +    into other or new headers there's no risk of this becoming stale, if
>>     +    and when that happens the we should be removing these rules anyway.
>>     +
>>          Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>
> Are people happy with the result?  I think the previous round was
> both read carefully on the central piece of the series, with some
> spot checks to mechanical parts, and with the above clarification
> the series is ready to be merged down to 'next'.

Likewise, I'm also happy to see this merged to 'next'.

My comments on v1 were sanity-checking how we use coccinelle in this
series, not any actual objection :)

^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2023-03-30 18:08 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
2023-03-17 16:14   ` Eric Sunshine
2023-03-19  5:53   ` Elijah Newren
2023-03-17 15:35 ` [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
2023-03-19  5:55   ` Elijah Newren
2023-03-22 22:46   ` Glen Choo
2023-03-26  5:02     ` Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 03/17] cocci: sort "the_repository" rules by header Ævar Arnfjörð Bjarmason
2023-03-19  5:59   ` Elijah Newren
2023-03-17 15:35 ` [PATCH 04/17] cocci: add missing "the_repository" macros to "pending" Ævar Arnfjörð Bjarmason
2023-03-19  6:04   ` Elijah Newren
2023-03-17 15:35 ` [PATCH 05/17] cocci: apply the "cache.h" part of "the_repository.pending" Ævar Arnfjörð Bjarmason
2023-03-19  6:06   ` Elijah Newren
2023-03-22 23:17   ` Glen Choo
2023-03-17 15:35 ` [PATCH 06/17] cocci: apply the "commit-reach.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 07/17] cocci: apply the "commit.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 08/17] cocci: apply the "diff.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 09/17] cocci: apply the "object-store.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 10/17] cocci: apply the "pretty.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 11/17] cocci: apply the "packfile.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 12/17] cocci: apply the "promisor-remote.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 13/17] cocci: apply the "refs.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 14/17] cocci: apply the "rerere.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 15/17] cocci: apply the "revision.h" " Ævar Arnfjörð Bjarmason
2023-03-22 23:38   ` Glen Choo
2023-03-22 23:53     ` Glen Choo
2023-03-26  4:59       ` Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 16/17] post-cocci: adjust comments for recent repo_* migration Ævar Arnfjörð Bjarmason
2023-03-19  6:12   ` Elijah Newren
2023-03-17 15:35 ` [PATCH 17/17] libs: use "struct repository *" argument, not "the_repository" Ævar Arnfjörð Bjarmason
2023-03-19  6:19   ` Elijah Newren
2023-03-28 10:53     ` Ævar Arnfjörð Bjarmason
2023-03-17 19:22 ` [PATCH 00/17] cocci: remove "the_index" wrapper macros Junio C Hamano
2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
2023-03-29 20:35     ` Taylor Blau
2023-03-28 13:58   ` [PATCH v2 03/17] cocci: sort "the_repository" rules by header Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 04/17] cocci: add missing "the_repository" macros to "pending" Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 05/17] cocci: apply the "cache.h" part of "the_repository.pending" Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 06/17] cocci: apply the "commit-reach.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 07/17] cocci: apply the "commit.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 08/17] cocci: apply the "diff.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 09/17] cocci: apply the "object-store.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 10/17] cocci: apply the "pretty.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 11/17] cocci: apply the "packfile.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 12/17] cocci: apply the "promisor-remote.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 13/17] cocci: apply the "refs.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 14/17] cocci: apply the "rerere.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 15/17] cocci: apply the "revision.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 16/17] post-cocci: adjust comments for recent repo_* migration Ævar Arnfjörð Bjarmason
2023-03-29 20:50     ` Taylor Blau
2023-03-28 13:58   ` [PATCH v2 17/17] libs: use "struct repository *" argument, not "the_repository" Ævar Arnfjörð Bjarmason
2023-03-28 14:09   ` [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros Junio C Hamano
2023-03-28 14:34     ` Junio C Hamano
2023-03-29 19:02   ` Junio C Hamano
2023-03-29 22:04     ` Taylor Blau
2023-03-30  3:55     ` Elijah Newren
2023-03-30 18:08     ` Glen Choo

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).