Skip to content

Commit 07de3fd

Browse files
stefanbellergitster
authored andcommitted
commit: prepare get_commit_buffer to handle any repo
Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d5430f commit 07de3fd

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

commit.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,15 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit *
297297
return v->buffer;
298298
}
299299

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)
301303
{
302-
const void *ret = get_cached_commit_buffer(the_repository, commit, sizep);
304+
const void *ret = get_cached_commit_buffer(r, commit, sizep);
303305
if (!ret) {
304306
enum object_type type;
305307
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);
307309
if (!ret)
308310
die("cannot read commit object %s",
309311
oid_to_hex(&commit->object.oid));

commit.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,
117117
* from disk. The resulting memory should not be modified, and must be given
118118
* to unuse_commit_buffer when the caller is done.
119119
*/
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
121126

122127
/*
123128
* Tell the commit subsytem that we are done with a particular commit buffer.

contrib/coccinelle/the_repository.pending.cocci

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,11 @@ expression G;
107107
- in_merge_bases_many(
108108
+ repo_in_merge_bases_many(the_repository,
109109
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);

0 commit comments

Comments
 (0)