Skip to content

index: match git on invalid checkout paths#2235

Merged
jelmer merged 3 commits into
mainfrom
fix-colon-checkout-2205
Jun 12, 2026
Merged

index: match git on invalid checkout paths#2235
jelmer merged 3 commits into
mainfrom
fix-colon-checkout-2205

Conversation

@jelmer

@jelmer jelmer commented Jun 12, 2026

Copy link
Copy Markdown
Owner

The NTFS path-element validator rejected any element containing ':' or '', so files with a colon in their name (e.g. with:colon.txt) were silently dropped on clone. Reject only the '.git'/'git~1' alternate-data- stream spellings instead, like git: a bare colon is accepted, and a backslash is only rejected as a separator on Windows while still terminating the .git scan on every platform.

When a tree entry's path is genuinely invalid, abort the checkout rather than silently skipping the entry.

Fixes #2205

@abderrahim

Copy link
Copy Markdown
Contributor

This seems to fix the issue, thanks.

However, the dulwich CLI crashes with scary backtrace with a bad repo.

❯ git clone bad/ cloned-git
Cloning into 'cloned-git'...
done.
error: invalid path 'test\.git'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
❯ dulwich clone bad/ cloned-dul
counting objects: 6, done.
found 0 deltas to reuse
unable to checkout working tree: invalid path 'test\\.git'
Traceback (most recent call last):
  File "/home/abderrahim/.local/share/uv/tools/dulwich/lib/python3.13/site-packages/dulwich/cli.py", line 2121, in run
    porcelain.clone(
    ~~~~~~~~~~~~~~~^
        parsed_args.source,
        ^^^^^^^^^^^^^^^^^^^
    ...<8 lines>...
        ssh_command=_ssh_command_from_env(),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/abderrahim/.local/share/uv/tools/dulwich/lib/python3.13/site-packages/dulwich/porcelain/__init__.py", line 1576, in clone
    repo = client.clone(
        path,
    ...<9 lines>...
        protocol_version=protocol_version,
    )
  File "/home/abderrahim/.local/share/uv/tools/dulwich/lib/python3.13/site-packages/dulwich/client.py", line 3290, in clone
    target.get_worktree().reset_index(config=target.get_config_stack())
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abderrahim/.local/share/uv/tools/dulwich/lib/python3.13/site-packages/dulwich/worktree.py", line 841, in reset_index
    return build_index_from_tree(
        self.path,
    ...<6 lines>...
        blob_normalizer=blob_normalizer,
    )
  File "/home/abderrahim/.local/share/uv/tools/dulwich/lib/python3.13/site-packages/dulwich/index.py", line 2179, in build_index_from_tree
    raise InvalidPathError(entry.path)
dulwich.index.InvalidPathError: invalid path 'test\\.git'

@jelmer jelmer force-pushed the fix-colon-checkout-2205 branch from 2ec3c9e to abd0891 Compare June 12, 2026 08:50
Two related fixes for issue #2205:

The NTFS path-element validator rejected any element containing ':' or
'\', so files with a colon in their name (e.g. with:colon.txt) were
silently dropped on clone. Reject only the '.git'/'git~1' alternate-data-
stream spellings instead, like git: a bare colon is accepted, and a
backslash is only rejected as a separator on Windows while still
terminating the .git scan on every platform.

When a tree entry's path is genuinely invalid, abort the checkout rather
than silently skipping the entry.

Fixes #2205
@jelmer jelmer force-pushed the fix-colon-checkout-2205 branch from abd0891 to 7544dcd Compare June 12, 2026 08:51
@jelmer jelmer enabled auto-merge June 12, 2026 08:53
@jelmer jelmer merged commit f545f72 into main Jun 12, 2026
37 checks passed
@jelmer jelmer deleted the fix-colon-checkout-2205 branch June 12, 2026 10:51
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

Successfully merging this pull request may close these issues.

Files with ascii 0x3a (:) in their filename are not checked out when running dulwich clone

2 participants