+2
index a0961096cd..49042b3026 100644
--- a/add-interactive.c
+++ b/add-interactive.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "add-interactive.h"
#include "color.h"
+2
index 86181770f2..99e037c1e2 100644
--- a/add-patch.c
+++ b/add-patch.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "add-interactive.h"
#include "advice.h"
+2
index 528939abb6..ff939f908a 100644
--- a/apply.c
+++ b/apply.c
*
*/
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "base85.h"
+3
index 8ae30125f8..e7b3489e1e 100644
--- a/archive-tar.c
+++ b/archive-tar.c
/*
* Copyright (c) 2005, 2006 Rene Scharfe
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "gettext.h"
+3
index fd1d3f816d..9f32730181 100644
--- a/archive-zip.c
+++ b/archive-zip.c
/*
* Copyright (c) 2006 Rene Scharfe
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "archive.h"
+2
index 5287fcdd8e..7bd60d0632 100644
--- a/archive.c
+++ b/archive.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "config.h"
+2
index 300f994ba6..b5ed83c90e 100644
--- a/attr.c
+++ b/attr.c
* an insanely large number of attributes.
*/
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "environment.h"
+2
index 4ea703bec1..135f94ba09 100644
--- a/bisect.c
+++ b/bisect.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "commit.h"
+2
index a80f5e2e61..d403c46a35 100644
--- a/blame.c
+++ b/blame.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "refs.h"
#include "object-store-ll.h"
+2
index df5d24fec6..c887ea2151 100644
--- a/branch.c
+++ b/branch.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "advice.h"
#include "config.h"
+8
index 7eda9b2486..14fa017160 100644
--- a/builtin.h
+++ b/builtin.h
#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"
/*
+1
-1
index e09ff0155a..de89fff3f8 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
* See COPYING for licensing conditions
*/
-#include "git-compat-util.h"
+#include "builtin.h"
#include "config.h"
#include "color.h"
#include "builtin.h"
+1
-1
index ccbda8a005..00305bea51 100644
--- a/builtin/log.c
+++ b/builtin/log.c
* (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"
+3
index eb46b88637..da8673199b 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
/*
* Copyright (c) 2011, Google Inc.
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "bulk-checkin.h"
#include "environment.h"
+2
index 91b3319a5c..804fbcfbfa 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "bundle-uri.h"
#include "bundle.h"
+2
index 95367c2d0a..82c285b905 100644
--- a/bundle.c
+++ b/bundle.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "lockfile.h"
#include "bundle.h"
+2
index 3290a1b8dd..50610c3f3c 100644
--- a/cache-tree.c
+++ b/cache-tree.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "hex.h"
+2
index cfaea4bd10..0b1cf8b40b 100644
--- a/checkout.c
+++ b/checkout.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "object-name.h"
#include "remote.h"
+2
index cdc7f39b70..2dde24e6a3 100644
--- a/chunk-format.c
+++ b/chunk-format.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "chunk-format.h"
#include "csum-file.h"
+2
index 4960d904ac..829a44e416 100644
--- a/combine-diff.c
+++ b/combine-diff.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "object-store-ll.h"
#include "commit.h"
+2
index 98cbd53eea..e1070ee6e7 100644
--- a/commit-graph.c
+++ b/commit-graph.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "csum-file.h"
+2
index 384aee1ab3..dabc2972e4 100644
--- a/commit-reach.c
+++ b/commit-reach.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "commit.h"
#include "commit-graph.h"
+2
index 1d08951007..4956803e11 100644
--- a/commit.c
+++ b/commit.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "tag.h"
#include "commit.h"
+2
index b86f40600f..8e68ac9e42 100644
--- a/common-main.c
+++ b/common-main.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "exec-cmd.h"
#include "gettext.h"
compat/win32/trace2_win32_process_info.c
+2
index 3ef0936f6f..f147da706a 100644
--- a/compat/win32/trace2_win32_process_info.c
+++ b/compat/win32/trace2_win32_process_info.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "../../git-compat-util.h"
#include "../../json-writer.h"
#include "../../repository.h"
+3
index abce05b774..7951029644 100644
--- a/config.c
+++ b/config.c
* Copyright (C) Johannes Schindelin, 2005
*
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "advice.h"
+2
index 8f89376dbc..87cc4b57a1 100644
--- a/connected.c
+++ b/connected.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "hex.h"
+2
index f2b9f01354..d8737fe0f2 100644
--- a/convert.c
+++ b/convert.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "advice.h"
#include "config.h"
+3
index f4be0804b7..8abbf01325 100644
--- a/csum-file.c
+++ b/csum-file.c
* 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"
+2
index 89d51b72e3..ffe1ca2814 100644
--- a/delta-islands.c
+++ b/delta-islands.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "object.h"
#include "commit.h"
+2
index 4d096c857f..cc2d535b60 100644
--- a/diagnose.c
+++ b/diagnose.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "diagnose.h"
#include "compat/disk.h"
+3
index 3fb8d79fef..b0d0f711e8 100644
--- a/diff-lib.c
+++ b/diff-lib.c
/*
* Copyright (C) 2005 Junio C Hamano
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "commit.h"
#include "diff.h"
+3
index 60d1f7be81..d4579d5f76 100644
--- a/diff.c
+++ b/diff.c
/*
* Copyright (C) 2005 Junio C Hamano
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "base85.h"
+3
index 49ba38aa7c..831b66b5c3 100644
--- a/diffcore-break.c
+++ b/diffcore-break.c
/*
* Copyright (C) 2005 Junio C Hamano
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "diffcore.h"
#include "hash.h"
+3
index 5abb958651..ae504007cf 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
*
* Copyright (C) 2005 Junio C Hamano
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "diff.h"
#include "diffcore.h"
+3
index 5de421c29c..b7a6625ebd 100644
--- a/dir.c
+++ b/dir.c
* 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"
+2
index b8c257f6f9..fe1f74d140 100644
--- a/entry.c
+++ b/entry.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "object-store-ll.h"
#include "dir.h"
+3
index 701d515135..5cea2c9f54 100644
--- a/environment.c
+++ b/environment.c
* 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"
+2
index eba9e420ea..e6e14b3874 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "repository.h"
#include "config.h"
+2
index 7d144b803a..b8bca89c0c 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "environment.h"
+2
index dd0a33028e..432996cbb6 100644
--- a/fsck.c
+++ b/fsck.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "date.h"
#include "dir.h"
+2
index 45471b5b74..f1b1631111 100644
--- a/fsmonitor-ipc.c
+++ b/fsmonitor-ipc.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "simple-ipc.h"
+2
index 683bb69194..e35af9b0e5 100644
--- a/git.c
+++ b/git.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "environment.h"
+2
index 9aa6b82eb7..5f808caa51 100644
--- a/hash-lookup.c
+++ b/hash-lookup.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "hash.h"
#include "hash-lookup.h"
+3
-1
index 39a0164be3..cb85d26a2f 100644
--- a/hash.h
+++ b/hash.h
#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
+2
index 1d057aa607..10fdb1a03d 100644
--- a/help.c
+++ b/help.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "builtin.h"
+2
index bc9e86a978..5ca78a7744 100644
--- a/hex.c
+++ b/hex.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "hash.h"
#include "hex.h"
+2
index 5b65287ac9..7c0b3be968 100644
--- a/http-backend.c
+++ b/http-backend.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "environment.h"
+2
index a97df4a1fb..7315a694aa 100644
--- a/http-push.c
+++ b/http-push.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "hex.h"
+2
index b7110b6f82..e417a7f51c 100644
--- a/http-walker.c
+++ b/http-walker.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "repository.h"
#include "hex.h"
+2
index 67cc47d28f..6536816e81 100644
--- a/http.c
+++ b/http.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "git-curl-compat.h"
#include "hex.h"
list-objects-filter-options.c
+2
index c5f363ca6f..00611107d2 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "gettext.h"
+2
index 4346f8da45..49e2fa6f97 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "dir.h"
#include "gettext.h"
+2
index 11ad8be411..985d008799 100644
--- a/list-objects.c
+++ b/list-objects.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "tag.h"
#include "commit.h"
+2
index 41416de4e3..223a4d9463 100644
--- a/log-tree.c
+++ b/log-tree.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "commit-reach.h"
#include "config.h"
+2
index f6faa6216a..a8bf772172 100644
--- a/loose.c
+++ b/loose.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "hash.h"
#include "path.h"
+2
index 398afe4ce3..2dd925b43d 100644
--- a/ls-refs.c
+++ b/ls-refs.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "gettext.h"
+2
index b2efe29b3d..534a3eb4f0 100644
--- a/mailmap.c
+++ b/mailmap.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "string-list.h"
+2
index 50c42e2061..f17c74d483 100644
--- a/match-trees.c
+++ b/match-trees.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "hex.h"
#include "match-trees.h"
+2
index 2f659fd014..0ad0390fea 100644
--- a/merge-blobs.c
+++ b/merge-blobs.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "merge-ll.h"
#include "blob.h"
+2
index eaede6cead..691db9050e 100644
--- a/merge-ort.c
+++ b/merge-ort.c
* "cale", "peedy", or "ins" instead of "ort"?)
*/
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "merge-ort.h"
+3
index 8ff29ed09e..46ee364af7 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
* 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"
+2
index 752a937fa9..fe3efa4b24 100644
--- a/merge.c
+++ b/merge.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "hash.h"
+2
index 55a6b63bac..9a194e8aac 100644
--- a/midx-write.c
+++ b/midx-write.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "config.h"
+2
index 1e75f1a7eb..3992b05465 100644
--- a/midx.c
+++ b/midx.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "dir.h"
+2
index 518b3c43b2..e3fa5c3324 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "default.h"
#include "../commit.h"
+2
index b7e008c2fd..f109928ad0 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "skipping.h"
#include "../commit.h"
+2
index 038db01ca0..ecfdf6e43b 100644
--- a/notes-cache.c
+++ b/notes-cache.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "notes-cache.h"
#include "object-store-ll.h"
+2
index 801941c2d1..d95e683414 100644
--- a/notes-merge.c
+++ b/notes-merge.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "advice.h"
#include "commit.h"
+2
index e33aa86c4b..bca71274be 100644
--- a/notes-utils.c
+++ b/notes-utils.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "commit.h"
+2
index afe2e2882e..b6a13d0980 100644
--- a/notes.c
+++ b/notes.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "environment.h"
+2
index f684038f7f..958f61f094 100644
--- a/object-file-convert.c
+++ b/object-file-convert.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "strbuf.h"
+3
index 72318c8dd4..a6555ed68c 100644
--- a/object-file.c
+++ b/object-file.c
* 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"
+2
index 523af6f64f..d7509514bc 100644
--- a/object-name.c
+++ b/object-name.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "object-name.h"
#include "advice.h"
+2
index 93b5d97fdb..0c0fcb76c0 100644
--- a/object.c
+++ b/object.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "hex.h"
+2
index 1f36651754..9cac974395 100644
--- a/oid-array.c
+++ b/oid-array.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "oid-array.h"
#include "hash-lookup.h"
oss-fuzz/fuzz-commit-graph.c
+2
index 75e668a057..951c9c082f 100644
--- a/oss-fuzz/fuzz-commit-graph.c
+++ b/oss-fuzz/fuzz-commit-graph.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "commit-graph.h"
#include "repository.h"
+2
index 59d2e3a387..37a8ad0fb3 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "gettext.h"
+2
index 184d28f05c..7eafdce4ee 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "commit.h"
#include "gettext.h"
+2
index e7b214fcbd..e883dae3f2 100644
--- a/pack-check.c
+++ b/pack-check.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "hex.h"
+2
index fc63aa76a2..de922b47d2 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "pack-revindex.h"
+2
index eef625fa5b..d07f03d0ab 100644
--- a/pack-write.c
+++ b/pack-write.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "gettext.h"
+2
index ec7312cd20..813584646f 100644
--- a/packfile.c
+++ b/packfile.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "gettext.h"
+2
index d99d688d3c..3fb7ce68ca 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "parse-options.h"
#include "branch.h"
+3
index adfb3d3eb7..19f7684f38 100644
--- a/path.c
+++ b/path.c
/*
* Utilities for paths and pathnames
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "environment.h"
+2
index 2133b9fe60..fe1f0f41af 100644
--- a/pathspec.c
+++ b/pathspec.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "parse.h"
+2
index 22a81506b7..2c14a88abc 100644
--- a/pretty.c
+++ b/pretty.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "commit.h"
+2
index c83cb60bf1..0d44c18edc 100644
--- a/progress.c
+++ b/progress.c
*/
#define GIT_TEST_PROGRESS_ONLY
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "pager.h"
#include "progress.h"
+2
index 2ca7c2ae48..317e1b127f 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "hex.h"
+2
index c45b6d849c..5f01605550 100644
--- a/range-diff.c
+++ b/range-diff.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "gettext.h"
+2
index 1224b30008..46613a6bb6 100644
--- a/reachable.c
+++ b/reachable.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "hex.h"
+3
index 085b22faf3..48bf24f87c 100644
--- a/read-cache.c
+++ b/read-cache.c
*
* Copyright (C) Linus Torvalds, 2005
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "bulk-checkin.h"
#include "config.h"
+2
index c343e16fcd..e93b385523 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "commit.h"
#include "editor.h"
+2
index f7fb0c7e0e..8c5e673fc0 100644
--- a/ref-filter.c
+++ b/ref-filter.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "gettext.h"
+2
index 5f09552c5c..c7070b13b0 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "commit.h"
#include "refs.h"
+2
index 3c80950186..5ca944529b 100644
--- a/reflog.c
+++ b/reflog.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "object-store-ll.h"
+2
index 6e7caefdcf..727ed6c1d6 100644
--- a/refs.c
+++ b/refs.c
* The backend-independent part of the reference module.
*/
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "advice.h"
#include "config.h"
+2
index b484b5880d..35931bc71e 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "../git-compat-util.h"
#include "../copy.h"
#include "../environment.h"
+2
index 5ab1b21d10..a0666407cd 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "../git-compat-util.h"
#include "../config.h"
#include "../dir.h"
+2
index 57df2aba66..6e34eb2188 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "../git-compat-util.h"
#include "../abspath.h"
#include "../chdir-notify.h"
+2
index d60932f4de..c2e3e24351 100644
--- a/refspec.c
+++ b/refspec.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "hash.h"
+2
index 6008d7e87c..1930f83cc7 100644
--- a/remote-curl.c
+++ b/remote-curl.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "git-curl-compat.h"
#include "config.h"
+2
index 1064171085..5fab7f0970 100644
--- a/remote.c
+++ b/remote.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "config.h"
+8
index 95d10cc4a0..9825a30899 100644
--- a/repository.c
+++ b/repository.c
#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;
+2
index a35cd77c35..29727edec6 100644
--- a/repository.h
+++ b/repository.h
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
+2
index c7e1f8fd25..597256fa5b 100644
--- a/rerere.c
+++ b/rerere.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "config.h"
+2
index 937f11c0f4..9550dea03d 100644
--- a/reset.c
+++ b/reset.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "cache-tree.h"
#include "gettext.h"
+2
index 4e6f0e4676..8c9911affb 100644
--- a/resolve-undo.c
+++ b/resolve-undo.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "dir.h"
#include "hash.h"
+2
index 7ddf0f151a..40da255953 100644
--- a/revision.c
+++ b/revision.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "environment.h"
+2
index 31b20123d8..f5fde92b7c 100644
--- a/run-command.c
+++ b/run-command.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "run-command.h"
#include "environment.h"
+2
index 331b91dbdb..a1cb4b45b5 100644
--- a/scalar.c
+++ b/scalar.c
* The Scalar command-line interface.
*/
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "gettext.h"
+2
index 37f59d4f66..b42e6986df 100644
--- a/send-pack.c
+++ b/send-pack.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "commit.h"
+2
index 823691e379..8083fe20bf 100644
--- a/sequencer.c
+++ b/sequencer.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "advice.h"
+2
index aa651b73e9..33608ea4d5 100644
--- a/serve.c
+++ b/serve.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "repository.h"
#include "config.h"
+2
index 6feaa457c5..97e839c33d 100644
--- a/server-info.c
+++ b/server-info.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "dir.h"
#include "environment.h"
+2
index 20f380825b..7e1169eb86 100644
--- a/setup.c
+++ b/setup.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "copy.h"
+2
index a0b181ba8a..31a6ca40fe 100644
--- a/shallow.c
+++ b/shallow.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "hex.h"
#include "repository.h"
+2
index 058a8f448e..120c8190b1 100644
--- a/split-index.c
+++ b/split-index.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "hash.h"
+3
index 10adf625b2..38839511af 100644
--- a/streaming.c
+++ b/streaming.c
/*
* Copyright (c) 2011, Google Inc.
*/
+
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "convert.h"
#include "environment.h"
+2
index ad43a282da..9b0bb0b9f4 100644
--- a/submodule-config.c
+++ b/submodule-config.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "dir.h"
#include "environment.h"
+2
index caf3aa5600..ab99a30253 100644
--- a/submodule.c
+++ b/submodule.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "repository.h"
+2
index af43ee1cb5..1f18d57007 100644
--- a/t/helper/test-bitmap.c
+++ b/t/helper/test-bitmap.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "git-compat-util.h"
#include "pack-bitmap.h"
+2
index 1281e66876..f7f9b62002 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "bloom.h"
#include "hex.h"
t/helper/test-cache-tree.c
+2
index dc89ecfd71..5cdef3ebef 100644
--- a/t/helper/test-cache-tree.c
+++ b/t/helper/test-cache-tree.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "gettext.h"
#include "hex.h"
t/helper/test-dump-cache-tree.c
+2
index 02b0b46c3f..3f0c7d0ed0 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "hash.h"
#include "hex.h"
t/helper/test-dump-fsmonitor.c
+2
index 4f215fea02..1b7f37a84f 100644
--- a/t/helper/test-dump-fsmonitor.c
+++ b/t/helper/test-dump-fsmonitor.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "read-cache-ll.h"
#include "repository.h"
t/helper/test-dump-split-index.c
+2
index f472691a3c..a6720faf9c 100644
--- a/t/helper/test-dump-split-index.c
+++ b/t/helper/test-dump-split-index.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "hex.h"
#include "read-cache-ll.h"
t/helper/test-dump-untracked-cache.c
+2
index 9ff67c3967..4f010d5324 100644
--- a/t/helper/test-dump-untracked-cache.c
+++ b/t/helper/test-dump-untracked-cache.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "dir.h"
#include "hex.h"
t/helper/test-find-pack.c
+2
index e8bd793e58..14b2b0c12c 100644
--- a/t/helper/test-find-pack.c
+++ b/t/helper/test-find-pack.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "object-name.h"
#include "object-store.h"
t/helper/test-fsmonitor-client.c
+2
index 8280984d08..02bfe92e8d 100644
--- a/t/helper/test-fsmonitor-client.c
+++ b/t/helper/test-fsmonitor-client.c
* a `git fsmonitor--daemon` daemon.
*/
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "parse-options.h"
#include "fsmonitor-ipc.h"
t/helper/test-lazy-init-name-hash.c
+2
index 5f33bb7b8f..40f5df4412 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "environment.h"
#include "name-hash.h"
t/helper/test-match-trees.c
+2
index d0db5ff26f..e0e2048320 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "hex.h"
#include "match-trees.h"
+2
index bd30244a54..c03cfa5ecf 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "hex.h"
#include "object-name.h"
t/helper/test-pack-mtimes.c
+2
index 67a964ef90..f8f9afbb5b 100644
--- a/t/helper/test-pack-mtimes.c
+++ b/t/helper/test-pack-mtimes.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "hex.h"
#include "strbuf.h"
+2
index 1ba226f1f9..5dd374379c 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "commit.h"
#include "commit-reach.h"
t/helper/test-read-cache.c
+2
index e803c43ece..d285c656bd 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "config.h"
#include "read-cache-ll.h"
t/helper/test-read-graph.c
+2
index 8c7a83f578..d9e980d04c 100644
--- a/t/helper/test-read-graph.c
+++ b/t/helper/test-read-graph.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "commit-graph.h"
#include "repository.h"
t/helper/test-read-midx.c
+2
index 4acae41bb9..83effc2b5f 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "hex.h"
#include "midx.h"
t/helper/test-ref-store.c
+2
index ad24300170..637b8b294e 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "hex.h"
#include "refs.h"
t/helper/test-repository.c
+2
index 0c7c5aa4dd..c6a074df3d 100644
--- a/t/helper/test-repository.c
+++ b/t/helper/test-repository.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "commit-graph.h"
#include "commit.h"
t/helper/test-revision-walking.c
+2
index f346951bc2..071f5bd1e2 100644
--- a/t/helper/test-revision-walking.c
+++ b/t/helper/test-revision-walking.c
* published by the Free Software Foundation.
*/
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "commit.h"
#include "diff.h"
t/helper/test-scrap-cache-tree.c
+2
index 737cbe475b..64fff6e9e3 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "lockfile.h"
#include "read-cache-ll.h"
t/helper/test-submodule-config.c
+2
index 4b809d9dca..cbe93f2f9e 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "config.h"
#include "hash.h"
t/helper/test-submodule-nested-repo-config.c
+2
index ecd40ded99..6ca069ce63 100644
--- a/t/helper/test-submodule-nested-repo-config.c
+++ b/t/helper/test-submodule-nested-repo-config.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "repository.h"
#include "setup.h"
t/helper/test-submodule.c
+2
index 7197969a08..22e518d229 100644
--- a/t/helper/test-submodule.c
+++ b/t/helper/test-submodule.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "test-tool-utils.h"
#include "parse-options.h"
+2
index 1adac29a57..cd955ec63e 100644
--- a/t/helper/test-trace2.c
+++ b/t/helper/test-trace2.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "strvec.h"
#include "run-command.h"
t/helper/test-write-cache.c
+2
index 7e3da380a9..b37dd2c5d6 100644
--- a/t/helper/test-write-cache.c
+++ b/t/helper/test-write-cache.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-tool.h"
#include "lockfile.h"
#include "read-cache-ll.h"
t/unit-tests/t-example-decorate.c
+2
index 3c856a8cf2..a4a75db735 100644
--- a/t/unit-tests/t-example-decorate.c
+++ b/t/unit-tests/t-example-decorate.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "test-lib.h"
#include "object.h"
#include "decorate.h"
+2
index 52bbe50819..d24170e340 100644
--- a/tag.c
+++ b/tag.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "environment.h"
#include "tag.h"
+2
index 3509258be5..a8e4553f27 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "tmp-objdir.h"
#include "abspath.h"
+2
index 9820947ab2..09b3560ffd 100644
--- a/transport-helper.c
+++ b/transport-helper.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "transport.h"
#include "quote.h"
+2
index 83ddea8fbc..b9c8827ed9 100644
--- a/transport.c
+++ b/transport.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "advice.h"
#include "config.h"
+2
index 535a3a2539..a033397965 100644
--- a/tree-walk.c
+++ b/tree-walk.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "tree-walk.h"
#include "dir.h"
+2
index 7973d3f9a8..ad86ad1ba9 100644
--- a/tree.c
+++ b/tree.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "hex.h"
#include "tree.h"
+2
index 304ea2ed86..7dc884fafd 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "advice.h"
#include "strvec.h"
+2
index b726f7a57d..0052c6a4dc 100644
--- a/upload-pack.c
+++ b/upload-pack.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
#include "environment.h"
+2
index 946d86b04e..0fafdc97cf 100644
--- a/walker.c
+++ b/walker.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "hex.h"
+2
index 70844d023a..f3c4c8ec54 100644
--- a/worktree.c
+++ b/worktree.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "abspath.h"
#include "environment.h"
+2
index 5051f5e599..8815df419e 100644
--- a/wt-status.c
+++ b/wt-status.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "advice.h"
#include "wt-status.h"
+2
index 16ed8ac492..d5dc88661e 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "gettext.h"
#include "config.h"