libgit2 / libgit2/libgit2sharp
Libgit2sharp CheckoutPaths() doesn't undo changes on file with status "NewInIndex, ModifiedInWorkdir".
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 925
- PR merge metrics
- No merged PRs in 30d
Description
You are opening a bug report against the LibGit2Sharp project: we
use GitHub Issues for tracking bug reports and feature requests. If
you have a question about an API or usage, please ask on StackOverflow:
http://stackoverflow.com/questions/tagged/libgit2sharp.
Otherwise, to report a bug, please fill out the reproduction steps
(below) and delete these introductory paragraphs. Thanks!
Reproduction steps
I have a file inside many folders (for ex : docs/jsons/myfile.json ) in my repository
I staged the file , so it now has the status "NewInIndex".
After that i made changes on that file.
It has now the status "NewInIndex, ModifiedInWorkdir".
My code is the following :
using ( var repo = new Repository("my repo path")
{
CheckoutOptions options = new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force };
repo.CheckoutPaths(repo.Head.FriendlyName, new string[] {"docs/jsons/myfile.json"} , options );
}
I also tried to replace " repo.Head.FriendlyName" by "repo.Head.CannonicalName" and by "repo.Head.Tip.Id.Sha"
Expected behavior
I expect the file to get back to its previous content, and to have the status "NewInIndex" again.
Actual behavior
The file's content doesnt change and its status is still : "NewInIndex, ModifiedInWorkdir".
Version of LibGit2Sharp (release number or SHA1)
LibGit2Sharp version 0.26.2
Operating system(s) tested; .NET runtime tested
Window 10 Enterprise
.NET 6.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CheckoutPaths API and reproduce the reported state transition for a file marked NewInIndex, ModifiedInWorkdir using the supplied path and CheckoutOptions. Verify that forcing checkout restores the staged content and leaves the file with NewInIndex status, using the reported LibGit2Sharp 0.26.2 behavior as the baseline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, git
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100