8000 Expose the assume-unchanged flag to IndexEntry · SinghVarun/libgit2sharp@6f16791 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f16791

Browse files
committed
Expose the assume-unchanged flag to IndexEntry
Fix libgit2#928
1 parent d4f0867 commit 6f16791

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

LibGit2Sharp.Tests/IndexFixture.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,20 @@ public void CanMimicGitAddAll()
466466
}
467467
}
468468

469+
[Fact]
470+
public void RetrievingAssumedUnchangedMarkedIndexEntries()
471+
{
472+
var path = SandboxAssumeUnchangedTestRepo();
473+
using (var repo = new Repository(path))
474+
{
475+
var regularFile = repo.Index["hello.txt"];
476+
Assert.False(regularFile.AssumeUnchanged);
477+
478+
var assumeUnchangedFile = repo.Index["world.txt"];
479+
Assert.True(assumeUnchangedFile.AssumeUnchanged);
480+
}
481+
}
482+
469483
private static void AddSomeCornerCases(Repository repo)
470484
{
471485
// Turn 1.txt into a directory in the Index

LibGit2Sharp/Core/GitIndexEntry.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ namespace LibGit2Sharp.Core
66
[StructLayout(LayoutKind.Sequential)]
77
internal class GitIndexEntry
88
{
9+
internal const ushort GIT_IDXENTRY_VALID = 0x8000;
10+
911
public GitIndexTime CTime;
1012
public GitIndexTime MTime;
1113
public uint Dev;

LibGit2Sharp/IndexEntry.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public class IndexEntry : IEquatable<IndexEntry>
3030
/// </summary>
3131
public virtual StageLevel StageLevel { get; private set; }
3232

33+
/// <summary>
34+
/// Whether the file is marked as assume-unchanged
35+
/// </summary>
36+
public virtual bool AssumeUnchanged { get; private set; }
37+
3338
/// <summary>
3439
/// Gets the id of the <see cref="Blob"/> pointed at by this index entry.
3540
/// </summary>
@@ -51,7 +56,8 @@ internal static IndexEntry BuildFromPtr(IndexEntrySafeHandle handle)
5156
Path = path.Native,
5257
Id = entry.Id,
5358
StageLevel = Proxy.git_index_entry_stage(handle),
54-
Mode = (Mode)entry.Mode
59+
Mode = (Mode)entry.Mode,
60+
AssumeUnchanged = (GitIndexEntry.GIT_IDXENTRY_VALID & entry.Flags) == GitIndexEntry.GIT_IDXENTRY_VALID
5561
};
5662
}
5763

0 commit comments

Comments
 (0)
0