]> Kevux Git Server - rit/commitdiff
global: introduce `USE_THE_REPOSITORY_VARIABLE` macro
authorPatrick Steinhardt <ps@pks.im>
Fri, 14 Jun 2024 06:50:23 +0000 (08:50 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Jun 2024 17:26:33 +0000 (10:26 -0700)
Use of the `the_repository` variable is deprecated nowadays, and we
slowly but steadily convert the codebase to not use it anymore. Instead,
callers should be passing down the repository to work on via parameters.

It is hard though to prove that a given code unit does not use this
variable anymore. The most trivial case, merely demonstrating that there
is no direct use of `the_repository`, is already a bit of a pain during
code reviews as the reviewer needs to manually verify claims made by the
patch author. The bigger problem though is that we have many interfaces
that implicitly rely on `the_repository`.

Introduce a new `USE_THE_REPOSITORY_VARIABLE` macro that allows code
units to opt into usage of `the_repository`. The intent of this macro is
to demonstrate that a certain code unit does not use this variable
anymore, and to keep it from new dependencies on it in future changes,
be it explicit or implicit

For now, the macro only guards `the_repository` itself as well as
`the_hash_algo`. There are many more known interfaces where we have an
implicit dependency on `the_repository`, but those are not guarded at
the current point in time. Over time though, we should start to add
guards as required (or even better, just remove them).

Define the macro as required in our code units. As expected, most of our
code still relies on the global variable. Nearly all of our builtins
rely on the variable as there is no way yet to pass `the_repository` to
their entry point. For now, declare the macro in "biultin.h" to keep the
required changes at least a little bit more contained.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
160 files changed:
add-interactive.c
add-patch.c
apply.c
archive-tar.c
archive-zip.c
archive.c
attr.c
bisect.c
blame.c
branch.c
builtin.h
builtin/blame.c
builtin/log.c
bulk-checkin.c
bundle-uri.c
bundle.c
cache-tree.c
checkout.c
chunk-format.c
combine-diff.c
commit-graph.c
commit-reach.c
commit.c
common-main.c
compat/win32/trace2_win32_process_info.c
config.c
connected.c
convert.c
csum-file.c
delta-islands.c
diagnose.c
diff-lib.c
diff.c
diffcore-break.c
diffcore-rename.c
dir.c
entry.c
environment.c
fetch-pack.c
fmt-merge-msg.c
fsck.c
fsmonitor-ipc.c
git.c
hash-lookup.c
hash.h
help.c
hex.c
http-backend.c
http-push.c
http-walker.c
http.c
list-objects-filter-options.c
list-objects-filter.c
list-objects.c
log-tree.c
loose.c
ls-refs.c
mailmap.c
match-trees.c
merge-blobs.c
merge-ort.c
merge-recursive.c
merge.c
midx-write.c
midx.c
negotiator/default.c
negotiator/skipping.c
notes-cache.c
notes-merge.c
notes-utils.c
notes.c
object-file-convert.c
object-file.c
object-name.c
object.c
oid-array.c
oss-fuzz/fuzz-commit-graph.c
pack-bitmap-write.c
pack-bitmap.c
pack-check.c
pack-revindex.c
pack-write.c
packfile.c
parse-options-cb.c
path.c
pathspec.c
pretty.c
progress.c
promisor-remote.c
range-diff.c
reachable.c
read-cache.c
rebase-interactive.c
ref-filter.c
reflog-walk.c
reflog.c
refs.c
refs/files-backend.c
refs/packed-backend.c
refs/reftable-backend.c
refspec.c
remote-curl.c
remote.c
repository.c
repository.h
rerere.c
reset.c
resolve-undo.c
revision.c
run-command.c
scalar.c
send-pack.c
sequencer.c
serve.c
server-info.c
setup.c
shallow.c
split-index.c
streaming.c
submodule-config.c
submodule.c
t/helper/test-bitmap.c
t/helper/test-bloom.c
t/helper/test-cache-tree.c
t/helper/test-dump-cache-tree.c
t/helper/test-dump-fsmonitor.c
t/helper/test-dump-split-index.c
t/helper/test-dump-untracked-cache.c
t/helper/test-find-pack.c
t/helper/test-fsmonitor-client.c
t/helper/test-lazy-init-name-hash.c
t/helper/test-match-trees.c
t/helper/test-oidmap.c
t/helper/test-pack-mtimes.c
t/helper/test-reach.c
t/helper/test-read-cache.c
t/helper/test-read-graph.c
t/helper/test-read-midx.c
t/helper/test-ref-store.c
t/helper/test-repository.c
t/helper/test-revision-walking.c
t/helper/test-scrap-cache-tree.c
t/helper/test-submodule-config.c
t/helper/test-submodule-nested-repo-config.c
t/helper/test-submodule.c
t/helper/test-trace2.c
t/helper/test-write-cache.c
t/unit-tests/t-example-decorate.c
tag.c
tmp-objdir.c
transport-helper.c
transport.c
tree-walk.c
tree.c
unpack-trees.c
upload-pack.c
walker.c
worktree.c
wt-status.c
xdiff-interface.c

index a096109..49042b3 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "add-interactive.h"
 #include "color.h"
index 8618177..99e037c 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "add-interactive.h"
 #include "advice.h"
diff --git a/apply.c b/apply.c
index 528939a..ff939f9 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -7,6 +7,8 @@
  *
  */
 
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "base85.h"
index 8ae3012..e7b3489 100644 (file)
@@ -1,6 +1,9 @@
 /*
  * Copyright (c) 2005, 2006 Rene Scharfe
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "gettext.h"
index fd1d3f8..9f32730 100644 (file)
@@ -1,6 +1,9 @@
 /*
  * Copyright (c) 2006 Rene Scharfe
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "archive.h"
index 5287fcd..7bd60d0 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
diff --git a/attr.c b/attr.c
index 300f994..b5ed83c 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -6,6 +6,8 @@
  * an insanely large number of attributes.
  */
 
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
index 4ea703b..135f94b 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "commit.h"
diff --git a/blame.c b/blame.c
index a80f5e2..d403c46 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "refs.h"
 #include "object-store-ll.h"
index df5d24f..c887ea2 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "advice.h"
 #include "config.h"
index 7eda9b2..14fa017 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -1,6 +1,14 @@
 #ifndef BUILTIN_H
 #define BUILTIN_H
 
+/*
+ * TODO: Almost all of our builtins access `the_repository` by necessity
+ * because they do not get passed a pointer to it. We should adapt the function
+ * signature of those main functions to accept a `struct repository *` and then
+ * remove the macro here.
+ */
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 
 /*
index e09ff01..de89fff 100644 (file)
@@ -5,7 +5,7 @@
  * See COPYING for licensing conditions
  */
 
-#include "git-compat-util.h"
+#include "builtin.h"
 #include "config.h"
 #include "color.h"
 #include "builtin.h"
index ccbda8a..00305be 100644 (file)
@@ -4,7 +4,7 @@
  * (C) Copyright 2006 Linus Torvalds
  *              2006 Junio Hamano
  */
-#include "git-compat-util.h"
+#include "builtin.h"
 #include "abspath.h"
 #include "config.h"
 #include "environment.h"
index eb46b88..da86731 100644 (file)
@@ -1,6 +1,9 @@
 /*
  * Copyright (c) 2011, Google Inc.
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "bulk-checkin.h"
 #include "environment.h"
index 91b3319..804fbcf 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "bundle-uri.h"
 #include "bundle.h"
index 95367c2..82c285b 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "lockfile.h"
 #include "bundle.h"
index 3290a1b..50610c3 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
index cfaea4b..0b1cf8b 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "object-name.h"
 #include "remote.h"
index cdc7f39..2dde24e 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "chunk-format.h"
 #include "csum-file.h"
index 4960d90..829a44e 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "object-store-ll.h"
 #include "commit.h"
index 98cbd53..e1070ee 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "csum-file.h"
index 384aee1..dabc297 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "commit.h"
 #include "commit-graph.h"
index 1d08951..4956803 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "tag.h"
 #include "commit.h"
index b86f406..8e68ac9 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "exec-cmd.h"
 #include "gettext.h"
index 3ef0936..f147da7 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "../../git-compat-util.h"
 #include "../../json-writer.h"
 #include "../../repository.h"
index abce05b..7951029 100644 (file)
--- a/config.c
+++ b/config.c
@@ -5,6 +5,9 @@
  * Copyright (C) Johannes Schindelin, 2005
  *
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
index 8f89376..87cc4b5 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
index f2b9f01..d8737fe 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "advice.h"
 #include "config.h"
index f4be080..8abbf01 100644 (file)
@@ -7,6 +7,9 @@
  * files. Useful when you write a file that you want to be
  * able to verify hasn't been messed with afterwards.
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "progress.h"
 #include "csum-file.h"
index 89d51b7..ffe1ca2 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "object.h"
 #include "commit.h"
index 4d096c8..cc2d535 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "diagnose.h"
 #include "compat/disk.h"
index 3fb8d79..b0d0f71 100644 (file)
@@ -1,6 +1,9 @@
 /*
  * Copyright (C) 2005 Junio C Hamano
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/diff.c b/diff.c
index 60d1f7b..d4579d5 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1,6 +1,9 @@
 /*
  * Copyright (C) 2005 Junio C Hamano
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "base85.h"
index 49ba38a..831b66b 100644 (file)
@@ -1,6 +1,9 @@
 /*
  * Copyright (C) 2005 Junio C Hamano
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "diffcore.h"
 #include "hash.h"
index 5abb958..ae50400 100644 (file)
@@ -2,6 +2,9 @@
  *
  * Copyright (C) 2005 Junio C Hamano
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "diff.h"
 #include "diffcore.h"
diff --git a/dir.c b/dir.c
index 5de421c..b7a6625 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -5,6 +5,9 @@
  * Copyright (C) Linus Torvalds, 2005-2006
  *              Junio Hamano, 2005-2006
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
diff --git a/entry.c b/entry.c
index b8c257f..fe1f74d 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "object-store-ll.h"
 #include "dir.h"
index 701d515..5cea2c9 100644 (file)
@@ -7,6 +7,9 @@
  * even if you might want to know where the git directory etc
  * are.
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "branch.h"
index eba9e42..e6e14b3 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "repository.h"
 #include "config.h"
index 7d144b8..b8bca89 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
diff --git a/fsck.c b/fsck.c
index dd0a330..432996c 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "date.h"
 #include "dir.h"
index 45471b5..f1b1631 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "simple-ipc.h"
diff --git a/git.c b/git.c
index 683bb69..e35af9b 100644 (file)
--- a/git.c
+++ b/git.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "builtin.h"
 #include "config.h"
 #include "environment.h"
index 9aa6b82..5f808ca 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "hash.h"
 #include "hash-lookup.h"
diff --git a/hash.h b/hash.h
index 39a0164..cb85d26 100644 (file)
--- a/hash.h
+++ b/hash.h
@@ -4,6 +4,8 @@
 #include "hash-ll.h"
 #include "repository.h"
 
-#define the_hash_algo the_repository->hash_algo
+#ifdef USE_THE_REPOSITORY_VARIABLE
+# define the_hash_algo the_repository->hash_algo
+#endif
 
 #endif
diff --git a/help.c b/help.c
index 1d057aa..10fdb1a 100644 (file)
--- a/help.c
+++ b/help.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "builtin.h"
diff --git a/hex.c b/hex.c
index bc9e86a..5ca78a7 100644 (file)
--- a/hex.c
+++ b/hex.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "hash.h"
 #include "hex.h"
index 5b65287..7c0b3be 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
index a97df4a..7315a69 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
index b7110b6..e417a7f 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "repository.h"
 #include "hex.h"
diff --git a/http.c b/http.c
index 67cc47d..6536816 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "git-curl-compat.h"
 #include "hex.h"
index c5f363c..0061110 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "gettext.h"
index 4346f8d..49e2fa6 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "dir.h"
 #include "gettext.h"
index 11ad8be..985d008 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "tag.h"
 #include "commit.h"
index 41416de..223a4d9 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "commit-reach.h"
 #include "config.h"
diff --git a/loose.c b/loose.c
index f6faa62..a8bf772 100644 (file)
--- a/loose.c
+++ b/loose.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "hash.h"
 #include "path.h"
index 398afe4..2dd925b 100644 (file)
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
index b2efe29..534a3eb 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "string-list.h"
index 50c42e2..f17c74d 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "hex.h"
 #include "match-trees.h"
index 2f659fd..0ad0390 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "merge-ll.h"
 #include "blob.h"
index eaede6c..691db90 100644 (file)
@@ -14,6 +14,8 @@
  * "cale", "peedy", or "ins" instead of "ort"?)
  */
 
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "merge-ort.h"
 
index 8ff29ed..46ee364 100644 (file)
@@ -3,6 +3,9 @@
  * Fredrik Kuivinen.
  * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "merge-recursive.h"
 
diff --git a/merge.c b/merge.c
index 752a937..fe3efa4 100644 (file)
--- a/merge.c
+++ b/merge.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hash.h"
index 55a6b63..9a194e8 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
diff --git a/midx.c b/midx.c
index 1e75f1a..3992b05 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "dir.h"
index 518b3c4..e3fa5c3 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "default.h"
 #include "../commit.h"
index b7e008c..f109928 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "skipping.h"
 #include "../commit.h"
index 038db01..ecfdf6e 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "notes-cache.h"
 #include "object-store-ll.h"
index 801941c..d95e683 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "advice.h"
 #include "commit.h"
index e33aa86..bca7127 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "commit.h"
diff --git a/notes.c b/notes.c
index afe2e28..b6a13d0 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
index f684038..958f61f 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "strbuf.h"
index 72318c8..a6555ed 100644 (file)
@@ -6,6 +6,9 @@
  * This handles basic git object files - packing, unpacking,
  * creation etc.
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
index 523af6f..d750951 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "object-name.h"
 #include "advice.h"
index 93b5d97..0c0fcb7 100644 (file)
--- a/object.c
+++ b/object.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
index 1f36651..9cac974 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "oid-array.h"
 #include "hash-lookup.h"
index 75e668a..951c9c0 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "commit-graph.h"
 #include "repository.h"
index 59d2e3a..37a8ad0 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
index 184d28f..7eafdce 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "commit.h"
 #include "gettext.h"
index e7b214f..e883dae 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
index fc63aa7..de922b4 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-revindex.h"
index eef625f..d07f03d 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
index ec7312c..8135846 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
index d99d688..3fb7ce6 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "parse-options.h"
 #include "branch.h"
diff --git a/path.c b/path.c
index adfb3d3..19f7684 100644 (file)
--- a/path.c
+++ b/path.c
@@ -1,6 +1,9 @@
 /*
  * Utilities for paths and pathnames
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "environment.h"
index 2133b9f..fe1f0f4 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "parse.h"
index 22a8150..2c14a88 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "commit.h"
index c83cb60..0d44c18 100644 (file)
@@ -9,6 +9,8 @@
  */
 
 #define GIT_TEST_PROGRESS_ONLY
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "pager.h"
 #include "progress.h"
index 2ca7c2a..317e1b1 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
index c45b6d8..5f01605 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
index 1224b30..46613a6 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
index 085b22f..48bf24f 100644 (file)
@@ -3,6 +3,9 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "bulk-checkin.h"
 #include "config.h"
index c343e16..e93b385 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "commit.h"
 #include "editor.h"
index f7fb0c7..8c5e673 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
index 5f09552..c7070b1 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "commit.h"
 #include "refs.h"
index 3c80950..5ca9445 100644 (file)
--- a/reflog.c
+++ b/reflog.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "object-store-ll.h"
diff --git a/refs.c b/refs.c
index 6e7caef..727ed6c 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -2,6 +2,8 @@
  * The backend-independent part of the reference module.
  */
 
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "advice.h"
 #include "config.h"
index b484b58..35931bc 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "../git-compat-util.h"
 #include "../copy.h"
 #include "../environment.h"
index 5ab1b21..a066640 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "../git-compat-util.h"
 #include "../config.h"
 #include "../dir.h"
index 57df2ab..6e34eb2 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "../git-compat-util.h"
 #include "../abspath.h"
 #include "../chdir-notify.h"
index d60932f..c2e3e24 100644 (file)
--- a/refspec.c
+++ b/refspec.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hash.h"
index 6008d7e..1930f83 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "git-curl-compat.h"
 #include "config.h"
index 1064171..5fab7f0 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
index 95d10cc..9825a30 100644 (file)
 #include "promisor-remote.h"
 #include "refs.h"
 
+/*
+ * We do not define `USE_THE_REPOSITORY_VARIABLE` in this file because we do
+ * not want to rely on functions that implicitly use `the_repository`. This
+ * means that the `extern` declaration of `the_repository` isn't visible here,
+ * which makes sparse unhappy. We thus declare it here.
+ */
+extern struct repository *the_repository;
+
 /* The main repository */
 static struct repository the_repo;
 struct repository *the_repository = &the_repo;
index a35cd77..29727ed 100644 (file)
@@ -197,7 +197,9 @@ struct repository {
        unsigned different_commondir:1;
 };
 
+#ifdef USE_THE_REPOSITORY_VARIABLE
 extern struct repository *the_repository;
+#endif
 
 /*
  * Define a custom repository layout. Any field can be NULL, which
index c7e1f8f..597256f 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
diff --git a/reset.c b/reset.c
index 937f11c..9550dea 100644 (file)
--- a/reset.c
+++ b/reset.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "cache-tree.h"
 #include "gettext.h"
index 4e6f0e4..8c9911a 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "dir.h"
 #include "hash.h"
index 7ddf0f1..40da255 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
index 31b2012..f5fde92 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "run-command.h"
 #include "environment.h"
index 331b91d..a1cb4b4 100644 (file)
--- a/scalar.c
+++ b/scalar.c
@@ -2,6 +2,8 @@
  * The Scalar command-line interface.
  */
 
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "gettext.h"
index 37f59d4..b42e698 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "commit.h"
index 823691e..8083fe2 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
diff --git a/serve.c b/serve.c
index aa651b7..33608ea 100644 (file)
--- a/serve.c
+++ b/serve.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "repository.h"
 #include "config.h"
index 6feaa45..97e839c 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "dir.h"
 #include "environment.h"
diff --git a/setup.c b/setup.c
index 20f3808..7e1169e 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "copy.h"
index a0b181b..31a6ca4 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "hex.h"
 #include "repository.h"
index 058a8f4..120c819 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hash.h"
index 10adf62..3883951 100644 (file)
@@ -1,6 +1,9 @@
 /*
  * Copyright (c) 2011, Google Inc.
  */
+
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "convert.h"
 #include "environment.h"
index ad43a28..9b0bb0b 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "dir.h"
 #include "environment.h"
index caf3aa5..ab99a30 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "repository.h"
index af43ee1..1f18d57 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "git-compat-util.h"
 #include "pack-bitmap.h"
index 1281e66..f7f9b62 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "bloom.h"
 #include "hex.h"
index dc89ecf..5cdef3e 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "gettext.h"
 #include "hex.h"
index 02b0b46..3f0c7d0 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "hash.h"
 #include "hex.h"
index 4f215fe..1b7f37a 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "read-cache-ll.h"
 #include "repository.h"
index f472691..a6720fa 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "hex.h"
 #include "read-cache-ll.h"
index 9ff67c3..4f010d5 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "dir.h"
 #include "hex.h"
index e8bd793..14b2b0c 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "object-name.h"
 #include "object-store.h"
index 8280984..02bfe92 100644 (file)
@@ -3,6 +3,8 @@
  * a `git fsmonitor--daemon` daemon.
  */
 
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "parse-options.h"
 #include "fsmonitor-ipc.h"
index 5f33bb7..40f5df4 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "environment.h"
 #include "name-hash.h"
index d0db5ff..e0e2048 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "hex.h"
 #include "match-trees.h"
index bd30244..c03cfa5 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "hex.h"
 #include "object-name.h"
index 67a964e..f8f9afb 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "hex.h"
 #include "strbuf.h"
index 1ba226f..5dd3743 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "commit.h"
 #include "commit-reach.h"
index e803c43..d285c65 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "config.h"
 #include "read-cache-ll.h"
index 8c7a83f..d9e980d 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "commit-graph.h"
 #include "repository.h"
index 4acae41..83effc2 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "hex.h"
 #include "midx.h"
index ad24300..637b8b2 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "hex.h"
 #include "refs.h"
index 0c7c5aa..c6a074d 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "commit-graph.h"
 #include "commit.h"
index f346951..071f5bd 100644 (file)
@@ -8,6 +8,8 @@
  * published by the Free Software Foundation.
  */
 
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "commit.h"
 #include "diff.h"
index 737cbe4..64fff6e 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "lockfile.h"
 #include "read-cache-ll.h"
index 4b809d9..cbe93f2 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "config.h"
 #include "hash.h"
index ecd40de..6ca069c 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "repository.h"
 #include "setup.h"
index 7197969..22e518d 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "test-tool-utils.h"
 #include "parse-options.h"
index 1adac29..cd955ec 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "strvec.h"
 #include "run-command.h"
index 7e3da38..b37dd2c 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-tool.h"
 #include "lockfile.h"
 #include "read-cache-ll.h"
index 3c856a8..a4a75db 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "test-lib.h"
 #include "object.h"
 #include "decorate.h"
diff --git a/tag.c b/tag.c
index 52bbe50..d24170e 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "environment.h"
 #include "tag.h"
index 3509258..a8e4553 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "tmp-objdir.h"
 #include "abspath.h"
index 9820947..09b3560 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "transport.h"
 #include "quote.h"
index 83ddea8..b9c8827 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "advice.h"
 #include "config.h"
index 535a3a2..a033397 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "tree-walk.h"
 #include "dir.h"
diff --git a/tree.c b/tree.c
index 7973d3f..ad86ad1 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "hex.h"
 #include "tree.h"
index 304ea2e..7dc884f 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "advice.h"
 #include "strvec.h"
index b726f7a..0052c6a 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
index 946d86b..0fafdc9 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
index 70844d0..f3c4c8e 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "environment.h"
index 5051f5e..8815df4 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "advice.h"
 #include "wt-status.h"
index 16ed8ac..d5dc886 100644 (file)
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "config.h"