Re: [PATCH v2 1/8] discover_git_directory(): avoid setting invalid git_dir

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

 



On Thu, Jun 08, 2017 at 09:53:32PM +0200, Johannes Schindelin wrote:

> When discovering a .git/ directory, we take pains to ensure that its
> repository format version matches Git's expectations, and we return NULL
> otherwise.
> 
> However, we still appended the invalid path to the strbuf passed as
> argument.
> 
> Let's just reset the strbuf to the state before we appended the .git/
> directory that was eventually rejected.
> 
> There is another early return path in that function, when
> setup_git_directory_gently_1() returns GIT_DIR_NONE or an error. In that
> case, the gitdir parameter has not been touched, therefore there is no
> need for an equivalent change in that code path.

After reading this, I thought at first this was a user-visible (albeit
obscure) bug where something like:

  git init
  git init bogus
  cd bogus
  git config core.repositoryformatversion 5

would mean that early-config barfs on seeing our bogus ".git", but that
screws up the discovery going back to the real repository root. But
that's not the case, because we always stop walking anyway when we see
such a bogus git dir.

So it's just a cleanup (though obviously a sensible one).

-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]