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

Use index.lock and move writes to head and refs to the end of the run to make interrupted fastfetch operations less bad #1763

Merged
merged 4 commits into from
Jan 27, 2022

Conversation

SteveBenz
Copy link
Contributor

No description provided.

@SteveBenz
Copy link
Contributor Author

As mentioned in the comments, FastFetch is pretty far away from the ideal way of handling .git/index and .git/index.lock. I had a go at fixing that, but after getting a ways into it, I decided that the value just wasn't really there and the risk was pretty high. So I hacked around the problem.

Copy link
Contributor

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

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

I think we can simplify this just a tiny bit more. What do you think?

GVFS/FastFetch/IndexLock.cs Show resolved Hide resolved
GVFS/FastFetch/CheckoutPrefetcher.cs Outdated Show resolved Hide resolved
@@ -72,87 +72,104 @@ public override void Prefetch(string branchOrCommit, bool isBranch)
commitToFetch = branchOrCommit;
}

this.DownloadMissingCommit(commitToFetch, this.GitObjects);
if (!IndexLock.TryGetLock(this.Enlistment.EnlistmentRoot, this.Tracer, out var indexLock))
Copy link
Contributor

Choose a reason for hiding this comment

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

Not to any other reviewers: this diff looks a lot better if you change the diff options to "Hide Whitespace".

GVFS/FastFetch/IndexLock.cs Outdated Show resolved Hide resolved
GVFS/FastFetch/CheckoutPrefetcher.cs Outdated Show resolved Hide resolved
@SteveBenz SteveBenz changed the title Add a bespoke index.lock file to protect fastfetch operations Use index.lock and move writes to head and refs to the end of the run to make interrupted fastfetch operations less bad Jan 25, 2022
Copy link
Contributor

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

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

Thanks for answering my questions!

@derrickstolee derrickstolee merged commit 2cd3558 into microsoft:master Jan 27, 2022
@vdye vdye mentioned this pull request Mar 12, 2024
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