/// <summary> /// Adds all files which are marked as to be added to Git /// </summary> /// <param name="state">The state.</param> /// <returns></returns> private bool PreCommit_AddNewFiles(PendingCommitState state) { foreach (PendingChange pc in state.Changes) { if (pc.Change != null && pc.Change.State == PendingChangeKind.New) { GitItem item = pc.GitItem; // HACK: figure out why PendingChangeKind.New is still true if (item.IsVersioned) continue; // No need to add GitAddArgs a = new GitAddArgs(); a.AddParents = true; a.Depth = GitDepth.Empty; try { state.Client.Add(pc.FullPath, a); } catch (GitException ex) { GetService<IVisualGitErrorHandler>().OnWarning(ex); return false; } } } return true; }
internal void HandleEvent(VisualGitCommand command) { List<GitProject> dirtyProjects; HybridCollection<string> dirtyCheck; HybridCollection<string> maybeAdd; bool forceFullRefresh; VisualGitSccProvider provider = Context.GetService<VisualGitSccProvider>(); lock (_lock) { _posted = false; _onIdle = false; if (provider == null) return; dirtyProjects = _dirtyProjects; dirtyCheck = _dirtyCheck; maybeAdd = _maybeAdd; forceFullRefresh = _forceFullRefresh; _dirtyProjects = null; _dirtyCheck = null; _maybeAdd = null; _forceFullRefresh = false; } using (new FileStatusRefreshHint(forceFullRefresh)) { if (dirtyCheck != null) foreach (string file in dirtyCheck) { DocumentTracker.CheckDirty(file); } if (dirtyProjects != null) { foreach (GitProject project in dirtyProjects) { if (project.RawHandle == null) { if (project.IsSolution) provider.UpdateSolutionGlyph(); continue; // All IVsSccProjects have a RawHandle } try { project.RawHandle.SccGlyphChanged(0, null, null, null); } catch { } } } if (maybeAdd != null) { using (GitClient cl = GetService<IGitClientPool>().GetNoUIClient()) { foreach (string file in maybeAdd) { GitItem item = Cache[file]; // Only add // * files // * that are unversioned // * that are addable // * that are not ignored // * and just to be sure: that are still part of the solution if (item.IsFile && !item.IsVersioned && item.IsVersionable && !item.IsIgnored && item.InSolution) { GitAddArgs aa = new GitAddArgs(); aa.ThrowOnError = false; // Just ignore errors here; make the user add them themselves aa.AddParents = true; cl.Add(item.FullPath, aa); } } } } } }