Skip to content

Commit 3e8b7d3

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3e98919 commit 3e8b7d3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sha1_file.c

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

3323+
if (!startup_info->have_repository)
3324+
return 0;
33233325
if (find_pack_entry(sha1, &e))
33243326
return 1;
33253327
if (has_loose_object(sha1))

0 commit comments

Comments
 (0)