sha1_file: allow stat_sha1_file to handle arbitrary repositories
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Mar 23, 2018 at 18:21 UTC
d2607fa053441827446b57c17a3605840d638f15
1 file changed
+5
-6
sha1_file.c
+5
-6
@@ -867,23 +867,22 @@ int git_open_cloexec(const char *name, int flags)
867
* Note that it may point to static storage and is only valid until another
868
* call to sha1_file_name(), etc.
869
*/
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)
872
{
873
struct alternate_object_database *alt;
874
static struct strbuf buf = STRBUF_INIT;
875
876
strbuf_reset(&buf);
878
- sha1_file_name(the_repository, &buf, sha1);
877
+ sha1_file_name(r, &buf, sha1);
878
*path = buf.buf;
879
880
if (!lstat(*path, st))
881
return 0;
882
884
- prepare_alt_odb(the_repository);
883
+ prepare_alt_odb(r);
884
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) {
886
*path = alt_sha1_path(alt, sha1);
887
if (!lstat(*path, st))
888
return 0;