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
This commit is contained in:
Junio C Hamano 2017-04-19 21:37:20 -07:00
commit eb3af74e93
2 changed files with 3 additions and 0 deletions

View File

@ -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))

View File

@ -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();