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

TreeDefinition item recursive remove not working #2057

Open
SS1823 opened this issue Aug 30, 2023 · 2 comments
Open

TreeDefinition item recursive remove not working #2057

SS1823 opened this issue Aug 30, 2023 · 2 comments

Comments

@SS1823
Copy link

SS1823 commented Aug 30, 2023

Reproduction steps

Compile & run

using LibGit2Sharp;

Repository.Init(args[0]);
var repo = new Repository(args[0]);

TreeDefinition current = new();
current.Add("sample/stays/to/a/file", repo.ObjectDatabase.CreateBlob("stays".ToStream()), Mode.NonExecutableFile);
current.Add("sample/removed/to/a/file", repo.ObjectDatabase.CreateBlob("removed".ToStream()), Mode.NonExecutableFile);
current.Remove("sample/removed");

var tree = repo.ObjectDatabase.CreateTree(current);
var sig = new Signature("John Doe", "jd@example.com", DateTimeOffset.UtcNow);
var commit = repo.ObjectDatabase.CreateCommit(sig, sig, "Test", tree, new Commit[] { }, false);
var branch = repo.Branches.Add("main", commit, true);
repo.Refs.UpdateTarget(repo.Refs.Head, branch.Reference);
static class Ext
{
    public static Stream ToStream(this string data)
    {
        MemoryStream stream = new();
        StreamWriter writer = new(stream);
        writer.Write(data);
        writer.Flush();
        stream.Position = 0;
        return stream;
    }
}

Expected behavior

sample/removed path is not in repo

Actual behavior

sample/removed is there with the file

Version of LibGit2Sharp (release number or SHA1)

2.7.2

Operating system(s) tested; .NET runtime tested

linux (.net7) & windows (.net7)

@SS1823
Copy link
Author

SS1823 commented Aug 30, 2023

I noticed the code does not remove entries from unwrappedTrees dictionary, just from entries maybe that's the issue here

@tyrielv
Copy link
Contributor

tyrielv commented Jan 4, 2024

Duplicate of #1869

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

No branches or pull requests

2 participants