1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 21:07:52 +01:00

has_sha1_file: don't bother if we are not in a repository

Most callers to this function already require that they are in a
git repository, but there is an exception: "git apply" uses
has_sha1_file to avoid work if the result of applying a binary
patch is already present in the repository. When run outside any
repository, this produces an error:

 fatal: BUG: setup_git_env called without repository

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jonathan Nieder 2017-04-11 15:47:13 -07:00 committed by Junio C Hamano
parent 3e98919a18
commit 3e8b7d3c77

View file

@ -3320,6 +3320,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))