Skip to content

Default GitFileSystem reads to HEAD - #2525

Open
Daniel-Kim-Grata wants to merge 1 commit into
fsspec:masterfrom
Daniel-Kim-Grata:fix/git-default-head
Open

Daniel-Kim-Grata wants to merge 1 commit into
fsspec:masterfrom
Daniel-Kim-Grata:fix/git-default-head

Conversation

@Daniel-Kim-Grata

Copy link
Copy Markdown
Contributor

Without an explicit ref, GitFileSystem resolves master even when another branch is checked out. That fails in repositories without master and can read a different commit from the current checkout.

Default to HEAD and clarify that the backend reads committed content rather than uncommitted working-tree edits. Explicit refs are unchanged.

The new tests use real temporary repositories with a main branch but no master, and a detached HEAD that differs from master. Both fail before the change. All 45 Git filesystem tests pass after it.

@N7766 N7766 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional check on e944670: a real linked worktree on feature/worktree, with .git as a file and uncommitted file edits. Default cat_file, fsspec.open(path=...), and an embedded git://repo:file URL all read the committed feature content; explicit ref="main" still reads main. Unpatched main fails the three default-ref cases. All 45 Git backend tests also pass (macOS/Python 3.11, pygit2 1.21.0). AI-assisted verification; other backends not tested.

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.

2 participants