Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Comments

fix: properly parse pure renames in git diffs#4

Merged
wolfv merged 4 commits intoprefix-dev:masterfrom
wolfv:rename-parsing
Oct 28, 2025
Merged

fix: properly parse pure renames in git diffs#4
wolfv merged 4 commits intoprefix-dev:masterfrom
wolfv:rename-parsing

Conversation

@wolfv
Copy link
Member

@wolfv wolfv commented Oct 28, 2025

A pure rename has no hunks, and this made the parser error out before.

Now we treat it more carefully.

Should fix: prefix-dev/rattler-build#1960

AI Disclaimer:

Most changes made by Claude :)

Copy link

@remimimimimi remimimimimi left a comment

Choose a reason for hiding this comment

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

Just couple of small comments, otherwise looks good to me!

Option<(Cow<'a, [u8]>, Option<LineEnd>)>,
)> {
skip_header_preamble(parser)?;
let (git_original, git_modified) = skip_header_preamble(parser)?;

Choose a reason for hiding this comment

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

Maybe then it would make sense to rename skip_header_preamble to header_preamble?

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed! :)

Comment on lines +951 to +976
Patch {
original: Some(
Filename(
"tinygrad/frontend/__init__.py",
),
),
modified: Some(
Filename(
"tinygrad/frontend/__init__.py",
),
),
hunks: [],
},
Patch {
original: Some(
Filename(
"tinygrad/frontend/onnx.py",
),
),
modified: Some(
Filename(
"tinygrad/nn/onnx.py",
),
),
hunks: [],
},

Choose a reason for hiding this comment

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

Won't it cause problems if we will leave filenames without their usual a/b prefix?

Copy link
Member Author

Choose a reason for hiding this comment

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

It won't in our code in rattler-build (we are stripping them later anyways).

I also made the code more robust because git diff --no-prefix can actually also produce files without that prefix. So now we are checking that both files start/end with a/ or b/).

Now I am realizing that this logic might not work great for /dev/null...

Choose a reason for hiding this comment

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

Don't we have special handling for /dev/null in rattler-build? @wolfv

Copy link
Member Author

Choose a reason for hiding this comment

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

We just discussed this on Discord. The reasoning for stripping a/ and b/ here is that we have more information during patch parsing (e.g. we can observe if the patch starts with diff --git ....

So stripping a/ and b/ is easier here.

Additionally, it is more necessary for these operations because they usually map from "/dev/null" -> "a/foobar". Now it's ambigous whether we need to strip or create a a/ directory.

@wolfv wolfv merged commit 0ee3429 into prefix-dev:master Oct 28, 2025
3 checks passed
@wolfv wolfv deleted the rename-parsing branch October 28, 2025 11:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Patch application fails to do pure file renames

2 participants