Blinkbox implementation of GitFile The original implementation of this class is located in GitFileStatus.cs
 public void SetStatus(string filename, GitFileStatus status)
 {
     if (!String.IsNullOrWhiteSpace(filename))
     {
         var fileKey      = filename.ToLower();
         var changeStatus = GitFile.IsChangedStatus(status) ? status : GitFileStatus.Unaltered;
         if (_fileStatus.ContainsKey(fileKey))
         {
             if (changeStatus == GitFileStatus.Unaltered)
             {
                 ChangesetFileStatus dStatus;
                 _fileStatus.TryRemove(fileKey, out dStatus);
             }
             else
             {
                 _fileStatus.AddOrUpdate(fileKey, new ChangesetFileStatus(changeStatus), (key, val) => new ChangesetFileStatus(changeStatus));
             }
         }
         else if (changeStatus != GitFileStatus.Unaltered)
         {
             _fileStatus.AddOrUpdate(fileKey, new ChangesetFileStatus(changeStatus), (key, val) => new ChangesetFileStatus(changeStatus));
         }
     }
 }
        public IList <GitFile> ParseGitStatus(string statusString)
        {
            //Debug.WriteLine(statusString);

            var list = new List <GitFile>();

            if (string.IsNullOrEmpty(statusString))
            {
                return(list);
            }

            // trim warning messages
            var    nl             = new char[] { '\n', '\r' };
            string trimmedStatus  = statusString.Trim(nl);
            int    lastNewLinePos = trimmedStatus.LastIndexOfAny(nl);

            if (lastNewLinePos > 0)
            {
                int ind = trimmedStatus.LastIndexOf('\0');
                if (ind < lastNewLinePos) //Warning at end
                {
                    lastNewLinePos = trimmedStatus.IndexOfAny(nl, ind >= 0 ? ind : 0);
                    trimmedStatus  = trimmedStatus.Substring(0, lastNewLinePos).Trim(nl);
                }
                else                                              //Warning at beginning
                {
                    trimmedStatus = trimmedStatus.Substring(lastNewLinePos).Trim(nl);
                }
            }


            //Split all files on '\0' (WE NEED ALL COMMANDS TO BE RUN WITH -z! THIS IS ALSO IMPORTANT FOR ENCODING ISSUES!)
            var files = trimmedStatus.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);

            for (int n = 0; n < files.Length; n++)
            {
                if (string.IsNullOrEmpty(files[n]))
                {
                    continue;
                }

                int splitIndex = files[n].IndexOfAny(new char[] { '\0', '\t', ' ' }, 1);

                string status   = string.Empty;
                string fileName = string.Empty;

                if (splitIndex < 0)
                {
                    //status = files[n];
                    //fileName = files[n + 1];
                    //n++;
                    continue;
                }
                else
                {
                    status   = files[n].Substring(0, splitIndex);
                    fileName = files[n].Substring(splitIndex);
                }

                //X shows the status of the index, and Y shows the status of the work tree

                char x = status[0];
                char y = status.Length > 1 ? status[1] : ' ';

                var gitFile = new GitFile {
                    FileName = fileName.Trim()
                };

                switch (x)
                {
                case '?':
                    gitFile.Status = GitFileStatus.New;
                    break;

                case '!':
                    gitFile.Status = GitFileStatus.Ignored;
                    break;

                case ' ':
                    if (y == 'M')
                    {
                        gitFile.Status = GitFileStatus.Modified;
                    }
                    else if (y == 'D')
                    {
                        gitFile.Status = GitFileStatus.Deleted;
                    }
                    break;

                case 'M':
                    gitFile.Status = GitFileStatus.Staged;
                    break;

                case 'A':
                    gitFile.Status = GitFileStatus.Added;
                    break;

                case 'D':
                    gitFile.Status = GitFileStatus.Removed;
                    break;

                case 'R':
                    gitFile.Status = GitFileStatus.Renamed;
                    break;

                case 'C':
                    gitFile.Status = GitFileStatus.Copied;
                    break;

                case 'U':
                    gitFile.Status = GitFileStatus.Conflict;
                    break;
                }
                list.Add(gitFile);

                this.cache[GetCacheKey(gitFile.FileName)] = gitFile.Status;
            }
            return(list);
        }
        public IList<GitFile> ParseGitStatus(string statusString)
        {
            //Debug.WriteLine(statusString);

            var list = new List<GitFile>();
            if (string.IsNullOrEmpty(statusString)) return list;

            // trim warning messages
            var nl = new char[] { '\n', '\r' };
            string trimmedStatus = statusString.Trim(nl);
            int lastNewLinePos = trimmedStatus.LastIndexOfAny(nl);
            if (lastNewLinePos > 0)
            {
                int ind = trimmedStatus.LastIndexOf('\0');
                if (ind < lastNewLinePos) //Warning at end
                {
                    lastNewLinePos = trimmedStatus.IndexOfAny(nl, ind >= 0 ? ind : 0);
                    trimmedStatus = trimmedStatus.Substring(0, lastNewLinePos).Trim(nl);
                }
                else                                              //Warning at beginning
                    trimmedStatus = trimmedStatus.Substring(lastNewLinePos).Trim(nl);
            }

            //Split all files on '\0' (WE NEED ALL COMMANDS TO BE RUN WITH -z! THIS IS ALSO IMPORTANT FOR ENCODING ISSUES!)
            var files = trimmedStatus.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
            for (int n = 0; n < files.Length; n++)
            {
                if (string.IsNullOrEmpty(files[n]))
                    continue;

                int splitIndex = files[n].IndexOfAny(new char[] { '\0', '\t', ' ' }, 1);

                string status = string.Empty;
                string fileName = string.Empty;

                if (splitIndex < 0)
                {
                    //status = files[n];
                    //fileName = files[n + 1];
                    //n++;
                    continue;
                }
                else
                {
                    status = files[n].Substring(0, splitIndex);
                    fileName = files[n].Substring(splitIndex);
                }

                //X shows the status of the index, and Y shows the status of the work tree

                char x = status[0];
                char y = status.Length > 1 ? status[1] : ' ';

                var gitFile = new GitFile { FileName = fileName.Trim() };

                switch (x)
                {
                    case '?':
                        gitFile.Status = GitFileStatus.New;
                        break;
                    case '!':
                        gitFile.Status = GitFileStatus.Ignored;
                        break;
                    case ' ':
                        if (y == 'M') gitFile.Status = GitFileStatus.Modified;
                        else if (y == 'D') gitFile.Status = GitFileStatus.Deleted;
                        break;
                    case 'M':
                        if (y == 'M') gitFile.Status = GitFileStatus.Modified;
                        else gitFile.Status = GitFileStatus.Staged;
                        break;
                    case 'A':
                        gitFile.Status = GitFileStatus.Added;
                        break;
                    case 'D':
                        gitFile.Status = GitFileStatus.Removed;
                        break;
                    case 'R':
                        gitFile.Status = GitFileStatus.Renamed;
                        break;
                    case 'C':
                        gitFile.Status = GitFileStatus.Copied;
                        break;

                    case 'U':
                        gitFile.Status = GitFileStatus.Conflict;
                        break;
                }
                list.Add(gitFile);

                this.cache[GetCacheKey(gitFile.FileName)] = gitFile.Status;
            }
            return list;
        }