示例#1
0
 protected internal override byte[] IdSubmodule(WorkingTreeIterator.Entry e)
 {
     if (repository == null)
     {
         return(IdSubmodule(GetDirectory(), e));
     }
     return(base.IdSubmodule(e));
 }
示例#2
0
 private byte[] IdBufferBlob(WorkingTreeIterator.Entry e)
 {
     try
     {
         InputStream @is = e.OpenInputStream();
         if (@is == null)
         {
             return(zeroid);
         }
         try
         {
             state.InitializeDigestAndReadBuffer();
             long len = e.GetLength();
             if (!MightNeedCleaning())
             {
                 return(ComputeHash(@is, len));
             }
             if (len <= MAXIMUM_FILE_SIZE_TO_READ_FULLY)
             {
                 ByteBuffer rawbuf = IOUtil.ReadWholeStream(@is, (int)len);
                 byte[]     raw    = ((byte[])rawbuf.Array());
                 int        n      = rawbuf.Limit();
                 if (!IsBinary(raw, n))
                 {
                     rawbuf = FilterClean(raw, n);
                     raw    = ((byte[])rawbuf.Array());
                     n      = rawbuf.Limit();
                 }
                 return(ComputeHash(new ByteArrayInputStream(raw, 0, n), n));
             }
             if (IsBinary(e))
             {
                 return(ComputeHash(@is, len));
             }
             long        canonLen;
             InputStream lenIs = FilterClean(e.OpenInputStream());
             try
             {
                 canonLen = ComputeLength(lenIs);
             }
             finally
             {
                 SafeClose(lenIs);
             }
             return(ComputeHash(FilterClean(@is), canonLen));
         }
         finally
         {
             SafeClose(@is);
         }
     }
     catch (IOException)
     {
         // Can't read the file? Don't report the failure either.
         return(zeroid);
     }
 }
示例#3
0
        private void ParseEntry()
        {
            ignoreStatus = -1;
            WorkingTreeIterator.Entry e = entries[ptr];
            mode = e.GetMode().GetBits();
            int nameLen = e.encodedNameLen;

            EnsurePathCapacity(pathOffset + nameLen, pathOffset);
            System.Array.Copy(e.encodedName, 0, path, pathOffset, nameLen);
            pathLen = pathOffset + nameLen;
        }
示例#4
0
        /// <exception cref="System.IO.IOException"></exception>
        private bool IsBinary(WorkingTreeIterator.Entry entry)
        {
            InputStream @in = entry.OpenInputStream();

            try
            {
                return(RawText.IsBinary(@in));
            }
            finally
            {
                SafeClose(@in);
            }
        }
示例#5
0
 private WorkingTreeIterator.Entry[] Entries()
 {
     FilePath[] all = directory.ListFiles();
     if (all == null)
     {
         return(EOF);
     }
     WorkingTreeIterator.Entry[] r = new WorkingTreeIterator.Entry[all.Length];
     for (int i = 0; i < r.Length; i++)
     {
         r[i] = new FileTreeIterator.FileEntry(all[i], fs);
     }
     return(r);
 }
示例#6
0
        /// <summary>Constructor helper.</summary>
        /// <remarks>Constructor helper.</remarks>
        /// <param name="list">
        /// files in the subtree of the work tree this iterator operates
        /// on
        /// </param>
        protected internal virtual void Init(WorkingTreeIterator.Entry[] list)
        {
            // Filter out nulls, . and .. as these are not valid tree entries,
            // also cache the encoded forms of the path names for efficient use
            // later on during sorting and iteration.
            //
            entries = list;
            int            i;
            int            o;
            CharsetEncoder nameEncoder = state.nameEncoder;

            for (i = 0, o = 0; i < entries.Length; i++)
            {
                WorkingTreeIterator.Entry e = entries[i];
                if (e == null)
                {
                    continue;
                }
                string name = e.GetName();
                if (".".Equals(name) || "..".Equals(name))
                {
                    continue;
                }
                if (Constants.DOT_GIT.Equals(name))
                {
                    continue;
                }
                if (Constants.DOT_GIT_IGNORE.Equals(name))
                {
                    ignoreNode = new WorkingTreeIterator.PerDirectoryIgnoreNode(e);
                }
                if (i != o)
                {
                    entries[o] = e;
                }
                e.EncodeName(nameEncoder);
                o++;
            }
            entryCnt = o;
            Arrays.Sort(entries, 0, entryCnt, ENTRY_CMP);
            contentIdFromPtr = -1;
            ptr = 0;
            if (!Eof)
            {
                ParseEntry();
            }
        }
示例#7
0
 internal static int LastPathChar(WorkingTreeIterator.Entry e)
 {
     return(e.GetMode() == FileMode.TREE ? '/' : '\0');
 }
示例#8
0
 internal RootIgnoreNode(WorkingTreeIterator.Entry entry, Repository repository) :
     base(entry)
 {
     this.repository = repository;
 }
示例#9
0
 internal PerDirectoryIgnoreNode(WorkingTreeIterator.Entry entry) : base(Sharpen.Collections
                                                                         .EmptyList <IgnoreRule>())
 {
     this.entry = entry;
 }