Ejemplo n.º 1
0
        private void RestorePotentialPreviousVersionOf(string relativePath)
        {
            TreeEntry currentHeadBlob = repo.Head.Tip.Tree[relativePath];

            if ((currentHeadBlob == null) || currentHeadBlob.Type != GitObjectType.Blob)
            {
                return;
            }

            File.WriteAllBytes(Path.Combine(repo.Info.WorkingDirectory, relativePath), ((Blob)currentHeadBlob.Target).Content);
            AddToIndex(relativePath);
        }
Ejemplo n.º 2
0
        private void RestorePotentialPreviousVersionOfHeadIntoIndex(string relativePath)
        {
            TreeEntry treeEntry = repo.Head[relativePath];

            if (treeEntry == null || treeEntry.Type != GitObjectType.Blob)
            {
                return;
            }

            var indexEntry = new GitIndexEntry
            {
                Mode = (uint)treeEntry.Mode,
                oid  = treeEntry.TargetId.Oid,
                Path = utf8Marshaler.MarshalManagedToNative(relativePath),
            };

            Ensure.Success(NativeMethods.git_index_add2(handle, indexEntry));
            utf8Marshaler.CleanUpNativeData(indexEntry.Path);
        }
Ejemplo n.º 3
0
 private void WriteStream(string path, TreeEntry entry, DateTimeOffset modificationTime, Func <Stream> streamer)
 {
     using (Stream contentStream = streamer())
     {
         writer.Write(path,
                      contentStream,
                      modificationTime,
                      (entry.Mode == Mode.ExecutableFile)
                          ? "775".OctalToInt32()
                          : "664".OctalToInt32(),
                      "0",
                      "0",
                      '0',
                      "root",
                      "root",
                      "0",
                      "0",
                      entry.TargetId.Sha,
                      false);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Implements the archiving of a TreeEntry in a given format.
 /// </summary>
 /// <param name="path">The path of the entry in the archive.</param>
 /// <param name="entry">The entry to archive.</param>
 /// <param name="modificationTime">The datetime the entry was last modified.</param>
 protected abstract void AddTreeEntry(string path, TreeEntry entry, DateTimeOffset modificationTime);