repo git: Fix coding style for #823
This commit is contained in:
parent
9ddb9cbb7e
commit
be9f7de13f
|
@ -18,6 +18,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using SparkleLib;
|
using SparkleLib;
|
||||||
|
|
||||||
|
@ -480,7 +481,7 @@ namespace SparkleLib.Git {
|
||||||
|
|
||||||
foreach (string line in lines) {
|
foreach (string line in lines) {
|
||||||
string conflicting_path = line.Substring (3);
|
string conflicting_path = line.Substring (3);
|
||||||
conflicting_path = this.EnsureSpecialCharacters (conflicting_path);
|
conflicting_path = EnsureSpecialCharacters (conflicting_path);
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", Name + " | Conflict type: " + line);
|
SparkleHelpers.DebugInfo ("Git", Name + " | Conflict type: " + line);
|
||||||
|
|
||||||
|
@ -710,8 +711,8 @@ namespace SparkleLib.Git {
|
||||||
file_path = entry_line.Substring (42, tab_pos - 42);
|
file_path = entry_line.Substring (42, tab_pos - 42);
|
||||||
to_file_path = entry_line.Substring (tab_pos + 1);
|
to_file_path = entry_line.Substring (tab_pos + 1);
|
||||||
|
|
||||||
file_path = this.EnsureSpecialCharacters (file_path);
|
file_path = EnsureSpecialCharacters (file_path);
|
||||||
to_file_path = this.EnsureSpecialCharacters (to_file_path);
|
to_file_path = EnsureSpecialCharacters (to_file_path);
|
||||||
|
|
||||||
if (file_path.EndsWith (".empty"))
|
if (file_path.EndsWith (".empty"))
|
||||||
file_path = file_path.Substring (0, file_path.Length - 6);
|
file_path = file_path.Substring (0, file_path.Length - 6);
|
||||||
|
@ -765,47 +766,47 @@ namespace SparkleLib.Git {
|
||||||
return change_sets;
|
return change_sets;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string EnsureSpecialCharacters (string file_path)
|
|
||||||
|
private string EnsureSpecialCharacters (string path)
|
||||||
{
|
{
|
||||||
if (file_path.StartsWith("\""))
|
// The path is quoted if it contains special characters
|
||||||
{
|
if (path.StartsWith ("\""))
|
||||||
System.Diagnostics.Debug.Assert(file_path.Length > 2 && file_path.EndsWith("\""), "unexpected path");
|
path = ResolveSpecialChars (path.Substring (1, path.Length - 2));
|
||||||
file_path = ResolveSpecialChars(file_path.Substring(1, file_path.Length - 2));
|
|
||||||
}
|
return path;
|
||||||
return file_path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolves special characters like \303\244 (ä) to their real character
|
/// Resolves special characters like \303\244 (ä) to their real character
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="file_path"></param>
|
/// <param name="file_path"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string ResolveSpecialChars (string file_path)
|
private string ResolveSpecialChars (string s)
|
||||||
{
|
{
|
||||||
var builder = new System.Text.StringBuilder(file_path.Length);
|
StringBuilder builder = new StringBuilder (s.Length);
|
||||||
var codes = new List<byte>();
|
List<byte> codes = new List<byte> ();
|
||||||
for (int i = 0; i < file_path.Length; i++)
|
|
||||||
{
|
for (int i = 0; i < s.Length; i++) {
|
||||||
while (file_path[i] == '\\'
|
while (s [i] == '\\' &&
|
||||||
&& file_path.Length - i > 3
|
s.Length - i > 3 &&
|
||||||
&& char.IsNumber(file_path[i + 1])
|
char.IsNumber (s [i + 1]) &&
|
||||||
&& char.IsNumber(file_path[i + 2])
|
char.IsNumber (s [i + 2]) &&
|
||||||
&& char.IsNumber(file_path[i + 3]))
|
char.IsNumber (s [i + 3])) {
|
||||||
{
|
|
||||||
codes.Add (Convert.ToByte(file_path.Substring(i + 1, 3), 8));
|
codes.Add (Convert.ToByte (s.Substring (i + 1, 3), 8));
|
||||||
i += 4;
|
i += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codes.Count > 0)
|
if (codes.Count > 0) {
|
||||||
{
|
builder.Append (Encoding.UTF8.GetString (codes.ToArray ()));
|
||||||
builder.Append(System.Text.Encoding.UTF8.GetString (codes.ToArray ()));
|
|
||||||
codes.Clear ();
|
codes.Clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.Append(file_path[i]);
|
builder.Append (s [i]);
|
||||||
}
|
}
|
||||||
return builder.ToString();
|
|
||||||
//System.Text.Encoding.UTF8.
|
return builder.ToString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue