Add a repository argument to allow the callers of sha1_object_info
to be more specific about which repository to handle. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.
In the expanded macro the identifier `the_repository` is not actually used,
so the compiler does not catch if the repository.h header is not included
at the call site. call sites needing that #include were identified by
changing the macro to definition to
#define sha1_object_info(r, sha1, size) \
(r, sha1_object_info_##r(sha1, size)).
This produces a compiler warning about the left hand side of the comma
operator being unused, which can be suppressed using -Wno-unused-value.
To avoid breaking bisection, do not include this trick in the patch.
There is a large number of callers. The included coccinelle semantic patch
will adapt any new callers in the diff produced by `make coccicheck`.
Signed-off-by: Jonathan Nieder
Signed-off-by: Stefan Beller
---
archive-tar.c | 3 ++-
archive-zip.c | 4 +++-
blame.c | 5 +++--
builtin/cat-file.c| 6 +++---
builtin/fast-export.c | 3 ++-
builtin/fetch.c | 3 ++-
builtin/fsck.c| 3 ++-
builtin/index-pack.c | 7 +--
builtin/ls-tree.c | 3 ++-
builtin/mktree.c | 3 ++-
builtin/pack-objects.c| 9 ++---
builtin/prune.c | 3 ++-
builtin/replace.c | 12 +++-
builtin/tag.c | 5 +++--
builtin/unpack-objects.c | 4 +++-
contrib/coccinelle/sha1_object_info.cocci | 7 +++
diff.c| 4 +++-
fast-import.c | 16 +++-
list-objects-filter.c | 2 +-
object-store.h| 5 -
object.c | 2 +-
pack-bitmap-write.c | 4 +++-
packfile.c| 2 +-
reachable.c | 2 +-
refs.c| 2 +-
remote.c | 3 ++-
sequencer.c | 5 -
sha1_file.c | 4 ++--
sha1_name.c | 12 ++--
submodule.c | 2 +-
tag.c | 3 ++-
31 files changed, 97 insertions(+), 51 deletions(-)
create mode 100644 contrib/coccinelle/sha1_object_info.cocci
diff --git a/archive-tar.c b/archive-tar.c
index 909347c108..b10c9b8911 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -5,6 +5,7 @@
#include "config.h"
#include "tar.h"
#include "archive.h"
+#include "repository.h"
#include "object-store.h"
#include "streaming.h"
#include "run-command.h"
@@ -277,7 +278,7 @@ static int write_tar_entry(struct archiver_args *args,
memcpy(header.name, path, pathlen);
if (S_ISREG(mode) && !args->convert &&
- sha1_object_info(sha1, &size) == OBJ_BLOB &&
+ sha1_object_info(the_repository, sha1, &size) == OBJ_BLOB &&
size > big_file_threshold)
buffer = NULL;
else if (S_ISLNK(mode) || S_ISREG(mode)) {
diff --git a/archive-zip.c b/archive-zip.c
index 233fed3a61..03321b9777 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -6,6 +6,7 @@
#include "archive.h"
#include "streaming.h"
#include "utf8.h"
+#include "repository.h"
#include "object-store.h"
#include "userdiff.h"
#include "xdiff-interface.h"
@@ -326,7 +327,8 @@ static int write_zip_entry(struct archiver_args *args,
compressed_size = 0;
buffer = NULL;
} else if (S_ISREG(mode) || S_ISLNK(mode)) {
- enum object_type type = sha1_object_info(sha1, &size);
+ enum object_type type = sha1_object_info(the_repository, sha1,
+&size);
method = 0;
attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
diff --git a/blame.c b/blame.c
index 61f0f6bb40..f95a53898d 100644
--- a/blame.c
+++ b/blame.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "refs.h"
+#include "repository.h"
#include "object-store.h"
#include "cache-tree.h"
#include "mergesort.h"
@@ -82,7 +83,7 @@ static void verify_working_tree_path(struct commit
*work_tree, const char *path)
unsigned mode;
if (!get_tree_entry(commit_oid->hash, path, blob_oid.hash,
&mode) &&
- sha1_object_info(blob_oid.hash, NULL) == OBJ_B