git-branchless icon indicating copy to clipboard operation
git-branchless copied to clipboard

Unsupported extension name extensions.worktreeconfig

Open auscompgeek opened this issue 3 years ago • 6 comments

Description of the bug

Running git sparse-checkout set will cause all git-branchless commands to fail with Git error GenericError: unsupported extension name extensions.worktreeconfig in that repo.

cd /tmp
git init test
cd test
git commit --allow-empty -m 'Initial commit'
git sparse-checkout set
git branchless smartlog

Expected behavior

The smart log should show successfully, e.g.

◆ b1350a3f 12s (master) Initial commit

Actual behavior

The application panicked (crashed).
Message:  A fatal error occurred:
   0: Git error GenericError: unsupported extension name extensions.worktreeconfig

Location:
   src/git/repo.rs:45

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   0: branchless::git::repo::from_dir with path="/private/tmp/test"
      at src/git/repo.rs:193
   1: branchless::commands::smartlog::smartlog with effects=<Output fancy=true> git_run_info=<GitRunInfo path_to_git="git" working_directory="/private/tmp/test" env=not shown> options=SmartlogOptions { show_hidden_commits: false }
      at src/commands/smartlog.rs:526

Version of git-branchless

git-branchless 0.3.9

Version of git

git version 2.35.1

Version of rustc

No response

auscompgeek avatar Feb 21 '22 09:02 auscompgeek

I presume this is related to git config extensions.worktreeConfig but I had trouble simplifying the STR further. Notably from those docs:

Older Git versions will refuse to access repositories with this extension.

I'm guessing libgit2 doesn't handle this extension?

auscompgeek avatar Feb 21 '22 09:02 auscompgeek

I'm guessing libgit2 doesn't handle this extension?

Yes, I think this is libgit2/libgit2#6044. I suspect the fix is pretty simple, as someone there commented.

martinvonz avatar Feb 21 '22 15:02 martinvonz

Thanks for reporting. git-branchless should work fine with sparse checkouts (I use them at work), so most likely the only issue is with the extension.worktreeConfig setting. (If not, please update repro steps.) I'm guessing that we would need to make an upstream libgit2 change and percolate it down to git2 and then git-branchless.

The obvious workaround would be to disable extension.worktreeConfig, if that's possible for you. Unless this comes up at work, I don't have any plans to work on the upstream change, but if it ends up being done, I can fork the necessary crates and pull them into git-branchless before they're officially released.

arxanas avatar Feb 21 '22 19:02 arxanas

I was able to reproduce this in Git v2.35.0. However, it looks like this behavior, at least for the repro case, stops happening in Git v2.36.0 thanks to this commit: https://github.com/git/git/commit/7316dc5f6f2c8297d32e47d5859933ffacb6c00e. If upgrading Git is an option for you, you should try it to see if it solves your problem.

arxanas avatar Sep 14 '22 05:09 arxanas

Ah interesting. Unfortunately the repo I work on already has core.repositoryformatversion set to 1, and I presume downgrading that is unsafe. (I don't want to clone this repo again.)

auscompgeek avatar Sep 14 '22 11:09 auscompgeek

@auscompgeek you can also consider doing a shallow clone of the repo locally to get a "fresh" copy while hopefully not taking too long.

arxanas avatar Sep 14 '22 13:09 arxanas