cli: error when git clone destination equals the source#9714
Open
petejm wants to merge 1 commit into
Open
Conversation
When `jj git clone <source>` is run without an explicit destination, the destination is inferred from the source. For a local source this can resolve to the same path as the source itself. With `--colocate` a valid empty `.git` is initialized at the destination before the fetch runs, so the fetch then reads from the empty repo jj just created and silently produces an empty clone instead of erroring. An explicit destination that resolves to the source (including through a symlink) hit the same trap. `absolute_git_url` now also returns the parsed `gix::Url`. The clone command normalizes both the source and the destination through it, so both sides are canonicalized identically (gix resolves symlinks and applies unix separators on Windows), then gates on a `file:` scheme and compares the parsed paths. This fixes an earlier asymmetry where the source was symlink-resolved but the destination was only logically normalized, letting a symlinked explicit destination defeat the guard. The error message now distinguishes the inferred-destination case from an explicit one. Fixes jj-vcs#6918 Assisted-by: Claude Code (Opus 4.8)
Author
|
CI is green except for one check: I don't have permission to re-run CI on this repo. Could a maintainer re-trigger that job when convenient? Happy to rebase/force-push instead if that's preferred. |
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 #6918.
jj git clone <source>without an explicit destination infers it from the source; for a local source that can resolve to the source's own path. With--colocate, an empty.gitis initialized at the destination before the fetch, so jj fetches from the repo it just created and silently produces an empty clone. An explicit destination resolving to the source (including through a symlink) hit the same trap.The fix canonicalizes both source and destination through
absolute_git_urland errors when they resolve to the same local (file:) path. Per @martinvonz's note on the issue, only the local-path case is handled;ssh://localhost-style self-clones remain out of scope.Checklist
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)