Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeing "BUG: refs.c:2083: reference backend is unknown" when attempting to clone #4843

Closed
1 task done
exoosh opened this issue Feb 29, 2024 · 6 comments
Closed
1 task done
Milestone

Comments

@exoosh
Copy link

exoosh commented Feb 29, 2024

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? -> Its 64-bit
$ git --version --build-options
git version 2.44.0.windows.1
cpu: x86_64
built from commit: ad0bbfffa543db6979717be96df630d3e5741331
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
  • Windows 10 Pro, to be more precise 10.0.19045 Build 19045 (aka 22H2)
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.19045.4046]
(c) Microsoft Corporation. All rights reserved.
  • What options did you set as part of the installation? Or did you choose the
    defaults?
$ cat /etc/install-options.txt
Editor Option: VIM
Custom Editor Path:
Default Branch Option: main
Path Option: Cmd
Plink Path: C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe
SSH Option: Plink
Tortoise Option: true
CURL Option: OpenSSL
CRLF Option: CRLFCommitAsIs
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Enabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

None that I am aware of

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Bash within Windows Terminal

$ git -C test_helper clone https://github.com/bats-core/bats-core.git
Cloning into 'bats-core'...
BUG: refs.c:2083: reference backend is unknown
  • What did you expect to occur after running these commands?

I expected the clone to commence and succeed (the directory test_helper existed!).

  • What actually happened instead?

It aborted with the message:

BUG: refs.c:2083: reference backend is unknown
  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

https://github.com/bats-core/bats-core.git

@exoosh
Copy link
Author

exoosh commented Feb 29, 2024

It should be noted that this works with the 2.43.0.windows.1 version of Git for Windows! I just downgraded back to it.

Z:\temp$ git -C test_helper clone https://github.com/bats-core/bats-core.git
Cloning into 'bats-core'...
remote: Enumerating objects: 9764, done.
remote: Counting objects: 100% (2750/2750), done.
remote: Compressing objects: 100% (321/321), done.
remote: Total 9764 (delta 2561), reused 2535 (delta 2415), pack-reused 7014
Receiving objects: 100% (9764/9764), 2.34 MiB | 7.23 MiB/s, done.
Resolving deltas: 100% (6024/6024), done.
Z:\temp$ git --version
git version 2.43.0.windows.1

@assarbad
Copy link

assarbad commented Mar 29, 2024

This is definitely not limited to Git for Windows. I am seeing the exact same thing on Manjaro:

$ git clone https://github.com/kee-org/keepassrpc.git
Cloning into 'keepassrpc'...
BUG: refs.c:2083: reference backend is unknown
error: git-remote-https died of signal 6
$ git --version
git version 2.44.0

@dscho Clearly someone created an issue in version 2.44.0 of Git and it also appears in Git for Windows.

NB: cloning with SSH works. And repo seems to be irrelevant, as long as HTTPS is used:

$ git clone https://github.com/git/git.git
Cloning into 'git'...
BUG: refs.c:2083: reference backend is unknown
error: git-remote-https died of signal 6

@assarbad
Copy link

assarbad commented Mar 30, 2024

@dscho
Copy link
Member

dscho commented Apr 8, 2024

@assarbad would you be so kind as to provide a backport PR?

@exoosh
Copy link
Author

exoosh commented Apr 12, 2024

@assarbad would you be so kind as to provide a backport PR?

Will do (same person, company account)

dscho added a commit that referenced this issue Apr 12, 2024
In 18c9cb7 (builtin/clone: create the refdb with the correct object
format, 2023-12-12), we have changed git-clone(1) so that it delays
creation of the refdb until after it has learned about the remote's
object format. This change was required for the reftable backend, which
encodes the object format into the tables. So if we pre-initialized the
refdb with the default object format, but the remote uses a different
object format than that, then the resulting tables would have encoded
the wrong object format.

This change unfortunately breaks remote helpers which try to access the
repository that is about to be created. Because the refdb has not yet
been initialized at the point where we spawn the remote helper, we also
don't yet have "HEAD" or "refs/". Consequently, any Git commands ran by
the remote helper which try to access the repository would fail because
it cannot be discovered.

This is essentially a chicken-and-egg problem: we cannot initialize the
refdb because we don't know about the object format. But we cannot learn
about the object format because the remote helper may be unable to
access the partially-initialized repository.

Ideally, we would address this issue via capabilities. But the remote
helper protocol is not structured in a way that guarantees that the
capability announcement happens before the remote helper tries to access
the repository.

Instead, fix this issue by partially initializing the refdb up to the
point where it becomes discoverable by Git commands.

-----

Cherry-picked the commit 199f44c to
provide the backport-PR requested by @dscho in #4843 ...

Commit message unchanged with the exception of the `Signed-off-by:`. The
contents of the commit are anyway unchanged. Hope this works for you.
@dscho
Copy link
Member

dscho commented Apr 12, 2024

/add relnote bug A regression where git clone no longer worked in the presence of includeIf.*.onbranch config settings has been fixed.

The workflow run was started

github-actions bot pushed a commit to git-for-windows/build-extra that referenced this issue Apr 12, 2024
A [regression](git-for-windows/git#4843) where
`git clone` no longer worked in the presence of `includeIf.*.onbranch`
config settings [has been
fixed](git-for-windows/git@199f44c).

Signed-off-by: gitforwindowshelper[bot] <gitforwindowshelper-bot@users.noreply.github.com>
@dscho dscho closed this as completed Apr 12, 2024
@dscho dscho added this to the Next release milestone Apr 12, 2024
dscho added a commit to microsoft/git that referenced this issue Apr 16, 2024
This is a backport of git-for-windows#4908
to address git-for-windows#4843 where
cloning no longer worked if the user has configured any
`includeIf.*.onbranch` settings in their gitconfig.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants