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

Potential fix: Correctly shrink vec into a box #5904

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

estib-vega
Copy link
Contributor

Shrink the vec into a box correctly, so that it can be serialized and propagated correctly.

Copy link

vercel bot commented Jan 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitbutler-components ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 8, 2025 4:01pm
gitbutler-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 8, 2025 4:01pm

Shrink the vec into a box correctly, so that it can be serialized and propagated correctly.
@estib-vega
Copy link
Contributor Author

@mtsgrd I was not able to consistently reproduce the locking message not showing up.
I did see it once, but I wasn't able to reproduce it a second time.

What I did find out was that the message doesn't show up because the file has the property locked set to true but has 0 lockedIds which are derived from the hunks.lockedTo.

My guess is that the reason for this inconsistent condition is that the lockedTo value is somehow being incorrectly set from the rust side, and this change fixes the most probable culprit.

@@ -53,7 +53,7 @@ impl VirtualBranchHunk {
hunk: GitHunk,
hash: Digest,
mtimes: &mut MTimeCache,
locked_to: &[HunkLock],
locked_to: Box<[HunkLock]>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a bit of desperation here and I'd be surprised if this affects the serialisation. It will affect the runtime though, so I'd hope this can be done without enforcing an extra clone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Byron Yeah, the justification for this is that it used to be this way (cloning it too) before implemented by someone else and my guess is that when I changed it I introduced a race condition.

I do indeed don't know for certain whether this fixes that, though.

Also, I'm not sure I can box the vec without cloning it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I won't merge this until I'm sure this is the source of the condition.

@Caleb-T-Owens
Copy link
Contributor

I'm rather surprised that serialisation was being problematic with the slice. @Byron is there anything serde related that you might know of that could be causing this?

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