Skip to content

Commit

Permalink
Fix: Fixed issue where checking out a Git branch would sometimes cras…
Browse files Browse the repository at this point in the history
…h the app (#12805)
  • Loading branch information
ferrariofilippo authored Jun 30, 2023
1 parent 5441b55 commit 6632a87
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Files.App/Helpers/GitHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,14 @@ public static GitItemModel GetGitInformationForItem(Repository repository, strin
private static void CheckoutRemoteBranch(Repository repository, Branch branch)
{
var uniqueName = branch.FriendlyName.Substring(END_OF_ORIGIN_PREFIX);

// TODO: This is a temp fix to avoid an issue where Files would create many branches in a loop
if (repository.Branches.Any(b => !b.IsRemote && b.FriendlyName == uniqueName))
return;

var discriminator = 0;
while (repository.Branches.Any(b => !b.IsRemote && b.FriendlyName == uniqueName))
uniqueName = $"{branch.FriendlyName}_{++discriminator}";
//var discriminator = 0;
//while (repository.Branches.Any(b => !b.IsRemote && b.FriendlyName == uniqueName))
// uniqueName = $"{branch.FriendlyName}_{++discriminator}";

var newBranch = repository.CreateBranch(uniqueName, branch.Tip);
repository.Branches.Update(newBranch, b => b.TrackedBranch = branch.CanonicalName);
Expand Down

0 comments on commit 6632a87

Please sign in to comment.