GitSharp.Core.DirectoryCache.DirCacheEntry.smudgeRacilyClean C# (CSharp) Method

smudgeRacilyClean() public method

Force this entry to no longer match its working tree file. This avoids the "racy git" problem by making this index entry no longer match the file in the working directory. Later git will be forced to compare the file content to ensure the file matches the working tree.
public smudgeRacilyClean ( ) : void
return void
        public void smudgeRacilyClean()
        {
            // We don't use the same approach as C Git to smudge the entry,
            // as we cannot compare the working tree file to our SHA-1 and
            // thus cannot use the "size to 0" trick without accidentally
            // thinking a zero Length file is clean.
            //
            // Instead we force the mtime to the largest possible value, so
            // it is certainly After the index's own modification time and
            // on a future Read will cause mightBeRacilyClean to say "yes!".
            // It is also unlikely to match with the working tree file.
            //
            // I'll see you again before Jan 19, 2038, 03:14:07 AM GMT.
            //
            int @base = _infoOffset + PMtime;
            _info.Fill(@base, @base + 8, (byte)127);
        }

Usage Example

Ejemplo n.º 1
0
        private void WriteTo(Stream os)
        {
            MessageDigest foot = Constants.newMessageDigest();
            var           dos  = new DigestOutputStream(os, foot);

            // Write the header.
            //
            var tmp = new byte[128];

            Array.Copy(SigDirc, 0, tmp, 0, SigDirc.Length);
            NB.encodeInt32(tmp, 4, /* version */ 2);
            NB.encodeInt32(tmp, 8, _entryCnt);
            dos.Write(tmp, 0, 12);

            // Write the individual file entries.
            //
            if (_lastModified <= 0)
            {
                // Write a new index, as no entries require smudging.
                //
                for (int i = 0; i < _entryCnt; i++)
                {
                    _sortedEntries[i].write(dos);
                }
            }
            else
            {
                int smudge_s  = (int)(_lastModified / 1000);
                int smudge_ns = ((int)(_lastModified % 1000)) * 1000000;
                for (int i = 0; i < _entryCnt; i++)
                {
                    DirCacheEntry e = _sortedEntries[i];
                    if (e.mightBeRacilyClean(smudge_s, smudge_ns))
                    {
                        e.smudgeRacilyClean();
                    }
                    e.write(dos);
                }
            }

            if (_cacheTree != null)
            {
                var bb = new LocalFileBuffer();
                _cacheTree.write(tmp, bb);
                bb.close();

                NB.encodeInt32(tmp, 0, ExtTree);
                NB.encodeInt32(tmp, 4, (int)bb.Length);
                dos.Write(tmp, 0, 8);
                bb.writeTo(dos, null);
            }
            var hash = foot.Digest();

            os.Write(hash, 0, hash.Length);
            os.Close();
        }
All Usage Examples Of GitSharp.Core.DirectoryCache.DirCacheEntry::smudgeRacilyClean