-
Notifications
You must be signed in to change notification settings - Fork 899
repo.Index.Stage() won't notice a change if it occurs within the same second #688
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
Conversation
I don't recall exactly what |
It looks like @arrbee added some foundation code to support this in libgit2/libgit2@e35e268 |
Yes - it is a problem. If a file appears to have no changes to time and size, then we try not to actually reread it. Despite this, we get libgit2/libgit2#1625 where we do excessive OID calculation and go too slow. It seems like libgit2 is right now being both too forgiving about allowing unchanged stat data to hide a change and too rigid about calculating OIDs for some files that are not changed. I had promised to work on this a while ago - I'll bump it back up the priority list... |
Related #747 |
a6ddc5c
to
472eb2c
Compare
Related SO question "Index.RetrieveStatus On files that don't change length return unaltered" |
4875855
to
5386591
Compare
Yet another related SO question "Repository.Commit() is throwing EmptyCommitException even though there are changes in the working directory" |
5386591
to
230fed9
Compare
@carlosmn Rebased on top of latest libgit2. Still failing 😿 |
The error I see on AppVeyor was due to the null references on the Filter tests, one of the builds did pass fine. I've restarted. |
Looks like an unrelated failure. |
Indeed, but randomly fails on my local box. Applying the following patch diff --git a/LibGit2Sharp.Tests/StageFixture.cs b/LibGit2Sharp.Tests/StageFixture.cs
index 9a6c624..85633dc 100644
--- a/LibGit2Sharp.Tests/StageFixture.cs
+++ b/LibGit2Sharp.Tests/StageFixture.cs
@@ -382,11 +382,18 @@ public void CanSuccessfullyStageTheContentOfAModifiedFileOfTheSameSizeWithinTheS
{
for (int i = 0; i < 10; i++)
{
+ Console.WriteLine("Iteration " + i);
+
+ var content = Guid.NewGuid().ToString();
+
Touch(repo.Info.WorkingDirectory, "test.txt",
- Guid.NewGuid().ToString());
+ content);
+ Console.WriteLine("Content = " + content);
repo.Stage("test.txt");
+ Console.WriteLine("Index entry Id = " + repo.Index["test.txt"].Id.Sha);
+
Assert.DoesNotThrow(() => repo.Commit(
"Commit", Constants.Signature, Constants.Signature));
} Produces the following output
|
wrt AppVeyor. I restarted it. It now shows
|
I've been adding my own debug prints (including collecting the sizes into the managed struct) and it looks like we do behave exactly as we should wrt zeroing out files with the same timestamp as the index, which is the bit which we just merged a fix for. When it fails to update the entry (and thus have this error happen) is when an iteration happens across the second barrier, and the rewritten And it is in the iteration after the one I've described above that we fail to detect the size of the file. This is odd, as I was sure this did in fact work. The timestamps are different, so we have to re-read the file to check. I suspect a timestamp going backwards on us, which IIRC FAT can do, though I'm not sure if NTFS is capable of such a feat. |
So, a two-year-old TODO to actually implement the bit I was sure we already had Is what bit us. If you run this on top of libgit2/libgit2#3226 you should be unable to make it fail. |
Now for reals, putting this on top of libgit2's master really should make it work. |
49778e4
to
794a8bd
Compare
794a8bd
to
db02403
Compare
repo.Index.Stage() won't notice a change if it occurs within the same second
The test below actually fails
See this SO question for some background information.