Re: What's cooking in git.git (Apr 2017, #01; Tue, 11)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 11, 2017 at 03:47:13PM -0700, Jonathan Nieder wrote:

> Junio C Hamano wrote:
> 
> > * jk/no-looking-at-dotgit-outside-repo-final (2016-10-26) 1 commit
> >   (merged to 'next' on 2017-02-27 at 7373a1b73d)
> >  + setup_git_env: avoid blind fall-back to ".git"
> >
> >  This is the endgame of the topic to avoid blindly falling back to
> >  ".git" when the setup sequence said we are _not_ in Git repository.
> >  A corner case that happens to work right now may be broken by a
> >  call to die("BUG").
> 
> There's one caller we missed, in "git apply" when you apply a binary
> patch outside any repository.

Good catch. This might also trigger with "apply --3way", but I didn't
check. Your patch would presumably fix that, too.

> diff --git a/sha1_file.c b/sha1_file.c
> index 71063890ff..bf1ff2ef77 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;

I added have_git_dir(), which catches some other cases (e.g., we have a
$GIT_DIR but just haven't entered the repo _yet_). TBH, I am not
entirely sure when it would be needed, and when checking have_repository
is enough. I added it to make some cases with early config-reading work,
but now that we have Dscho's discover-the-real-repo, I think it would
supersede that use anyway.

So...maybe you'd want it here and maybe not?

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]