Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probably fix #5096 #5111

Merged
merged 2 commits into from
Oct 14, 2024
Merged

Probably fix #5096 #5111

merged 2 commits into from
Oct 14, 2024

Conversation

Byron
Copy link
Collaborator

@Byron Byron commented Oct 11, 2024

When testing paths for prefix-matches it's important they are all normalized in the same fashion.

canonicalize() is very particular about canonicalizing Windows paths, which makes it easy for these paths to not be compatible to other absolute-looking paths.

The difficulty here is to get the right trade-off between performance and safety, e.g. we wouldn't want these canonicalized Windows paths to be used anywhere as they are very uncommon (and don't even work everywhere).

Notes for the Reviewer

  • I didn't actually validate this on Windows, but am quite confident that this will fix the issue.
  • This PR touches read_file_from_workspace() which needs work, I just did the bare minimum here. More context is here.

Related to #5096 .

…lly.

Unfortunately, with anything `git2`, it's impossible (or unknown) to
prevent it from picking up the users configuration, hence tests aren't
isolated.

This change alleviates the worst results of this which at least makes
the tests run in my particular setup.
…hs (gitbutlerapp#5096)

When testing paths for prefix-matches it's important they are all normalized in
the same fashion.

`canonicalize()` is very particular about canonicalizing Windows paths, which
makes it easy for these paths to not be compatible to other absolute-looking
paths.

The difficulty here is to get the right trade-off between performance and
safety, e.g. we wouldn't want these canonicalized Windows paths to be used
anywhere as they are very uncommon (and don't even work everywhere).
Copy link

vercel bot commented Oct 11, 2024

@Byron is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the rust Pull requests that update Rust code label Oct 11, 2024
@Byron Byron linked an issue Oct 11, 2024 that may be closed by this pull request
@ndom91
Copy link
Contributor

ndom91 commented Oct 12, 2024

So what was the underlying issue here? The prefix match didn't work on windows due to canonicalize?

@Byron
Copy link
Collaborator Author

Byron commented Oct 12, 2024

Yes, it's very likely. Note that gix_path::* is used as it does what canonicalize() does, but without butchering Windows paths, so its output is usable also for presentation to the user. The lack of this trait is the reason that Project::path doesn't use canonicalize(), which would have been an alternative solution.

Copy link
Contributor

@Caleb-T-Owens Caleb-T-Owens left a comment

Choose a reason for hiding this comment

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

LGTM.

I'm still not in love with the name. IIRC there was some business logic reason as to why we wanted to get the committed version of the file over the uncommitted one, but that feels like something we can bike-shed another time

@Byron
Copy link
Collaborator Author

Byron commented Oct 14, 2024

Maybe #5089 should rather create a new function that acts like it need it to act, while this one could be renamed to something more specific. If the case, the canonicalize()/realpath() check also won't be needed anymore.

Edit: Merging, hoping that #5089 can sort out the fate of this function.

@Byron Byron merged commit 0be8710 into gitbutlerapp:master Oct 14, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants