Esempio n. 1
0
 /// <summary>
 /// Adds untracked files or directories to the index and writes the index to the disk (like "git add").
 /// For tracked files that were modified, it stages the modification. Is a no-op for tracked files that were
 /// not modified.
 ///
 /// Note: Add as many files as possible by one call of this method for best performance.
 /// </summary>
 /// <param name="paths">Paths to add to the index</param>
 public void Add(params string[] paths)
 {
     GitIndex.RereadIfNecessary();
     foreach (var absolute_or_relative_path in paths)
     {
         string path = absolute_or_relative_path;
         if (!Path.IsPathRooted(absolute_or_relative_path))
         {
             path = Path.Combine(_repo.WorkingDirectory, path);
         }
         if (new FileInfo(path).Exists)
         {
             AddFile(new FileInfo(path));
         }
         else if (new DirectoryInfo(path).Exists)
         {
             AddDirectory(new DirectoryInfo(path));
         }
         else
         {
             throw new ArgumentException("File or directory at <" + path + "> doesn't seem to exist.", "path");
         }
     }
     GitIndex.write();
 }
Esempio n. 2
0
 /// <summary>
 /// Adds untracked files or directories to the index and writes the index to the disk (like "git add").
 /// For tracked files that were modified, it stages the modification. Is a no-op for tracked files that were
 /// not modified.
 ///
 /// Note: Add as many files as possible by one call of this method for best performance.
 /// </summary>
 /// <param name="paths">Paths to add to the index</param>
 public void Add(params string[] paths)
 {
     GitIndex.RereadIfNecessary();
     foreach (var path in paths)
     {
         if (new FileInfo(path).Exists)
         {
             AddFile(new FileInfo(path));
         }
         else if (new DirectoryInfo(path).Exists)
         {
             AddDirectory(new DirectoryInfo(path));
         }
         else
         {
             throw new ArgumentException("File or directory at <" + path + "> doesn't seem to exist.", "path");
         }
     }
     GitIndex.write();
 }