summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sha1_file.c2
-rw-r--r--t/helper/test-read-cache.c1
2 files changed, 3 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 2270f36a2b..1577e2d7dd 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -3481,6 +3481,8 @@ int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
{
struct pack_entry e;
+ if (!startup_info->have_repository)
+ return 0;
if (find_pack_entry(sha1, &e))
return 1;
if (has_loose_object(sha1))
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index 2a7990efc3..48255eef31 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -5,6 +5,7 @@ int cmd_main(int argc, const char **argv)
int i, cnt = 1;
if (argc == 2)
cnt = strtol(argv[1], NULL, 0);
+ setup_git_directory();
for (i = 0; i < cnt; i++) {
read_cache();
discard_cache();