Example #1
0
        internal virtual FileMode ParseFileMode(int ptr, int end)
        {
            int tmp = 0;

            while (ptr < end - 1)
            {
                tmp <<= 3;
                tmp  += buf[ptr++] - '0';
            }
            return(FileMode.FromBits(tmp));
        }
Example #2
0
        protected FileMode ParseFileMode(int ptr, int end)
        {
            int tmp = 0;

            while (ptr < end - 1)
            {
                tmp <<= 3;
                tmp  += Buffer[ptr++] - '0';
            }
            return(FileMode.FromBits(tmp));
        }
Example #3
0
        internal virtual FileMode ParseFileMode(int ptr, int end)
        {
            int tmp = 0;

            if (IsWindowsLineEnding(end))         // Ignore windows line ending
            {
                end--;
            }
            while (ptr < end - 1)
            {
                tmp <<= 3;
                tmp  += buf[ptr++] - '0';
            }
            return(FileMode.FromBits(tmp));
        }
Example #4
0
        private void MarkTreeUninteresting(RevObject tree)
        {
            if ((tree.Flags & UNINTERESTING) != 0)
            {
                return;
            }
            tree.Flags |= UNINTERESTING;

            _treeWalk = _treeWalk.resetRoot(Repository, tree, WindowCursor);
            while (!_treeWalk.eof())
            {
                FileMode mode  = _treeWalk.EntryFileMode;
                var      sType = (int)mode.ObjectType;

                switch (sType)
                {
                case Constants.OBJ_BLOB:
                    _treeWalk.getEntryObjectId(IdBuffer);
                    lookupBlob(IdBuffer).Flags |= UNINTERESTING;
                    break;

                case Constants.OBJ_TREE:
                    _treeWalk.getEntryObjectId(IdBuffer);
                    RevTree t = lookupTree(IdBuffer);
                    if ((t.Flags & UNINTERESTING) == 0)
                    {
                        t.Flags  |= UNINTERESTING;
                        _treeWalk = _treeWalk.createSubtreeIterator0(Repository, t, WindowCursor);
                        continue;
                    }
                    break;

                default:
                    if (FileMode.GitLink == FileMode.FromBits(mode.Bits))
                    {
                        break;
                    }
                    _treeWalk.getEntryObjectId(IdBuffer);

                    throw new CorruptObjectException("Invalid mode " + mode
                                                     + " for " + IdBuffer + " "
                                                     + _treeWalk.EntryPathString + " in " + tree + ".");
                }

                _treeWalk = _treeWalk.next();
            }
        }
Example #5
0
 /// <summary>Updates the index after a content merge has happened.</summary>
 /// <remarks>
 /// Updates the index after a content merge has happened. If no conflict has
 /// occurred this includes persisting the merged content to the object
 /// database. In case of conflicts this method takes care to write the
 /// correct stages to the index.
 /// </remarks>
 /// <param name="base"></param>
 /// <param name="ours"></param>
 /// <param name="theirs"></param>
 /// <param name="result"></param>
 /// <param name="of"></param>
 /// <exception cref="System.IO.FileNotFoundException">System.IO.FileNotFoundException
 ///     </exception>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 private void UpdateIndex(CanonicalTreeParser @base, CanonicalTreeParser ours, CanonicalTreeParser
                          theirs, MergeResult <RawText> result, FilePath of)
 {
     if (result.ContainsConflicts())
     {
         // a conflict occurred, the file will contain conflict markers
         // the index will be populated with the three stages and only the
         // workdir (if used) contains the halfways merged content
         Add(tw.RawPath, @base, DirCacheEntry.STAGE_1, 0, 0);
         Add(tw.RawPath, ours, DirCacheEntry.STAGE_2, 0, 0);
         Add(tw.RawPath, theirs, DirCacheEntry.STAGE_3, 0, 0);
         mergeResults.Put(tw.PathString, result.Upcast());
     }
     else
     {
         // no conflict occurred, the file will contain fully merged content.
         // the index will be populated with the new merged version
         DirCacheEntry dce     = new DirCacheEntry(tw.PathString);
         int           newMode = MergeFileModes(tw.GetRawMode(0), tw.GetRawMode(1), tw.GetRawMode(2)
                                                );
         // set the mode for the new content. Fall back to REGULAR_FILE if
         // you can't merge modes of OURS and THEIRS
         dce.FileMode = (newMode == FileMode.MISSING.GetBits()) ? FileMode.REGULAR_FILE :
                        FileMode.FromBits(newMode);
         dce.LastModified = of.LastModified();
         dce.SetLength((int)of.Length());
         InputStream @is = new FileInputStream(of);
         try
         {
             dce.SetObjectId(GetObjectInserter().Insert(Constants.OBJ_BLOB, of.Length(), @is));
         }
         finally
         {
             @is.Close();
             if (inCore)
             {
                 FileUtils.Delete(of);
             }
         }
         builder.Add(dce);
     }
 }
Example #6
0
 private static int LastPathChar(int mode)
 {
     return(FileMode.Tree == FileMode.FromBits(mode) ? (byte)'/' : (byte)'\0');
 }
Example #7
0
 /// <summary>
 /// Obtain the <seealso cref="FileMode"/> for this entry.
 /// </summary>
 /// <returns>The file mode singleton for this entry.</returns>
 public FileMode getFileMode()
 {
     return(FileMode.FromBits(getRawMode()));
 }
Example #8
0
        public static readonly string NewFile = FileMode.RegularFile.ToModeString();// "100644";

        public static FileMode ToFileMode(this string mode)
        {
            return(FileMode.FromBits(Convert.ToInt32(mode, 8)));
        }
Example #9
0
 /// <summary>
 /// Obtain the
 /// <see cref="NGit.FileMode">NGit.FileMode</see>
 /// for the current entry.
 /// <p>
 /// Every added tree supplies a mode, even if the tree does not contain the
 /// current entry. In the latter case
 /// <see cref="NGit.FileMode.MISSING">NGit.FileMode.MISSING</see>
 /// is returned.
 /// </summary>
 /// <param name="nth">tree to obtain the mode from.</param>
 /// <returns>mode for the current entry of the nth tree.</returns>
 public virtual FileMode GetFileMode(int nth)
 {
     return(FileMode.FromBits(GetRawMode(nth)));
 }
Example #10
0
 public void ShouldFormatFileMode()
 {
     Assert.AreEqual("000020", FileMode.FromBits(16).ToModeString());
 }
Example #11
0
 /**
  * Obtain the {@link FileMode} for the current entry.
  * <para />
  * Every added tree supplies a mode, even if the tree does not contain the
  * current entry. In the latter case {@link FileMode#MISSING} is returned.
  *
  * @param nth
  *            tree to obtain the mode from.
  * @return mode for the current entry of the nth tree.
  */
 public FileMode getFileMode(int nth)
 {
     return(FileMode.FromBits(getRawMode(nth)));
 }