public VisualGitStatus(GitStatusEventArgs args) { if (args == null) throw new ArgumentNullException("args"); _nodeKind = args.NodeKind; _state = args.LocalContentStatus; _localCopied = args.LocalCopied; if (args.WorkingCopyInfo != null) { _lastChangeTime = args.WorkingCopyInfo.LastChangeTime; _lastChangeRevision = args.WorkingCopyInfo.LastChangeRevision; _lastChangeAuthor = args.WorkingCopyInfo.LastChangeAuthor; _revision = args.WorkingCopyInfo.Revision; } _treeConflict = args.TreeConflict; if(_treeConflict != null) _treeConflict.Detach(); }
public bool IsIgnored(string fullPath, GitNodeKind kind) { string path; if (kind == GitNodeKind.File) path = Path.GetDirectoryName(fullPath); else if (kind == GitNodeKind.Directory) path = fullPath; else throw new ArgumentOutOfRangeException("kind"); Debug.Assert( (path + Path.DirectorySeparatorChar).StartsWith(_repositoryPath + Path.DirectorySeparatorChar, FileSystemUtil.StringComparison), "Path is not part of the repository" ); bool ignored = false; while (true) { IgnoreFile file; if (_ignoreFiles.TryGetValue(path, out file)) { string relativePath = fullPath.Substring(path.Length).Replace(Path.DirectorySeparatorChar, '/'); foreach (var rule in file.Rules) { if (rule.IsMatch(relativePath, kind == GitNodeKind.Directory)) ignored = !rule.GetNegation(); } } if (path.Equals(_repositoryPath, FileSystemUtil.StringComparison)) return ignored; path = Path.GetDirectoryName(path); } }
/// <summary> /// Check if adding the path might succeed /// </summary> /// <param name="path"></param> /// <returns><c>false</c> when adding the file will fail, <c>true</c> if it could succeed</returns> public bool CouldAdd(string path, GitNodeKind nodeKind) { if (path == null) throw new ArgumentNullException("path"); GitItem item = StatusCache[path]; string file = item.Name; if (!item.Exists || item.IsVersioned) return true; // Item already exists.. Fast GitItem parent = item.Parent; if (BelowAdminDir(item)) return false; if (item.IsFile && parent != null && !parent.IsVersioned) return true; // Not in a versioned directory -> Fast out // Item does exist; check casing string parentDir = GitTools.GetNormalizedDirectoryName(path); GitStatusArgs wa = new GitStatusArgs(); wa.ThrowOnError = false; wa.ThrowOnCancel = false; wa.Depth = GitDepth.Files; bool ok = true; using (GitClient client = GetService<IGitClientPool>().GetNoUIClient()) { client.Status(parentDir, wa, delegate(object sender, GitStatusEventArgs e) { if (string.Equals(e.FullPath, path, StringComparison.OrdinalIgnoreCase)) { if (!string.Equals(e.Name, file, StringComparison.Ordinal)) { ok = false; // Casing issue } } }); } return ok; }
protected bool GitCanAddPath(string fullpath, GitNodeKind nodeKind) { using (GitSccContext git = new GitSccContext(Context)) { // Determine if we could add fullname if (!git.CouldAdd(fullpath, nodeKind)) { if (git.BelowAdminDir(fullpath)) _batchErrors.Add(string.Format(Resources.GitPathXBlocked, fullpath)); else _batchErrors.Add(string.Format(Resources.PathXBlocked, fullpath)); return false; } else return true; } }