Skip to content

Commit 7dd95b8

Browse files
Oded WelgreenOded Welgreen
Oded Welgreen
authored and
Oded Welgreen
committed
Remove CultureInfo parameter from LibGit2sharpException ctor and use always InvariantCulture
1 parent ac4c7d9 commit 7dd95b8

17 files changed

+31
-56
lines changed

LibGit2Sharp/AmbiguousSpecificationException.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ public AmbiguousSpecificationException(string message)
2727
/// <summary>
2828
/// Initializes a new instance of the <see cref="AmbiguousSpecificationException"/> class with a specified error message.
2929
/// </summary>
30-
/// <param name="cultureInfo">An object that supplies culture-specific formatting information.</param>
3130
/// <param name="format">A composite format string for use in <see cref="String.Format(IFormatProvider, string, object[])"/>.</param>
3231
/// <param name="args">An object array that contains zero or more objects to format.</param>
33-
public AmbiguousSpecificationException(CultureInfo cultureInfo, string format, params object[] args)
34-
: base(String.Format(cultureInfo, format, args))
32+
public AmbiguousSpecificationException(string format, params object[] args)
33+
: base(String.Format(format, args))
3534
{
3635
}
3736

LibGit2Sharp/BranchCollection.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ public virtual Branch Rename(Branch branch, string newName, bool allowOverwrite)
263263

264264
if (branch.IsRemote)
265265
{
266-
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
267-
"Cannot rename branch '{0}'. It's a remote tracking branch.",
266+
throw new LibGit2SharpException("Cannot rename branch '{0}'. It's a remote tracking branch.",
268267
branch.FriendlyName);
269268
}
270269

LibGit2Sharp/Configuration.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,7 @@ private ConfigurationSafeHandle RetrieveConfigurationHandle(ConfigurationLevel l
693693

694694
if (handle == null && throwIfStoreHasNotBeenFound)
695695
{
696-
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
697-
"No {0} configuration file has been found.",
696+
throw new LibGit2SharpException("No {0} configuration file has been found.",
698697
Enum.GetName(typeof(ConfigurationLevel), level));
699698
}
700699

LibGit2Sharp/Core/Proxy.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,9 +1432,8 @@ public static IntPtr git_odb_backend_malloc(IntPtr backend, UIntPtr len)
14321432

14331433
if (IntPtr.Zero == toReturn)
14341434
{
1435-
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
1436-
"Unable to allocate {0} bytes; out of memory",
1437-
len,
1435+
throw new LibGit2SharpException("Unable to allocate {0} bytes; out of memory",
1436+
len,
14381437
GitErrorCode.Error,
14391438
GitErrorCategory.NoMemory);
14401439
}
@@ -2556,8 +2555,7 @@ public static Tuple<GitObjectSafeHandle, ReferenceSafeHandle> git_revparse_ext(R
25562555
return null;
25572556

25582557
case (int)GitErrorCode.Ambiguous:
2559-
throw new AmbiguousSpecificationException(CultureInfo.InvariantCulture,
2560-
"Provided abbreviated ObjectId '{0}' is too short.",
2558+
throw new AmbiguousSpecificationException("Provided abbreviated ObjectId '{0}' is too short.",
25612559
objectish);
25622560

25632561
default:
@@ -2778,8 +2776,7 @@ public static FileStatus git_status_file(RepositorySafeHandle repo, FilePath pat
27782776
return FileStatus.Nonexistent;
27792777

27802778
case (int)GitErrorCode.Ambiguous:
2781-
throw new AmbiguousSpecificationException(CultureInfo.InvariantCulture,
2782-
"More than one file matches the pathspec '{0}'. " +
2779+
throw new AmbiguousSpecificationException("More than one file matches the pathspec '{0}'. " +
27832780
"You can either force a literal path evaluation " +
27842781
"(GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH), or use git_status_foreach().",
27852782
path);

LibGit2Sharp/Diff.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ private static T BuildDiffResult<T>(DiffSafeHandle diff) where T : class, IDiffR
109109

110110
if (!ChangesBuilders.TryGetValue(typeof(T), out builder))
111111
{
112-
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
113-
"User-defined types passed to Compare are not supported. Supported values are: {0}",
112+
throw new LibGit2SharpException("User-defined types passed to Compare are not supported. Supported values are: {0}",
114113
string.Join(", ", ChangesBuilders.Keys.Select(x => x.Name)));
115114
}
116115

LibGit2Sharp/GitObject.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ internal static GitObject BuildFrom(Repository repo, ObjectId id, GitObjectType
7777
return new Blob(repo, id);
7878

7979
default:
80-
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
81-
"Unexpected type '{0}' for object '{1}'.",
80+
throw new LibGit2SharpException("Unexpected type '{0}' for object '{1}'.",
8281
type,
8382
id);
8483
}

LibGit2Sharp/LibGit2SharpException.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ public LibGit2SharpException(string message, Exception innerException)
3737
/// <summary>
3838
/// Initializes a new instance of the <see cref="LibGit2SharpException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
3939
/// </summary>
40-
/// <param name="cultureInfo">An object that supplies culture-specific formatting information.</param>
4140
/// <param name="format">A composite format string for use in <see cref="String.Format(IFormatProvider, string, object[])"/>.</param>
4241
/// <param name="args">An object array that contains zero or more objects to format.</param>
43-
public LibGit2SharpException(CultureInfo cultureInfo, string format, params object[] args)
44-
: base(String.Format(cultureInfo, format, args))
42+
public LibGit2SharpException(string format, params object[] args)
43+
: base(String.Format(CultureInfo.InvariantCulture, format, args))
4544
{
4645
}
4746

LibGit2Sharp/Network.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,7 @@ public virtual void Push(
399399
{
400400
if (string.IsNullOrEmpty(branch.UpstreamBranchCanonicalName))
401401
{
402-
throw new LibGit2SharpException(
403-
CultureInfo.InvariantCulture,
404-
"The branch '{0}' (\"{1}\") that you are trying to push does not track an upstream branch.",
402+
throw new LibGit2SharpException("The branch '{0}' (\"{1}\") that you are trying to push does not track an upstream branch.",
405403
branch.FriendlyName, branch.CanonicalName);
406404
}
407405
}

LibGit2Sharp/Rebase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, I
8181

8282
if (this.repository.Info.CurrentOperation != CurrentOperation.None)
8383
{
84-
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
85-
"A {0} operation is already in progress.",
84+
throw new LibGit2SharpException("A {0} operation is already in progress.",
8685
this.repository.Info.CurrentOperation);
8786
}
8887

LibGit2Sharp/RebaseOperationImpl.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ private static RebaseResult RunRebaseStep(RebaseSafeHandle rebaseOperationHandle
119119
case RebaseStepOperation.Fixup:
120120
case RebaseStepOperation.Reword:
121121
// These operations are not yet supported by lg2.
122-
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
123-
"Rebase Operation Type ({0}) is not currently supported in LibGit2Sharp.",
122+
throw new LibGit2SharpException("Rebase Operation Type ({0}) is not currently supported in LibGit2Sharp.",
124123
stepToApplyInfo.Type);
125124
default:
126125
throw new ArgumentException(string.Format(

LibGit2Sharp/Reference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ internal static T BuildFromPtr<T>(ReferenceSafeHandle handle, Repository repo) w
5959
break;
6060

6161
default:
62-
throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Unable to build a new reference from a type '{0}'.", type);
62+
throw new LibGit2SharpException("Unable to build a new reference from a type '{0}'.", type);
6363
}
6464

6565
return reference as T;

LibGit2Sharp/ReferenceCollection.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,7 @@ public virtual Reference Rename(string currentName, string newName,
404404

405405
if (reference == null)
406406
{
407-
throw new LibGit2SharpException(
408-
CultureInfo.InvariantCulture,
409-
"Reference '{0}' doesn't exist. One cannot move a non existing reference.",
407+
throw new LibGit2SharpException("Reference '{0}' doesn't exist. One cannot move a non existing reference.",
410408
currentName);
411409
}
412410

@@ -547,8 +545,7 @@ public virtual Reference UpdateTarget(string name, string canonicalRefNameOrObje
547545
return UpdateTarget(symbolicReference, targetRef, logMessage);
548546
}
549547

550-
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
551-
"Reference '{0}' has an unexpected type ('{1}').",
548+
throw new LibGit2SharpException("Reference '{0}' has an unexpected type ('{1}').",
552549
name,
553550
reference.GetType());
554551
}

LibGit2Sharp/RemoveFromIndexException.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ public RemoveFromIndexException(string message)
2727
/// <summary>
2828
/// Initializes a new instance of the <see cref="LibGit2SharpException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
2929
/// </summary>
30-
/// <param name="cultureInfo">An object that supplies culture-specific formatting information.</param>
3130
/// <param name="format">A composite format string for use in <see cref="String.Format(IFormatProvider, string, object[])"/>.</param>
3231
/// <param name="args">An object array that contains zero or more objects to format.</param>
33-
public RemoveFromIndexException(CultureInfo cultureInfo, string format, params object[] args)
34-
: base(cultureInfo, format, args)
32+
public RemoveFromIndexException(string format, params object[] args)
33+
: base(format, args)
3534
{
3635
}
3736

LibGit2Sharp/Repository.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,7 @@ public Branch Checkout(Branch branch, CheckoutOptions options)
900900
// Make sure this is not an unborn branch.
901901
if (branch.Tip == null)
902902
{
903-
throw new UnbornBranchException(CultureInfo.InvariantCulture,
904-
"The tip of branch '{0}' is null. There's nothing to checkout.",
903+
throw new UnbornBranchException("The tip of branch '{0}' is null. There's nothing to checkout.",
905904
branch.FriendlyName);
906905
}
907906

@@ -1858,8 +1857,7 @@ public void Move(IEnumerable<string> sourcePaths, IEnumerable<string> destinatio
18581857
FileStatus sourceStatus = keyValuePair.Key.Item2;
18591858
if (sourceStatus.HasAny(new Enum[] { FileStatus.Nonexistent, FileStatus.DeletedFromIndex, FileStatus.NewInWorkdir, FileStatus.DeletedFromWorkdir }))
18601859
{
1861-
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
1862-
"Unable to move file '{0}'. Its current status is '{1}'.",
1860+
throw new LibGit2SharpException("Unable to move file '{0}'. Its current status is '{1}'.",
18631861
sourcePath,
18641862
sourceStatus);
18651863
}
@@ -1870,8 +1868,7 @@ public void Move(IEnumerable<string> sourcePaths, IEnumerable<string> destinatio
18701868
continue;
18711869
}
18721870

1873-
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
1874-
"Unable to overwrite file '{0}'. Its current status is '{1}'.",
1871+
throw new LibGit2SharpException("Unable to overwrite file '{0}'. Its current status is '{1}'.",
18751872
destPath,
18761873
desStatus);
18771874
}
@@ -2106,8 +2103,7 @@ private IEnumerable<string> RemoveStagedItems(IEnumerable<string> paths, bool re
21062103
status.HasFlag(FileStatus.ModifiedInIndex) ||
21072104
status.HasFlag(FileStatus.NewInIndex)))
21082105
{
2109-
throw new RemoveFromIndexException(CultureInfo.InvariantCulture,
2110-
"Unable to remove file '{0}', as it has changes staged in the index. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.",
2106+
throw new RemoveFromIndexException("Unable to remove file '{0}', as it has changes staged in the index. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.",
21112107
treeEntryChanges.Path);
21122108
}
21132109
removed.Add(RemoveFromIndex(treeEntryChanges.Path));
@@ -2116,22 +2112,19 @@ private IEnumerable<string> RemoveStagedItems(IEnumerable<string> paths, bool re
21162112
case ChangeKind.Modified:
21172113
if (status.HasFlag(FileStatus.ModifiedInWorkdir) && status.HasFlag(FileStatus.ModifiedInIndex))
21182114
{
2119-
throw new RemoveFromIndexException(CultureInfo.InvariantCulture,
2120-
"Unable to remove file '{0}', as it has staged content different from both the working directory and the HEAD.",
2115+
throw new RemoveFromIndexException("Unable to remove file '{0}', as it has staged content different from both the working directory and the HEAD.",
21212116
treeEntryChanges.Path);
21222117
}
21232118
if (removeFromWorkingDirectory)
21242119
{
2125-
throw new RemoveFromIndexException(CultureInfo.InvariantCulture,
2126-
"Unable to remove file '{0}', as it has local modifications. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.",
2120+
throw new RemoveFromIndexException("Unable to remove file '{0}', as it has local modifications. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.",
21272121
treeEntryChanges.Path);
21282122
}
21292123
removed.Add(RemoveFromIndex(treeEntryChanges.Path));
21302124
continue;
21312125

21322126
default:
2133-
throw new RemoveFromIndexException(CultureInfo.InvariantCulture,
2134-
"Unable to remove file '{0}'. Its current status is '{1}'.",
2127+
throw new RemoveFromIndexException("Unable to remove file '{0}'. Its current status is '{1}'.",
21352128
treeEntryChanges.Path,
21362129
treeEntryChanges.Status);
21372130
}

LibGit2Sharp/RepositoryExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ internal static IEnumerable<ObjectId> Committishes(this Repository repo, object
485485

486486
if (throwIfNotFound)
487487
{
488-
throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Unexpected kind of identifier '{0}'.", identifier);
488+
throw new LibGit2SharpException("Unexpected kind of identifier '{0}'.", identifier);
489489
}
490490

491491
yield return null;

LibGit2Sharp/SubmoduleCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ internal T Lookup<T>(string name, Func<SubmoduleSafeHandle, T> selector, bool th
160160

161161
if (throwIfNotFound)
162162
{
163-
throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Submodule lookup failed for '{0}'.", name);
163+
throw new LibGit2SharpException("Submodule lookup failed for '{0}'.", name);
164164
}
165165

166166
return default(T);

LibGit2Sharp/UnbornBranchException.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ public UnbornBranchException(string message)
2828
/// <summary>
2929
/// Initializes a new instance of the <see cref="UnbornBranchException"/> class with a specified error message.
3030
/// </summary>
31-
/// <param name="cultureInfo">An object that supplies culture-specific formatting information.</param>
3231
/// <param name="format">A composite format string for use in <see cref="String.Format(IFormatProvider, string, object[])"/>.</param>
3332
/// <param name="args">An object array that contains zero or more objects to format.</param>
34-
public UnbornBranchException(CultureInfo cultureInfo, string format, params object[] args)
35-
: base(cultureInfo, format, args)
33+
public UnbornBranchException(string format, params object[] args)
34+
: base(format, args)
3635
{ }
3736

3837
/// <summary>

0 commit comments

Comments
 (0)