Skip to content

Commit d2607fa

Browse files
stefanbellergitster
authored andcommitted
sha1_file: allow stat_sha1_file to handle arbitrary repositories
Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a68377b commit d2607fa

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

sha1_file.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -867,23 +867,22 @@ int git_open_cloexec(const char *name, int flags)
867867
* Note that it may point to static storage and is only valid until another
868868
* call to sha1_file_name(), etc.
869869
*/
870-
#define stat_sha1_file(r, s, st, p) stat_sha1_file_##r(s, st, p)
871-
static int stat_sha1_file_the_repository(const unsigned char *sha1,
872-
struct stat *st, const char **path)
870+
static int stat_sha1_file(struct repository *r, const unsigned char *sha1,
871+
struct stat *st, const char **path)
873872
{
874873
struct alternate_object_database *alt;
875874
static struct strbuf buf = STRBUF_INIT;
876875

877876
strbuf_reset(&buf);
878-
sha1_file_name(the_repository, &buf, sha1);
877+
sha1_file_name(r, &buf, sha1);
879878
*path = buf.buf;
880879

881880
if (!lstat(*path, st))
882881
return 0;
883882

884-
prepare_alt_odb(the_repository);
883+
prepare_alt_odb(r);
885884
errno = ENOENT;
886-
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
885+
for (alt = r->objects->alt_odb_list; alt; alt = alt->next) {
887886
*path = alt_sha1_path(alt, sha1);
888887
if (!lstat(*path, st))
889888
return 0;

0 commit comments

Comments
 (0)