/// <summary> /// Adjusts the modifed paths and placeholders list for an index entry. /// </summary> /// <param name="gitIndexEntry">Index entry</param> /// <param name="filePlaceholders"> /// Dictionary of file placeholders. AddEntryToModifiedPathsAndRemoveFromPlaceholdersIfNeeded will /// remove enties from filePlaceholders as they are found in the index. After /// AddEntryToModifiedPathsAndRemoveFromPlaceholdersIfNeeded is called for all entries in the index /// filePlaceholders will contain only those placeholders that are not in the index. /// </param> private FileSystemTaskResult AddEntryToModifiedPathsAndRemoveFromPlaceholdersIfNeeded( GitIndexEntry gitIndexEntry, HashSet <string> filePlaceholders) { gitIndexEntry.BackgroundTask_ParsePath(); string placeholderRelativePath = gitIndexEntry.BackgroundTask_GetPlatformRelativePath(); FileSystemTaskResult result = FileSystemTaskResult.Success; if (!gitIndexEntry.SkipWorktree) { // A git command (e.g. 'git reset --mixed') may have cleared a file's skip worktree bit without // triggering an update to the projection. If git cleared the skip-worktree bit then git will // be responsible for updating the file and we need to: // - Ensure this file is in GVFS's modified files database // - Remove this path from the placeholders list (if present) result = this.projection.AddModifiedPath(placeholderRelativePath); if (result == FileSystemTaskResult.Success) { if (filePlaceholders.Remove(placeholderRelativePath)) { this.projection.RemoveFromPlaceholderList(placeholderRelativePath); } } } else { filePlaceholders.Remove(placeholderRelativePath); } return(result); }
private void ParsePathForIndexEntry(GitIndexEntry indexEntry, string path, int replaceIndex) { byte[] pathBuffer = Encoding.UTF8.GetBytes(path); Buffer.BlockCopy(pathBuffer, 0, indexEntry.PathBuffer, 0, pathBuffer.Length); indexEntry.PathLength = pathBuffer.Length; indexEntry.ReplaceIndex = replaceIndex; if (this.buildingNewProjection) { indexEntry.BuildingProjection_ParsePath(); } else { indexEntry.BackgroundTask_ParsePath(); } }