Skip to content

Commit

Permalink
Fixed conflicted file being in bad sates.
Browse files Browse the repository at this point in the history
Conflict window now shows filename correctly when to long.
Fixed backslash platform formating (for sanity).
  • Loading branch information
zezba9000 committed Apr 26, 2017
1 parent ca1dd13 commit f2d0ca2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
13 changes: 4 additions & 9 deletions GitCommander/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,14 @@ public static Tuple<string, string> RunExe
StreamWriter stdOutStreamWriter = null;
if (stdOutToFilePath != null)
{
stdOutToFilePath = Repository.repoPath + Path.DirectorySeparatorChar + stdOutToFilePath;
stdOutToFilePath = Repository.repoPath + Path.DirectorySeparatorChar + stdOutToFilePath.Replace('/', Path.DirectorySeparatorChar);
stdOutStream = new FileStream(stdOutToFilePath, FileMode.Create, FileAccess.Write, FileShare.None);
stdOutStreamWriter = new StreamWriter(stdOutStream);
}

var outDataReceived = new StdCallbackMethod(delegate(string line)
{
if (stdOutToFilePath != null)
{
stdOutStreamWriter.WriteLine(line);
stdOutStreamWriter.Flush();
stdOutStream.Flush();
}
if (stdOutToFilePath != null) stdOutStreamWriter.WriteLine(line);

if (stdCallback != null) stdCallback(line);
if (stdResultOn)
Expand Down Expand Up @@ -156,10 +151,10 @@ public static Tuple<string, string> RunExe
process.WaitForExit();

// close stdOut file
if (stdOutStreamWriter != null) stdOutStreamWriter.Dispose();
if (stdOutStreamWriter != null) stdOutStreamWriter.Flush();
if (stdOutStream != null)
{
stdOutStream.Close();
stdOutStream.Flush();
stdOutStream.Dispose();
}
}
Expand Down
2 changes: 2 additions & 0 deletions GitItGUI.Core/AppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ private static void Client_DownloadStringCompleted(object sender, DownloadString
Debug.LogError("Failed to grab git version!", true);
client.Dispose();
if (checkForUpdatesCallback != null) checkForUpdatesCallback(false, true);
DownloadGit();
return;
}

Expand All @@ -427,6 +428,7 @@ private static void Client_DownloadStringCompleted(object sender, DownloadString
Debug.LogError("Failed to grab git-lfs version!", true);
client.Dispose();
if (checkForUpdatesCallback != null) checkForUpdatesCallback(false, true);
DownloadGitLFS();
return;
}

Expand Down
16 changes: 11 additions & 5 deletions GitItGUI.Core/ChangesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public static bool ResolveAllConflicts(bool refresh = true)
public static bool ResolveConflict(FileState fileState, bool refresh)
{
bool wasModified = false, success = true;
string fullPath = Repository.repoPath + Path.DirectorySeparatorChar + fileState.filename;
string fullPath = Repository.repoPath + Path.DirectorySeparatorChar + fileState.filename.Replace('/', Path.DirectorySeparatorChar);
string fullPathBase = fullPath+".base", fullPathOurs = null, fullPathTheirs = null;
var DeleteTempMergeFiles = new DeleteTempMergeFilesMethod(delegate ()
{
Expand All @@ -509,6 +509,9 @@ public static bool ResolveConflict(FileState fileState, bool refresh)

try
{
// make sure file is in a normal state
File.SetAttributes(fullPath, FileAttributes.Normal);

// make sure file needs to be resolved
if (!fileState.HasState(FileStates.Conflicted))
{
Expand All @@ -529,14 +532,14 @@ public static bool ResolveConflict(FileState fileState, bool refresh)
if (fileState.conflictType != FileConflictTypes.DeletedByUs)
{
bool fileCreated = Repository.SaveConflictedFile(fileState.filename, FileConflictSources.Ours, out fullPathOurs);
fullPathOurs = Repository.repoPath + Path.DirectorySeparatorChar + fullPathOurs;
fullPathOurs = Repository.repoPath + Path.DirectorySeparatorChar + fullPathOurs.Replace('/', Path.DirectorySeparatorChar);
if (!fileCreated) throw new Exception(Repository.lastError);
}

if (fileState.conflictType != FileConflictTypes.DeletedByThem)
{
bool fileCreated = Repository.SaveConflictedFile(fileState.filename, FileConflictSources.Theirs, out fullPathTheirs);
fullPathTheirs = Repository.repoPath + Path.DirectorySeparatorChar + fullPathTheirs;
fullPathTheirs = Repository.repoPath + Path.DirectorySeparatorChar + fullPathTheirs.Replace('/', Path.DirectorySeparatorChar);
if (!fileCreated) throw new Exception(Repository.lastError);
}
Debug.pauseGitCommanderStdWrites = false;
Expand Down Expand Up @@ -605,14 +608,17 @@ public static bool ResolveConflict(FileState fileState, bool refresh)
}

// copy base and parse
File.Copy(fullPath, fullPathBase, true);
string baseFile = File.ReadAllText(fullPath);
var match = Regex.Match(baseFile, @"(<<<<<<<\s*\w*[\r\n]*).*(=======[\r\n]*).*(>>>>>>>\s*\w*[\r\n]*)", RegexOptions.Singleline);
if (match.Success && match.Groups.Count == 4)
{
baseFile = baseFile.Replace(match.Groups[1].Value, "").Replace(match.Groups[2].Value, "").Replace(match.Groups[3].Value, "");
File.WriteAllText(fullPathBase, baseFile);
}
else
{
File.Copy(fullPath, fullPathBase, true);
}

// hash base file
byte[] baseHash = null;
Expand Down Expand Up @@ -739,7 +745,7 @@ public static bool ResolveConflict(FileState fileState, bool refresh)
private delegate void DeleteTempDiffFilesMethod();
public static bool OpenDiffTool(FileState fileState)
{
string fullPath = Repository.repoPath + Path.DirectorySeparatorChar + fileState.filename;
string fullPath = Repository.repoPath + Path.DirectorySeparatorChar + fileState.filename.Replace('/', Path.DirectorySeparatorChar);
string fullPathOrig = null;
var DeleteTempDiffFiles = new DeleteTempDiffFilesMethod(delegate ()
{
Expand Down
2 changes: 1 addition & 1 deletion GitItGUI.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

public static class VersionInfo
{
public const string version = "0.2.13";
public const string version = "0.2.14";
#if DEBUG
public const string versionType = version + "b";
#else
Expand Down
2 changes: 1 addition & 1 deletion GitItGUI/VersionInfo.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<VersionInfo>
<AppVersion>0.2.13</AppVersion>
<AppVersion>0.2.14</AppVersion>
</VersionInfo>
2 changes: 1 addition & 1 deletion MergeConflicPicker/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Window xmlns="https://github.com/avaloniaui" Width="400" Height="150" MinWidth="400" MinHeight="150" MaxWidth="400" MaxHeight="150">
<Grid Name="grid" Background="LightGray">
<TextBox Name="fileInConflictTextBox" Height="28" Margin="10,10,10,-10" TextWrapping="Wrap" Text="File in Question..." IsReadOnly="True" VerticalAlignment="Top"/>
<TextBox Name="fileInConflictTextBox" Height="28" Margin="10,10,10,-10" Text="File in Question..." IsReadOnly="True" VerticalAlignment="Top"/>
<Button Name="keepMineButton" Content="Keep Mine" HorizontalAlignment="Left" Margin="10,0,-10,10" VerticalAlignment="Bottom" Width="75"/>
<Button Name="useTheirsButton" Content="Use Theirs" HorizontalAlignment="Right" Margin="-10,0,12,10" VerticalAlignment="Bottom" Width="75"/>
<Button Name="cancelButton" Content="Cancel" Margin="0,0,0,10" VerticalAlignment="Bottom" HorizontalAlignment="Center" Width="205"/>
Expand Down

0 comments on commit f2d0ca2

Please sign in to comment.