예제 #1
0
 public ConflictData(ConflictedFileData _base, ConflictedFileData _local,
     ConflictedFileData _remote)
 {
     Base = _base;
     Local = _local;
     Remote = _remote;
 }
 private string GetShortHash(ConflictedFileData item)
 {
     if (item.Hash == null)
         return "@" + deleted.Text;
     return '@' + item.Hash.Substring(0, 8);
 }
예제 #3
0
        public List<ConflictData> GetConflicts(string filename = "")
        {
            filename = filename.ToPosixPath();

            var list = new List<ConflictData>();

            var unmerged = RunGitCmd("ls-files -z --unmerged " + filename.QuoteNE()).Split(new[] { '\0', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            var item = new ConflictedFileData[3];

            string prevItemName = null;

            foreach (var line in unmerged)
            {
                int findSecondWhitespace = line.IndexOfAny(new[] { ' ', '\t' });
                string fileStage = findSecondWhitespace >= 0 ? line.Substring(findSecondWhitespace).Trim() : "";

                findSecondWhitespace = fileStage.IndexOfAny(new[] { ' ', '\t' });

                string hash = findSecondWhitespace >= 0 ? fileStage.Substring(0, findSecondWhitespace).Trim() : "";
                fileStage = findSecondWhitespace >= 0 ? fileStage.Substring(findSecondWhitespace).Trim() : "";

                int stage;
                if (fileStage.Length > 2 && Int32.TryParse(fileStage[0].ToString(), out stage) && stage >= 1 && stage <= 3)
                {
                    var itemName = fileStage.Substring(2);
                    if (prevItemName != itemName && prevItemName != null)
                    {
                        list.Add(new ConflictData(item[0], item[1], item[2]));
                        item = new ConflictedFileData[3];
                    }
                    item[stage - 1] = new ConflictedFileData(hash, itemName);
                    prevItemName = itemName;
                }
            }
            if (prevItemName != null)
                list.Add(new ConflictData(item[0], item[1], item[2]));

            return list;
        }