commit: prepare get_commit_buffer to handle any repo
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Nov 13, 2018 at 16:12 UTC
07de3fd84049c90d8d873599c43c3979f37166aa
3 files changed
+19
-4
commit.c
+5
-3
@@ -297,13 +297,15 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit *
297
return v->buffer;
298
}
299
300
-const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)
300
+const void *repo_get_commit_buffer(struct repository *r,
301
+ const struct commit *commit,
302
+ unsigned long *sizep)
303
{
302
- const void *ret = get_cached_commit_buffer(the_repository, commit, sizep);
304
+ const void *ret = get_cached_commit_buffer(r, commit, sizep);
305
if (!ret) {
306
enum object_type type;
307
unsigned long size;
306
- ret = read_object_file(&commit->object.oid, &type, &size);
308
+ ret = repo_read_object_file(r, &commit->object.oid, &type, &size);
309
if (!ret)
310
die("cannot read commit object %s",
311
oid_to_hex(&commit->object.oid));
commit.h
+6
-1
@@ -117,7 +117,12 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,
117
* from disk. The resulting memory should not be modified, and must be given
118
* to unuse_commit_buffer when the caller is done.
119
*/
120
-const void *get_commit_buffer(const struct commit *, unsigned long *size);
120
+const void *repo_get_commit_buffer(struct repository *r,
121
+ const struct commit *,
122
+ unsigned long *size);
123
+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
124
+#define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s)
125
+#endif
126
127
/*
128
* Tell the commit subsytem that we are done with a particular commit buffer.
contrib/coccinelle/the_repository.pending.cocci
+8
@@ -107,3 +107,11 @@ expression G;
107
- in_merge_bases_many(
108
+ repo_in_merge_bases_many(the_repository,
109
E, F, G);
110
+
111
+@@
112
+expression E;
113
+expression F;
114
+@@
115
+- get_commit_buffer(
116
++ repo_get_commit_buffer(the_repository,
117
+ E, F);