Represents a Git repository. A repository holds all objects and refs used for managing source code (could by any type of file, but source code is what SCM's are typically used for). In Git terms all data is stored in GIT_DIR, typically a directory called .git. A work tree is maintained unless the repository is a bare repository. Typically the .git directory is located at the root of the work dir.
  • GIT_DIR
    • objects/ - objects
    • refs/ - tags and heads
    • config - configuration
    • info/ - more configurations
This class is thread-safe. This implementation only handles a subtly undocumented subset of git features.
Inheritance: IDisposable
コード例 #1
0
ファイル: GitRepository.cs プロジェクト: jsmale/git-tfs
 public GitRepository(TextWriter stdout, string gitDir, IContainer container)
     : base(stdout)
 {
     _container = container;
     GitDir = gitDir;
     _repository = new Repository(new DirectoryInfo(gitDir));
 }
コード例 #2
0
ファイル: ReflogReader.cs プロジェクト: georgeck/GitSharp
 ///	<summary>
 /// Parsed reflog entry.
 /// </summary>
 public ReflogReader(Repository db, string refName)
 {
     _logName = new FileInfo(
         Path.Combine(
             db.Directory.FullName,
                 Path.Combine("logs", refName)).Replace('/', Path.DirectorySeparatorChar));
 }
コード例 #3
0
ファイル: IgnoreHandler.cs プロジェクト: dev218/GitSharp
		public IgnoreHandler(Repository repo)
		{
			if (repo == null)
			{
				throw new ArgumentNullException("repo");
			}

			_repo = repo;

			try
			{
				string excludeFile = repo.Config.getCore().getExcludesFile();
				if (!string.IsNullOrEmpty(excludeFile))
				{
					ReadPatternsFromFile(Path.Combine(repo.WorkingDirectory.FullName, excludeFile), _excludePatterns);
				}
			}
			catch (Exception)
			{
				//optional
			}

			try
			{
				ReadPatternsFromFile(Path.Combine(repo.Directory.FullName, "info/exclude"), _excludePatterns);
			}
			catch (Exception)
			{
				// optional
			}
		}
コード例 #4
0
ファイル: ObjectWriter.cs プロジェクト: jagregory/GitSharp
 ///	<summary>
 /// Construct an object writer for the specified repository.
 /// </summary>
 ///	<param name="repo"> </param>
 public ObjectWriter(Repository repo)
 {
     _r = repo;
     _buf = new byte[0x2000];
     _md = new MessageDigest();
     _def = new Deflater(_r.Config.getCore().getCompression());
 }
コード例 #5
0
ファイル: RepositoryCache.cs プロジェクト: dev218/GitSharp
        public static void close(Repository db)
        {
			if (db == null)
				throw new System.ArgumentNullException ("db");
			
            Cache.unregisterRepository(FileKey.exact(db.Directory));
        }
コード例 #6
0
ファイル: CloneTests.cs プロジェクト: Flatlineato/GitSharp
        public void Checked_cloned_local_dotGit_suffixed_repo()
        {
            //setup of .git directory
            var resource =
                new DirectoryInfo(PathUtil.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
                                               "OneFileRepository"));
            var tempRepository =
                new DirectoryInfo(Path.Combine(trash.FullName, "OneFileRepository" + Path.GetRandomFileName() + Constants.DOT_GIT_EXT));
            CopyDirectory(resource.FullName, tempRepository.FullName);

            var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, Constants.DOT_GIT));
            Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);

            using (var repo = new Repository(repositoryPath.FullName))
            {
                Assert.IsTrue(Repository.IsValid(repo.Directory));
                Commit headCommit = repo.Head.CurrentCommit;
                Assert.AreEqual("f3ca78a01f1baa4eaddcc349c97dcab95a379981", headCommit.Hash);
            }

            string toPath = Path.Combine(trash.FullName, "to.git");

            using (var repo = Git.Clone(repositoryPath.FullName, toPath))
            {
                Assert.IsTrue(Repository.IsValid(repo.Directory));
                Commit headCommit = repo.Head.CurrentCommit;
                Assert.AreEqual("f3ca78a01f1baa4eaddcc349c97dcab95a379981", headCommit.Hash);
            }
        }
コード例 #7
0
ファイル: RepositoryConfig.cs プロジェクト: dev218/GitSharp
        public RepositoryConfig(Repository repo)
            : this(SystemReader.getInstance().openUserConfig(), new FileInfo(Path.Combine(repo.Directory.FullName, "config")))
        {
			if (repo == null)
				throw new System.ArgumentNullException ("repo");
            
        }
コード例 #8
0
ファイル: RefDatabase.cs プロジェクト: stschake/GitSharp
 public RefDatabase(Repository repo)
 {
     Repository = repo;
     _gitDir = repo.Directory;
     _refsDir = PathUtil.CombineDirectoryPath(_gitDir, "refs");
     _packedRefsFile = PathUtil.CombineFilePath(_gitDir, "packed-refs");
     ClearCache();
 }
コード例 #9
0
ファイル: WorkDirCheckout.cs プロジェクト: dev218/GitSharp
 ///	<summary>
 /// Create a checkout class for checking out one tree, merging with the index
 ///	</summary>
 ///	<param name="repo"> </param>
 ///	<param name="root"> workdir </param>
 ///	<param name="index"> current index </param>
 ///	<param name="merge"> tree to check out </param>
 public WorkDirCheckout(Repository repo, DirectoryInfo root, GitIndex index, Tree merge)
     : this()
 {
     this._repo = repo;
     this._root = root;
     this._index = index;
     this._merge = merge;
 }
コード例 #10
0
ファイル: WorkDirCheckout.cs プロジェクト: dev218/GitSharp
 internal WorkDirCheckout(Repository repo, DirectoryInfo workDir, GitIndex oldIndex, GitIndex newIndex)
     : this()
 {
     _repo = repo;
     _root = workDir;
     _index = oldIndex;
     _merge = repo.MapTree(newIndex.writeTree());
 }
コード例 #11
0
ファイル: PersonIdent.cs プロジェクト: spraints/GitSharp
        private readonly int tzOffset; // offset in minutes to UTC

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates new PersonIdent from config info in repository, with current time.
        /// This new PersonIdent gets the info from the default committer as available
        /// from the configuration.
        /// </summary>
        /// <param name="repo"></param>
        public PersonIdent(Repository repo)
        {
            RepositoryConfig config = repo.Config;
            Name = config.getCommitterName();
            EmailAddress = config.getCommitterEmail();
            When = SystemReader.getInstance().getCurrentTime();
            tzOffset = SystemReader.getInstance().getTimezone(When);
        }
コード例 #12
0
 public void AlternativeCallbackApiTest()
 {
     using (var repo = new Repository(trash.FullName))
     {
         repo.Head.Reset(ResetBehavior.Mixed);
         writeTrashFile("untracked", "");
         writeTrashFile("added", "");
         repo.Index.Add("added");
         writeTrashFile("a/a1", "modified");
         repo.Index.AddContent("a/a1.txt", "staged");
         repo.Index.Remove("b/b2.txt");
         var status = repo.Status;
         Assert.AreEqual(1, status.Added.Count);
         Assert.AreEqual(1, status.Staged.Count);
         Assert.AreEqual(6, status.Missing.Count);
         Assert.AreEqual(1, status.Modified.Count);
         Assert.AreEqual(1, status.Removed.Count);
         Assert.AreEqual(1, status.Untracked.Count);
         var stati = new List<PathStatus>();
         var s = new RepositoryStatus(repo, new RepositoryStatusOptions
         {
             PerPathNotificationCallback = path_status =>
             {
                 stati.Add(path_status);
                 switch (path_status.WorkingPathStatus)
                 {
                     case WorkingPathStatus.Missing:
                         Assert.IsTrue(status.Missing.Contains(path_status.Path));
                         break;
                     case WorkingPathStatus.Modified:
                         Assert.IsTrue(status.Modified.Contains(path_status.Path));
                         break;
                     case WorkingPathStatus.Untracked:
                         Assert.IsTrue(status.Untracked.Contains(path_status.Path));
                         break;
                 }
                 switch (path_status.IndexPathStatus)
                 {
                     case IndexPathStatus.Added:
                         Assert.IsTrue(status.Added.Contains(path_status.Path));
                         break;
                     case IndexPathStatus.Removed:
                         Assert.IsTrue(status.Removed.Contains(path_status.Path));
                         break;
                     case IndexPathStatus.Staged:
                         Assert.IsTrue(status.Staged.Contains(path_status.Path));
                         break;
                 }
             }
         });
         var dict = stati.ToDictionary(p => p.Path);
         Assert.IsTrue(dict.ContainsKey("untracked"));
         Assert.IsTrue(dict.ContainsKey("added"));
         Assert.IsTrue(dict.ContainsKey("a/a1"));
         Assert.IsTrue(dict.ContainsKey("a/a1.txt"));
         Assert.IsTrue(dict.ContainsKey("b/b2.txt"));
     }
 }
コード例 #13
0
 ///	<summary>
 /// Parsed reflog entry.
 /// </summary>
 public ReflogReader(Repository db, string refName)
 {
     if (db == null)
         throw new ArgumentNullException ("db");
     _logName = new FileInfo(
         Path.Combine(
             db.Directory.FullName,
                 Path.Combine("logs", refName)).Replace('/', Path.DirectorySeparatorChar));
 }
コード例 #14
0
ファイル: BlobBasedConfig.cs プロジェクト: jagregory/GitSharp
 ///	<summary> * The constructor from object identifier
 ///	</summary>
 ///	<param name="base">the base configuration file </param>
 ///	<param name="r">the repository</param>
 /// <param name="objectid">the object identifier</param>
 /// <exception cref="IOException">
 /// the blob cannot be read from the repository. </exception>
 /// <exception cref="ConfigInvalidException">
 /// the blob is not a valid configuration format.
 /// </exception> 
 public BlobBasedConfig(Config @base, Repository r, ObjectId objectid)
     : base(@base)
 {
     ObjectLoader loader = r.OpenBlob(objectid);
     if (loader == null)
     {
         throw new IOException("Blob not found: " + objectid);
     }
     fromText(RawParseUtils.decode(loader.Bytes));
 }
コード例 #15
0
ファイル: RepositoryWalker.cs プロジェクト: diev/dotnet-docfx
        public RepositoryWalker(CoreRepository repo)
        {
            if (repo == null)
            {
                throw new ArgumentNullException(nameof(repo));
            }

            _walker          = new RevWalk(repo);
            _assistantWalker = new RevWalk(repo);
            _initCommit      = new RevCommit(repo.Head.ObjectId);
        }
コード例 #16
0
        private IEnumerable <string> GetPackRefs(GitSharp.Core.Repository repository)
        {
            var packDir = repository.ObjectsDirectory.GetDirectories().SingleOrDefault(x => x.Name == "pack");

            if (packDir == null)
            {
                return(Enumerable.Empty <string>());
            }

            return(packDir.GetFiles("*.pack").Select(x => x.Name).ToList());
        }
コード例 #17
0
ファイル: GitRepository.cs プロジェクト: dipeshc/git-tfs
        public GitRepository(TextWriter stdout, string gitDir, IContainer container, Globals globals)
            : base(stdout, container)
        {
            _container = container;
            _globals = globals;

            DirectoryInfo GitDirectoryInfo = GitHelpers.ResolveRepositoryLocation();

            GitDir = GitDirectoryInfo.ToString();
            _repository = new Repository(GitDirectoryInfo);
        }
コード例 #18
0
		public void TracksAddedFiles()
		{
			//setup of .git directory
			var resource =
				 new DirectoryInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
														  "CorruptIndex"));
			var tempRepository =
				 new DirectoryInfo(Path.Combine(trash.FullName, "CorruptIndex" + Path.GetRandomFileName()));
			CopyDirectory(resource.FullName, tempRepository.FullName);

			var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, Constants.DOT_GIT));
			Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);

			using (var repository = new Repository(repositoryPath.FullName))
			{
				var status = repository.Status;

				Assert.IsTrue(status.AnyDifferences);
				Assert.AreEqual(1, status.Added.Count);
				Assert.IsTrue(status.Added.Contains("b.txt")); // the file already exists in the index (eg. has been previously git added)
				Assert.AreEqual(0, status.Staged.Count);
				Assert.AreEqual(0, status.Missing.Count);
				Assert.AreEqual(0, status.Modified.Count);
				Assert.AreEqual(0, status.Removed.Count);
				Assert.AreEqual(0, status.Untracked.Count);

				string filepath = Path.Combine(repository.WorkingDirectory, "c.txt");
				writeTrashFile(filepath, "c");
				repository.Index.Add(filepath);

				status.Update();

				Assert.IsTrue(status.AnyDifferences);
				Assert.AreEqual(2, status.Added.Count);
				Assert.IsTrue(status.Added.Contains("b.txt"));
				Assert.IsTrue(status.Added.Contains("c.txt"));
				Assert.AreEqual(0, status.Staged.Count);
				Assert.AreEqual(0, status.Missing.Count);
				Assert.AreEqual(0, status.Modified.Count);
				Assert.AreEqual(0, status.Removed.Count);
				Assert.AreEqual(0, status.Untracked.Count);

				repository.Commit("after that no added files should remain", Author.Anonymous);
				status.Update();

				Assert.AreEqual(0, status.Added.Count);
				Assert.AreEqual(0, status.Staged.Count);
				Assert.AreEqual(0, status.Missing.Count);
				Assert.AreEqual(0, status.Modified.Count);
				Assert.AreEqual(0, status.Removed.Count);
				Assert.AreEqual(0, status.Untracked.Count);
				Assert.AreEqual(0, status.Untracked.Count);
			}
		}
コード例 #19
0
ファイル: RepositoryWalker.cs プロジェクト: dotnet/docfx
        public RepositoryWalker(CoreRepository repo)
        {
            if (repo == null)
            {
                throw new ArgumentNullException(nameof(repo));
            }

            _walker = new RevWalk(repo);
            _assistantWalker = new RevWalk(repo);
            _initCommit = new RevCommit(repo.Head.ObjectId);

        }
コード例 #20
0
ファイル: BlobBasedConfig.cs プロジェクト: dev218/GitSharp
		///	<summary> * The constructor from object identifier
		///	</summary>
		///	<param name="base">the base configuration file </param>
		///	<param name="repo">the repository</param>
		/// <param name="objectid">the object identifier</param>
		/// <exception cref="IOException">
		/// the blob cannot be read from the repository. </exception>
		/// <exception cref="ConfigInvalidException">
		/// the blob is not a valid configuration format.
		/// </exception> 
		public BlobBasedConfig(Config @base, Repository repo, ObjectId objectid)
			: base(@base)
		{
			if (repo == null)
			{
				throw new System.ArgumentNullException("repo");
			}
			
			ObjectLoader loader = repo.OpenBlob(objectid);
			if (loader == null)
			{
				throw new IOException("Blob not found: " + objectid);
			}
			fromText(RawParseUtils.decode(loader.Bytes));
		}
コード例 #21
0
ファイル: Tag.cs プロジェクト: spraints/GitSharp
 /**
  * Construct a Tag representing an existing with a known name referencing an known object.
  * This could be either a simple or annotated tag.
  *
  * @param db {@link Repository}
  * @param id target id.
  * @param refName tag name or null
  * @param raw data of an annotated tag.
  */
 public Tag(Repository db, ObjectId id, string refName, byte[] raw)
 {
     Repository = db;
     if (raw != null)
     {
         TagId = id;
         Id = ObjectId.FromString(raw, 7);
     }
     else
         Id = id;
     if (refName != null && refName.StartsWith("refs/tags/"))
         refName = refName.Substring(10);
     TagName = refName;
     this.raw = raw;
 }
コード例 #22
0
        public override void Execute()
        {
            if (Source.Length <= 0)
            {
                throw new ArgumentNullException("Repository", "fatal: You must specify a repository to clone.");
            }

            URIish source = new URIish(Source);

            if (Mirror)
            {
                Bare = true;
            }
            if (Bare)
            {
                if (OriginName != null)
                {
                    throw new ArgumentException("Bare+Origin", "--bare and --origin " + OriginName + " options are incompatible.");
                }
                NoCheckout = true;
            }
            if (OriginName == null)
            {
                OriginName = "origin";
            }

            var repo = new GitSharp.Core.Repository(new DirectoryInfo(ActualDirectory));

            repo.Create(Bare);
            repo.Config.setBoolean("core", null, "bare", Bare);
            repo.Config.save();
            Repository = new Repository(repo);
            if (!Quiet)
            {
                OutputStream.WriteLine("Initialized empty Git repository in " + repo.Directory.FullName);
                OutputStream.Flush();
            }

            saveRemote(source);
            FetchResult r = runFetch();

            GitSharp.Core.Ref branch = guessHEAD(r);
            if (!NoCheckout)
            {
                doCheckout(branch);
            }
        }
コード例 #23
0
        private void WriteInfoPacks(IEnumerable <string> packs, GitSharp.Core.Repository repository)
        {
            var w = new StringBuilder();

            foreach (string pack in packs)
            {
                w.Append("P ");
                w.Append(pack);
                w.Append('\n');
            }

            var infoPacksPath = Path.Combine(repository.ObjectsDirectory.FullName, "info/packs");
            var encoded       = Encoding.ASCII.GetBytes(w.ToString());


            using (Stream fs = File.Create(infoPacksPath)) {
                fs.Write(encoded, 0, encoded.Length);
            }
        }
コード例 #24
0
ファイル: EncodingTests.cs プロジェクト: spraints/GitSharp
        public void CanReadFromMsysGitJapaneseRepository()
        {
            //setup of .git directory
            var resource =
                 new DirectoryInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
                                                          "JapaneseRepo"));
            var tempRepository =
                 new DirectoryInfo(Path.Combine(trash.FullName, "JapaneseRepo" + Path.GetRandomFileName()));
            CopyDirectory(resource.FullName, tempRepository.FullName);

            var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, Constants.DOT_GIT));
            Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);
            using (Repository repo = new Repository(tempRepository.FullName))
            {
                string commitHash = "24ed0e20ceff5e2cdf768345b6853213f840ff8f";

                var commit = new Commit(repo, commitHash);
                Assert.AreEqual("コミットのメッセージも日本語でやてみました。\n", commit.Message);
            }
        }
コード例 #25
0
        public void CanAddAFileToAMSysGitIndexWhereAFileIsAlreadyWaitingToBeCommitted()
        {
            //setup of .git directory
            var resource =
                new DirectoryInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
                                               "CorruptIndex"));
            var tempRepository =
                new DirectoryInfo(Path.Combine(trash.FullName, "CorruptIndex" + Path.GetRandomFileName()));
            CopyDirectory(resource.FullName, tempRepository.FullName);

            var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, ".git"));
            Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);

            var repository = new Repository(repositoryPath);
            GitIndex index = repository.Index;

            Assert.IsNotNull(index);

            writeTrashFile(Path.Combine(repository.WorkingDirectory.FullName, "c.txt"), "c");

            var tree = new Tree(repository);

            index.add(repository.WorkingDirectory, new FileInfo(Path.Combine(repository.WorkingDirectory.FullName, "c.txt")));

            var diff = new IndexDiff(tree, index);
            diff.Diff();

            index.write();

            Assert.AreEqual(3, diff.Added.Count);
            Assert.IsTrue(diff.Added.Contains("a.txt"));
            Assert.IsTrue(diff.Added.Contains("b.txt"));
            Assert.IsTrue(diff.Added.Contains("c.txt"));
            Assert.AreEqual(0, diff.Changed.Count);
            Assert.AreEqual(0, diff.Modified.Count);
            Assert.AreEqual(0, diff.Removed.Count);
        }
コード例 #26
0
        public void CanReadMsysgitIndex()
        {
            //setup of .git directory
            var resource =
                new DirectoryInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
                                               "OneFileRepository"));
            var tempRepository =
                new DirectoryInfo(Path.Combine(trash.FullName, "OneFileRepository" + Path.GetRandomFileName()));
            CopyDirectory(resource.FullName, tempRepository.FullName);

            var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, ".git"));
            Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);

            var repository = new Repository(repositoryPath);
            GitIndex index = repository.Index;

            Assert.IsNotNull(index);
            List<GitIndex.Entry> entries = index.Members.ToList();
            Assert.AreEqual(1, entries.Count);

            GitIndex.Entry entry = entries[0];
            Assert.AreEqual("dummy.txt", entry.Name);

            Ref headRef = repository.Head;
            Assert.AreEqual("refs/heads/master", headRef.Name);
            Assert.AreEqual("f3ca78a01f1baa4eaddcc349c97dcab95a379981", headRef.ObjectId.Name);

            object obj = repository.MapObject(headRef.ObjectId, headRef.OriginalName);
            Assert.IsInstanceOfType(typeof(Commit), obj);
            var commit = (Commit) obj;

            Assert.AreEqual("f3ca78a01f1baa4eaddcc349c97dcab95a379981", commit.CommitId.Name);
            Assert.AreEqual(commit.Committer, commit.Author);
            Assert.AreEqual("nulltoken <*****@*****.**> 1255117188 +0200", commit.Committer.ToExternalString());

            Assert.AreEqual(0, commit.ParentIds.Length);
        }
コード例 #27
0
ファイル: GitRepository.cs プロジェクト: fschwiet/git-tfs
 public GitRepository(TextWriter stdout, string gitDir)
     : base(stdout)
 {
     GitDir = gitDir;
     _repository = new Repository(new DirectoryInfo(gitDir));
 }
コード例 #28
0
ファイル: WorkDirCheckout.cs プロジェクト: kkl713/GitSharp
 ///	<summary>
 /// Create a checkout class for merging and checking our two trees and the index.
 ///	</summary>
 ///	<param name="repo"> </param>
 ///	<param name="root"> workdir </param>
 ///	<param name="head"> </param>
 ///	<param name="index"> </param>
 ///	<param name="merge"> </param>
 public WorkDirCheckout(Repository repo, DirectoryInfo root, Core.Tree head, GitIndex index, Core.Tree merge)
     : this(repo, root, index, merge)
 {
     this._head = head;
 }
コード例 #29
0
 public void UntrackedFiles()
 {
     using (var repo = new Repository(trash.FullName))
     {
         var a = writeTrashFile("untracked.txt", "");
         var b = writeTrashFile("someDirectory/untracked2.txt", "");
         repo.Index.Add(writeTrashFile("untracked2.txt", "").FullName); // <-- adding a file with same name in higher directory to test the file name comparison.
         var status = repo.Status;
         Assert.AreEqual(2, status.Untracked.Count);
         Assert.IsTrue(status.Untracked.Contains("untracked.txt"));
         Assert.IsTrue(status.Untracked.Contains("someDirectory/untracked2.txt"));
         Assert.IsTrue(status.Added.Contains("untracked2.txt"));
         Assert.AreEqual(0, status.Staged.Count);
         Assert.AreEqual(0, status.Missing.Count);
         Assert.AreEqual(0, status.Modified.Count);
         Assert.AreEqual(8, status.Removed.Count);
     }
 }
コード例 #30
0
 public void IgnoreUntrackedFilesAndDirectories()
 {
     using (var repo = new Repository(trash.FullName))
     {
         repo.Head.Reset(ResetBehavior.Hard);
         writeTrashFile("untracked.txt", "");
         writeTrashFile("image.png", "");
         writeTrashFile("someDirectory/untracked2.txt", "");
         writeTrashFile("someDirectory/untracked", "");
         writeTrashFile("some/other/directory/.svn/format", "");
         writeTrashFile("some/other/README", "");
         writeTrashFile("some/other/directory/README", "");
         // ignore patterns:
         writeTrashFile(".gitignore", "*.txt\n.svn");
         writeTrashFile("some/other/.gitignore", "README\n");
         var status = repo.Status;
         Assert.IsTrue(status.Untracked.Contains("image.png"));
         Assert.IsTrue(status.Untracked.Contains("someDirectory/untracked"));
         Assert.AreEqual(0, status.Added.Count);
         Assert.AreEqual(0, status.Staged.Count);
         Assert.AreEqual(0, status.Missing.Count);
         Assert.AreEqual(0, status.Modified.Count);
         Assert.AreEqual(0, status.Removed.Count);
         Assert.AreEqual(0, status.MergeConflict.Count);
         Assert.AreEqual(4, status.Untracked.Count);
         writeTrashFile(".gitignore", "other");
         writeTrashFile("some/other/.gitignore", "");
         status.Update();
         Assert.IsTrue(status.Untracked.Contains("untracked.txt"));
         Assert.IsTrue(status.Untracked.Contains("someDirectory/untracked2.txt"));
         Assert.IsTrue(status.Untracked.Contains("someDirectory/untracked"));
         Assert.IsTrue(status.Untracked.Contains("image.png"));
         Assert.AreEqual(0, status.Added.Count);
         Assert.AreEqual(0, status.Staged.Count);
         Assert.AreEqual(0, status.Missing.Count);
         Assert.AreEqual(0, status.Modified.Count);
         Assert.AreEqual(0, status.Removed.Count);
         Assert.AreEqual(0, status.MergeConflict.Count);
         Assert.AreEqual(5, status.Untracked.Count);
     }
 }
コード例 #31
0
 internal Repository(CoreRepository repo)
 {
     //PreferredEncoding = Encoding.UTF8;
     _internal_repo = repo;
 }
コード例 #32
0
ファイル: Tree.cs プロジェクト: dev218/GitSharp
		/// <summary>
		/// Construct a Tree with a known SHA-1 under another tree. Data is not yet
		///	specified and will have to be loaded on demand.
		///	</summary>
		///	<param name="parent"></param>
		///	<param name="id"></param>
		///	<param name="nameUTF8"></param>
		public Tree(Tree parent, ObjectId id, byte[] nameUTF8)
			: base(parent, id, nameUTF8)
		{
			_db = parent.Repository;
		}
コード例 #33
0
ファイル: Tree.cs プロジェクト: dev218/GitSharp
		///	<summary>
		/// Construct a new Tree under another Tree
		/// </summary>
		/// <param name="parent"></param>
		/// <param name="nameUTF8"></param>
		public Tree(Tree parent, byte[] nameUTF8)
			: base(parent, null, nameUTF8)
		{
			_db = parent.Repository;
			_contents = EmptyTree;
		}
コード例 #34
0
ファイル: Tree.cs プロジェクト: dev218/GitSharp
		///	<summary>
		/// Construct a Tree object with known content and hash value
		///	</summary>
		///	<param name="repo"></param>
		///	<param name="id"></param>
		///	<param name="raw"></param>
		///	<exception cref="IOException"></exception>
		public Tree(Repository repo, ObjectId id, byte[] raw)
			: base(null, id, null)
		{
			_db = repo;
			ReadTree(raw);
		}
コード例 #35
0
ファイル: Tree.cs プロジェクト: dev218/GitSharp
		///	<summary>
		/// Constructor for a new Tree
		///	</summary>
		///	<param name="repo">The repository that owns the Tree.</param>
		public Tree(Repository repo)
			: base(null, null, null)
		{
			_db = repo;
			_contents = EmptyTree;
		}
コード例 #36
0
ファイル: ObjectWriter.cs プロジェクト: dev218/GitSharp
 ///	<summary>
 /// Construct an object writer for the specified repository.
 /// </summary>
 ///	<param name="repo"> </param>
 public ObjectWriter(Repository repo)
 {
     _r = repo;
     _buf = new byte[0x2000];
     _md = Constants.newMessageDigest();
 }
コード例 #37
0
 public SimpleRefWriter(GitSharp.Core.Repository db, IEnumerable <Ref> refs)
     : base(refs)
 {
     _db = db;
 }
コード例 #38
0
ファイル: Ref.cs プロジェクト: yhtsnda/Bonobo-Git-Server
 /// <summary>
 /// Check validity of a ref name. It must not contain a character that has
 /// a special meaning in a Git object reference expression. Some other
 /// dangerous characters are also excluded.
 /// </summary>
 /// <param name="refName"></param>
 /// <returns>
 /// Returns true if <paramref name="refName"/> is a valid ref name.
 /// </returns>
 public static bool IsValidName(string refName)
 {
     return(CoreRepository.IsValidRefName(refName));
 }