fix(git): detect and reject SHA-256 repositories with clear error message#4485
Open
octo-patch wants to merge 2 commits intoTabbyML:mainfrom
Open
fix(git): detect and reject SHA-256 repositories with clear error message#4485octo-patch wants to merge 2 commits intoTabbyML:mainfrom
octo-patch wants to merge 2 commits intoTabbyML:mainfrom
Conversation
Private repositories authenticated via URL (e.g. Bitbucket, GitLab subgroups) were silently losing their credentials before the git clone/pull command ran. `CodeRepository::sync()` was calling `self.canonical_git_url()` which strips the username and password, causing git to fail with "could not read Username ... No such device or address". - In `tabby-index`: pass `self.git_url` (original URL) to `sync_refs` instead of the credential-stripped `canonical_git_url()`. - In `tabby-git`: add `mask_url_credentials()` helper to safely redact credentials in log output, and call `git remote set-url` on existing clones so credential changes in config take effect without a full re-clone. Fixes TabbyML#4434, TabbyML#4431
…sage SHA-256 git repositories cannot be read by libgit2 (the git2 crate used internally). Previously, cloning a SHA-256 repo would succeed via the shell git command, but subsequent operations using libgit2 would fail silently with a cryptic 'unknown object format: sha256' error. This commit: - Adds an `is_sha256_repo()` helper that detects SHA-256 format repos by checking `git config extensions.objectformat` - In `sync_refs()`, checks for SHA-256 format after clone and for existing repos, bailing early with a clear, actionable error message - Also fixes a missing `url` workspace dependency in tabby-git's Cargo.toml (pre-existing issue introduced in the previous commit) - Improves the error message in `resolve_commits()` to distinguish SHA-256 errors from other git2 open failures Fixes TabbyML#4390 Co-Authored-By: Octopus <liyuan851277048@icloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4390
Problem
When a user adds a git repository that uses SHA-256 object format (e.g., a Gitea instance configured with SHA-256), Tabby would:
gitcommand (which supports SHA-256)git2crate) does not support SHA-256 repositoriesThe user would see a cryptic error like:
without any explanation of what this means or how to resolve it.
Solution
is_sha256_repo()helper function incrates/tabby-gitthat detects SHA-256 format by checkinggit config --local extensions.objectformatsync_refs(), check the object format after a successful clone and for existing repositories, bailing early with a clear, actionable error message explaining the limitationresolve_commits()to distinguish SHA-256 format errors from other libgit2 open failuresurlworkspace dependency intabby-git'sCargo.tomlThe user will now see a clear message:
Testing
The fix is tested by verifying that
cargo check -p tabby-gitpasses. The SHA-256 detection uses the samegit configcommand that git itself uses to determine object format, so it is reliable.