Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7ebd71d

Browse files
committedJul 31, 2018
Formatting, typos, annotations
1 parent 87f3f11 commit 7ebd71d

File tree

12 files changed

+73
-58
lines changed

12 files changed

+73
-58
lines changed
 

‎GitCommands/Git/GitCommandHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ public static GitSubmoduleStatus ParseSubmoduleStatus(string text, GitModule mod
761761
// We are looking for lines resembling:
762762
//
763763
// -Subproject commit bfef4454fc51e345051ee5bf66686dc28deed627
764-
// +Subproject commit 8b20498b954609770205c2cc794b868b4ac3ee69
764+
// +Subproject commit 8b20498b954609770205c2cc794b868b4ac3ee69-dirty
765765

766766
if (!line.Contains("Subproject"))
767767
{

‎GitCommands/Git/GitModule.cs

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,19 +2082,6 @@ public string GetNextRebasePatch()
20822082
return File.Exists(file) ? File.ReadAllText(file).Trim() : "";
20832083
}
20842084

2085-
private static string AppendQuotedString(string str1, string str2)
2086-
{
2087-
var m1 = QuotedText.Match(str1);
2088-
var m2 = QuotedText.Match(str2);
2089-
if (!m1.Success || !m2.Success)
2090-
{
2091-
return str1 + str2;
2092-
}
2093-
2094-
Debug.Assert(m1.Groups[1].Value == m2.Groups[1].Value, "m1.Groups[1].Value == m2.Groups[1].Value");
2095-
return str1.Substring(0, str1.Length - 2) + m2.Groups[2].Value + "?=";
2096-
}
2097-
20982085
private static string DecodeString(string str)
20992086
{
21002087
// decode QuotedPrintable text using .NET internal decoder
@@ -2252,6 +2239,19 @@ public IReadOnlyList<PatchFile> GetRebasePatchFiles()
22522239
}
22532240

22542241
return patchFiles;
2242+
2243+
string AppendQuotedString(string str1, string str2)
2244+
{
2245+
var m1 = QuotedText.Match(str1);
2246+
var m2 = QuotedText.Match(str2);
2247+
if (!m1.Success || !m2.Success)
2248+
{
2249+
return str1 + str2;
2250+
}
2251+
2252+
Debug.Assert(m1.Groups[1].Value == m2.Groups[1].Value, "m1.Groups[1].Value == m2.Groups[1].Value");
2253+
return str1.Substring(0, str1.Length - 2) + m2.Groups[2].Value + "?=";
2254+
}
22552255
}
22562256

22572257
public string CommitCmd(bool amend, bool signOff = false, string author = "", bool useExplicitCommitMessage = true, bool noVerify = false, bool gpgSign = false, string gpgKeyId = "")
@@ -2856,7 +2856,8 @@ public string GetCurrentRemote()
28562856
public string GetRemoteBranch(string branch)
28572857
{
28582858
string remote = GetSetting(string.Format(SettingKeyString.BranchRemote, branch));
2859-
string merge = GetSetting(string.Format("branch.{0}.merge", branch));
2859+
string merge = GetSetting($"branch.{branch}.merge");
2860+
28602861
if (string.IsNullOrEmpty(remote) || string.IsNullOrEmpty(merge))
28612862
{
28622863
return "";
@@ -3139,25 +3140,41 @@ public string GetTagMessage(string tag)
31393140

31403141
tag = tag.Trim();
31413142

3142-
string info = RunGitCmd("tag -l -n10 " + tag, SystemEncoding);
3143+
var output = RunGitCmd("tag -l -n10 " + tag, SystemEncoding);
31433144

3144-
if (IsGitErrorMessage(info))
3145+
/*
3146+
* $ git tag -l -n10 1.50
3147+
* 1.50 Added close checkbox to process dialog
3148+
*
3149+
* $ git tag -l -n10 1.57
3150+
* 1.57 Minor changes.
3151+
*
3152+
* Packed with Git-1.6.1 to avoid a bug in Git-1.6.2
3153+
* When installing 64bit version, both 32bit and 64bit shell extensions will be registered
3154+
* Application settings are saved when closing settings dialog instead of when application exits
3155+
* Revert commit handles merge conflicts better
3156+
* Diff in browse dialog now shows the diff between revisions if 2 revisions are selected
3157+
* Bug solved: files in diff viewer are not shown correctly when 2 revisions are selected
3158+
* Format path dialog improved
3159+
*/
3160+
3161+
if (IsGitErrorMessage(output))
31453162
{
31463163
return null;
31473164
}
31483165

3149-
if (!info.StartsWith(tag))
3166+
if (!output.StartsWith(tag))
31503167
{
31513168
return null;
31523169
}
31533170

3154-
info = info.Substring(tag.Length).Trim();
3155-
if (info.Length == 0)
3171+
output = output.Substring(tag.Length).Trim();
3172+
if (output.Length == 0)
31563173
{
31573174
return null;
31583175
}
31593176

3160-
return info;
3177+
return output;
31613178
}
31623179

31633180
/// <summary>

‎GitCommands/Patches/PatchManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static byte[] GetSelectedLinesAsNewPatch([NotNull] GitModule module, [Not
137137
body = body.Replace("\r", "");
138138
}
139139

140-
if (header == null || body == null)
140+
if (body == null)
141141
{
142142
return null;
143143
}
@@ -312,9 +312,8 @@ public string ToIndexPatch(ref int addedCount, ref int removedCount, ref bool we
312312
diff = diff.Combine("\n", line.Text);
313313
}
314314

315-
for (int i = 0; i < RemovedLines.Count; i++)
315+
foreach (var removedLine in RemovedLines)
316316
{
317-
PatchLine removedLine = RemovedLines[i];
318317
selectedLastLine = removedLine.Selected;
319318
if (removedLine.Selected)
320319
{
@@ -397,6 +396,7 @@ public string ToIndexPatch(ref int addedCount, ref int removedCount, ref bool we
397396
}
398397

399398
// patch base is changed file
399+
[CanBeNull]
400400
public string ToResetWorkTreeLinesPatch(ref int addedCount, ref int removedCount, ref bool wereSelectedLines)
401401
{
402402
string diff = null;

‎GitCommands/Statistics/CommitCounter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ private static (Dictionary<string, int> commitsPerContributor, int totalCommits)
2424
.Split('\n');
2525

2626
return ParseCommitsPerContributor(unformattedCommitsPerContributor);
27+
28+
string GetDateParameter(DateTime sinceDate, string paramName)
29+
{
30+
return $" --{paramName}=\"{sinceDate:yyyy-MM-dd hh:mm:ss}\"";
31+
}
2732
}
2833

2934
private static (Dictionary<string, int> commitsPerContributor, int totalCommits)
@@ -66,10 +71,5 @@ private static (Dictionary<string, int> commitsPerContributor, int totalCommits)
6671

6772
return (commitsPerContributor, totalCommits);
6873
}
69-
70-
private static string GetDateParameter(DateTime sinceDate, string paramName)
71-
{
72-
return string.Format(" --{1}=\"{0}\"", sinceDate.ToString("yyyy-MM-dd hh:mm:ss"), paramName);
73-
}
7474
}
7575
}

‎GitExtensions.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
<s:Boolean x:Key="/Default/UserDictionary/Words/=gitmodule/@EntryIndexedValue">True</s:Boolean>
8080
<s:Boolean x:Key="/Default/UserDictionary/Words/=gitreview/@EntryIndexedValue">True</s:Boolean>
8181
<s:Boolean x:Key="/Default/UserDictionary/Words/=gitrevisions/@EntryIndexedValue">True</s:Boolean>
82+
<s:Boolean x:Key="/Default/UserDictionary/Words/=git_0027s/@EntryIndexedValue">True</s:Boolean>
8283
<s:Boolean x:Key="/Default/UserDictionary/Words/=gmail/@EntryIndexedValue">True</s:Boolean>
8384
<s:Boolean x:Key="/Default/UserDictionary/Words/=gnore_002Du/@EntryIndexedValue">True</s:Boolean>
8485
<s:Boolean x:Key="/Default/UserDictionary/Words/=guitool/@EntryIndexedValue">True</s:Boolean>

‎GitUI/CommandsDialogs/FormCommit.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,15 +1797,11 @@ private void Stage(IReadOnlyList<GitItemStatus> items)
17971797

17981798
var files = new List<GitItemStatus>();
17991799

1800-
foreach (var gitItemStatus in items)
1800+
foreach (var item in items)
18011801
{
18021802
toolStripProgressBar1.Value = Math.Min(toolStripProgressBar1.Maximum - 1, toolStripProgressBar1.Value + 1);
1803-
if (gitItemStatus.Name.EndsWith("/"))
1804-
{
1805-
gitItemStatus.Name = gitItemStatus.Name.TrimEnd('/');
1806-
}
1807-
1808-
files.Add(gitItemStatus);
1803+
item.Name = item.Name.TrimEnd('/');
1804+
files.Add(item);
18091805
}
18101806

18111807
bool wereErrors = false;
@@ -1965,7 +1961,7 @@ private void ResetSoftClick(object sender, EventArgs e)
19651961
}
19661962
else
19671963
{
1968-
Directory.Delete(path, true);
1964+
Directory.Delete(path, recursive: true);
19691965
}
19701966
}
19711967
catch (IOException)

‎GitUI/CommandsDialogs/FormPush.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ private void LoadMultiBranchViewData(string remote)
954954
}
955955
else
956956
{
957-
// use remote branches from the git's local database if there were problems with receiving branches from the remote server
957+
// use remote branches from git's local database if there were problems with receiving branches from the remote server
958958
remoteHeads = Module.GetRemoteBranches().Where(r => r.Remote == remote).ToList();
959959
}
960960

‎GitUI/Editor/FileViewer.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,17 +1194,14 @@ private void CopyNotStartingWith(char startChar)
11941194
int pos = noSelection ? 0 : _internalFileViewer.GetSelectionPosition();
11951195
string fileText = _internalFileViewer.GetText();
11961196

1197-
if (pos > 0)
1197+
if (pos > 0 && fileText[pos - 1] != '\n')
11981198
{
1199-
if (fileText[pos - 1] != '\n')
1200-
{
1201-
code = " " + code;
1202-
}
1199+
code = " " + code;
12031200
}
12041201

1205-
IEnumerable<string> lines = code.Split('\n');
1206-
lines = lines.Where(s => s.Length == 0 || s[0] != startChar || (s.Length > 2 && s[1] == s[0] && s[2] == s[0]));
1207-
int hpos = fileText.IndexOf("\n@@");
1202+
var lines = code.Split('\n')
1203+
.Where(s => s.Length == 0 || s[0] != startChar || (s.Length > 2 && s[1] == s[0] && s[2] == s[0]));
1204+
var hpos = fileText.IndexOf("\n@@");
12081205

12091206
// if header is selected then don't remove diff extra chars
12101207
if (hpos <= pos)

‎GitUI/FormStatus.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,12 @@ public async Task SetProgressAsync(string text)
9191
int index = text.LastIndexOf('%');
9292
if (index > 4 && int.TryParse(text.Substring(index - 3, 3), out var progressValue) && progressValue >= 0)
9393
{
94-
if (ProgressBar.Style != ProgressBarStyle.Blocks)
95-
{
96-
ProgressBar.Style = ProgressBarStyle.Blocks;
97-
}
98-
94+
ProgressBar.Style = ProgressBarStyle.Blocks;
9995
ProgressBar.Value = Math.Min(100, progressValue);
10096
TaskbarProgress.SetProgress(TaskbarProgressBarState.Normal, progressValue, 100);
10197
}
10298

103-
// Show last progress message in the title, unless it's showin in the control body already
99+
// Show last progress message in the title, unless it's showing in the control body already
104100
if (!ConsoleOutput.IsDisplayingFullProcessOutput)
105101
{
106102
Text = text;

‎GitUI/UserControls/RevisionGrid/FormQuickGitRefSelector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void Init(Action action, IReadOnlyList<IGitRef> refs)
8686
{
8787
// what is this magic number "MaxVisibleItemsWithoutScroll + 0.5"?
8888
// we are limiting number of visible items in the listbox before enabling vscroll, this is to reduce the risk of not fitting on user's screen.
89-
// when listbox.IntergralHeight=true, the listbox automatically calculates its size and only show full items (i.e. you can't render it
89+
// when listbox.IntegralHeight=true, the listbox automatically calculates its size and only show full items (i.e. you can't render it
9090
// at 20px high if the ItemHeight=13px, it can only be 13, 26, 39 etc (NB: slightly more if you account for the furniture)).
9191
// listbox.PreferredHeight returns the height of the listbox showing all items.
9292
// for some strange reason, MaxVisibleItemsWithoutScroll*listbox.ItemHeight renders the listbox showing MaxVisibleItemsWithoutScroll-1 items.

‎Plugins/GitFlow/GitFlowForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ private static bool TryExtractBranchFromHead(string currentRef, out string branc
9494
{
9595
foreach (Branch branch in Enum.GetValues(typeof(Branch)))
9696
{
97-
var startRef = branch.ToString("G") + "/";
97+
var startRef = branch + "/";
9898
if (currentRef.StartsWith(startRef))
9999
{
100-
branchType = branch.ToString("G");
100+
branchType = branch.ToString();
101101
branchName = currentRef.Substring(startRef.Length);
102102
return true;
103103
}

‎ResourceManager/LinkFactory.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,23 @@ public string ParseLink(string linkText)
9191
return linkUri;
9292
}
9393

94-
string uriCandidate = linkText;
95-
while (uriCandidate != null)
94+
var uriCandidate = linkText;
95+
96+
while (true)
9697
{
9798
if (Uri.TryCreate(uriCandidate, UriKind.Absolute, out var uri))
9899
{
99100
return uri.AbsoluteUri;
100101
}
101102

102-
uriCandidate = uriCandidate.SkipStr("#");
103+
var idx = uriCandidate.IndexOf('#');
104+
105+
if (idx == -1)
106+
{
107+
break;
108+
}
109+
110+
uriCandidate = uriCandidate.Substring(idx + 1);
103111
}
104112

105113
return linkText;

0 commit comments

Comments
 (0)
Please sign in to comment.