Skip to content

Commit eb3af74

Browse files
committed
Merge branch 'jk/no-looking-at-dotgit-outside-repo'
Clean up fallouts from recent tightening of the set-up sequence, where Git barfs when repository information is accessed without first ensuring that it was started in a repository. * jk/no-looking-at-dotgit-outside-repo: test-read-cache: setup git dir has_sha1_file: don't bother if we are not in a repository
2 parents 5ab8f22 + bccb22c commit eb3af74

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

sha1_file.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3481,6 +3481,8 @@ int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
34813481
{
34823482
struct pack_entry e;
34833483

3484+
if (!startup_info->have_repository)
3485+
return 0;
34843486
if (find_pack_entry(sha1, &e))
34853487
return 1;
34863488
if (has_loose_object(sha1))

t/helper/test-read-cache.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ int cmd_main(int argc, const char **argv)
55
int i, cnt = 1;
66
if (argc == 2)
77
cnt = strtol(argv[1], NULL, 0);
8+
setup_git_directory();
89
for (i = 0; i < cnt; i++) {
910
read_cache();
1011
discard_cache();

0 commit comments

Comments
 (0)