summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2018-03-23 17:21:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-03-26 17:05:55 (GMT)
commitd2607fa053441827446b57c17a3605840d638f15 (patch)
tree306abe889e40559e65e313757515338955e26406 /sha1_file.c
parenta68377b5dedbe7e5230901577eac9b9a00cb26b4 (diff)
downloadgit-d2607fa053441827446b57c17a3605840d638f15.zip
git-d2607fa053441827446b57c17a3605840d638f15.tar.gz
git-d2607fa053441827446b57c17a3605840d638f15.tar.bz2
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>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sha1_file.c b/sha1_file.c
index aed9a55..fc4f209 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -867,23 +867,22 @@ int git_open_cloexec(const char *name, int flags)
* Note that it may point to static storage and is only valid until another
* call to sha1_file_name(), etc.
*/
-#define stat_sha1_file(r, s, st, p) stat_sha1_file_##r(s, st, p)
-static int stat_sha1_file_the_repository(const unsigned char *sha1,
- struct stat *st, const char **path)
+static int stat_sha1_file(struct repository *r, const unsigned char *sha1,
+ struct stat *st, const char **path)
{
struct alternate_object_database *alt;
static struct strbuf buf = STRBUF_INIT;
strbuf_reset(&buf);
- sha1_file_name(the_repository, &buf, sha1);
+ sha1_file_name(r, &buf, sha1);
*path = buf.buf;
if (!lstat(*path, st))
return 0;
- prepare_alt_odb(the_repository);
+ prepare_alt_odb(r);
errno = ENOENT;
- for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
+ for (alt = r->objects->alt_odb_list; alt; alt = alt->next) {
*path = alt_sha1_path(alt, sha1);
if (!lstat(*path, st))
return 0;