@@ -556,7 +556,12 @@ void GetUserConfig(const FString& InPathToGitBinary, const FString& InRepository
556
556
557
557
bool GetBranchName (const FString& InPathToGitBinary, const FString& InRepositoryRoot, FString& OutBranchName)
558
558
{
559
- const FGitSourceControlProvider& Provider = FGitSourceControlModule::Get ().GetProvider ();
559
+ const FGitSourceControlModule* GitSourceControl = FGitSourceControlModule::GetThreadSafe ();
560
+ if (!GitSourceControl)
561
+ {
562
+ return false ;
563
+ }
564
+ const FGitSourceControlProvider& Provider = GitSourceControl->GetProvider ();
560
565
if (!Provider.GetBranchName ().IsEmpty ())
561
566
{
562
567
OutBranchName = Provider.GetBranchName ();
@@ -597,7 +602,12 @@ bool GetBranchName(const FString& InPathToGitBinary, const FString& InRepository
597
602
598
603
bool GetRemoteBranchName (const FString& InPathToGitBinary, const FString& InRepositoryRoot, FString& OutBranchName)
599
604
{
600
- const FGitSourceControlProvider& Provider = FGitSourceControlModule::Get ().GetProvider ();
605
+ const FGitSourceControlModule* GitSourceControl = FGitSourceControlModule::GetThreadSafe ();
606
+ if (!GitSourceControl)
607
+ {
608
+ return false ;
609
+ }
610
+ const FGitSourceControlProvider& Provider = GitSourceControl->GetProvider ();
601
611
if (!Provider.GetRemoteBranchName ().IsEmpty ())
602
612
{
603
613
OutBranchName = Provider.GetRemoteBranchName ();
@@ -813,6 +823,7 @@ class FGitLfsLocksParser
813
823
// Filename ID (or we expect it to be the username, but it's empty, or is the ID, we have to assume it's the current user)
814
824
if (Informations.Num () == 2 || Informations[1 ].IsEmpty () || Informations[1 ].StartsWith (TEXT (" ID:" )))
815
825
{
826
+ // TODO: thread safety
816
827
LockUser = FGitSourceControlModule::Get ().GetProvider ().GetLockUser ();
817
828
}
818
829
// Filename Username ID
@@ -1123,8 +1134,13 @@ R Content/Textures/T_Perlin_Noise_M.uasset -> Content/Textures/T_Perlin_Noise_M
1123
1134
static void ParseFileStatusResult (const FString& InPathToGitBinary, const FString& InRepositoryRoot, const bool InUsingLfsLocking, const TSet<FString>& InFiles,
1124
1135
const TMap<FString, FString>& InResults, TMap<FString, FGitSourceControlState>& OutStates)
1125
1136
{
1126
- FGitSourceControlModule& GitSourceControl = FGitSourceControlModule::Get ();
1127
- const FString& LfsUserName = GitSourceControl.GetProvider ().GetLockUser ();
1137
+ FGitSourceControlModule* GitSourceControl = FGitSourceControlModule::GetThreadSafe ();
1138
+ if (!GitSourceControl)
1139
+ {
1140
+ return ;
1141
+ }
1142
+ FGitSourceControlProvider& Provider = GitSourceControl->GetProvider ();
1143
+ const FString& LfsUserName = Provider.GetLockUser ();
1128
1144
1129
1145
TMap<FString, FString> LockedFiles;
1130
1146
TMap<FString, FString> Results = InResults;
@@ -1280,7 +1296,13 @@ void CheckRemote(const FString& InPathToGitBinary, const FString& InRepositoryRo
1280
1296
// We can obtain a list of files that were modified between our remote branches and HEAD. Assumes that fetch has been run to get accurate info.
1281
1297
1282
1298
// Gather valid remote branches
1283
- const TArray<FString> StatusBranches = FGitSourceControlModule::Get ().GetProvider ().GetStatusBranchNames ();
1299
+ FGitSourceControlModule* GitSourceControl = FGitSourceControlModule::GetThreadSafe ();
1300
+ if (!GitSourceControl)
1301
+ {
1302
+ return ;
1303
+ }
1304
+ FGitSourceControlProvider& Provider = GitSourceControl->GetProvider ();
1305
+ const TArray<FString> StatusBranches = Provider.GetStatusBranchNames ();
1284
1306
1285
1307
TSet<FString> BranchesToDiff{ StatusBranches };
1286
1308
@@ -1339,7 +1361,7 @@ void CheckRemote(const FString& InPathToGitBinary, const FString& InRepositoryRo
1339
1361
// Check if there's newer binaries pending on this branch
1340
1362
if (bCurrentBranch && (NewerFileName == TEXT (" .checksum" ) || NewerFileName.StartsWith (" Binaries" )))
1341
1363
{
1342
- FGitSourceControlModule::Get (). GetProvider () .bPendingRestart = true ;
1364
+ Provider .bPendingRestart = true ;
1343
1365
}
1344
1366
continue ;
1345
1367
}
@@ -1384,7 +1406,7 @@ bool GetAllLocks(const FString& InRepositoryRoot, const FString& GitBinaryFallba
1384
1406
const FTimespan CacheTimeElapsed = CurrentTime - FGitLockedFilesCache::LastUpdated;
1385
1407
bCacheExpired = CacheTimeElapsed > CacheLimit;
1386
1408
}
1387
- bool bResult;
1409
+ bool bResult = false ;
1388
1410
if (bCacheExpired)
1389
1411
{
1390
1412
// Our cache expired, or they asked us to expire cache. Query locks directly from the remote server.
@@ -1411,42 +1433,51 @@ bool GetAllLocks(const FString& InRepositoryRoot, const FString& GitBinaryFallba
1411
1433
TArray<FString> Params;
1412
1434
Params.Add (TEXT (" --cached" ));
1413
1435
1414
- const FString& LockUser = FGitSourceControlModule::Get ().GetProvider ().GetLockUser ();
1415
-
1416
- Results.Reset ();
1417
- bResult = RunLFSCommand (TEXT (" locks" ), InRepositoryRoot, GitBinaryFallback, Params, FGitSourceControlModule::GetEmptyStringArray (), Results, OutErrorMessages);
1418
- for (const FString& Result : Results)
1436
+ FGitSourceControlModule* GitSourceControl = FGitSourceControlModule::GetThreadSafe ();
1437
+ if (!GitSourceControl)
1419
1438
{
1420
- FGitLfsLocksParser LockFile (InRepositoryRoot, Result);
1421
- #if UE_BUILD_DEBUG && GIT_DEBUG_STATUS
1422
- UE_LOG (LogSourceControl, Log, TEXT (" LockedFile(%s, %s)" ), *LockFile.LocalFilename , *LockFile.LockUser );
1423
- #endif
1424
- // Only update remote locks
1425
- if (LockFile.LockUser != LockUser)
1439
+ bResult = false ;
1440
+ }
1441
+ else
1442
+ {
1443
+ FGitSourceControlProvider& Provider = GitSourceControl->GetProvider ();
1444
+ const FString& LockUser = Provider.GetLockUser ();
1445
+
1446
+ Results.Reset ();
1447
+ bResult = RunLFSCommand (TEXT (" locks" ), InRepositoryRoot, GitBinaryFallback, Params, FGitSourceControlModule::GetEmptyStringArray (), Results, OutErrorMessages);
1448
+ for (const FString& Result : Results)
1426
1449
{
1427
- OutLocks.Add (MoveTemp (LockFile.LocalFilename ), MoveTemp (LockFile.LockUser ));
1450
+ FGitLfsLocksParser LockFile (InRepositoryRoot, Result);
1451
+ #if UE_BUILD_DEBUG && GIT_DEBUG_STATUS
1452
+ UE_LOG (LogSourceControl, Log, TEXT (" LockedFile(%s, %s)" ), *LockFile.LocalFilename , *LockFile.LockUser );
1453
+ #endif
1454
+ // Only update remote locks
1455
+ if (LockFile.LockUser != LockUser)
1456
+ {
1457
+ OutLocks.Add (MoveTemp (LockFile.LocalFilename ), MoveTemp (LockFile.LockUser ));
1458
+ }
1428
1459
}
1429
- }
1430
- // Get the latest local state of our own locks
1431
- Params.Reset (1 );
1432
- Params.Add (TEXT (" --local" ));
1460
+ // Get the latest local state of our own locks
1461
+ Params.Reset (1 );
1462
+ Params.Add (TEXT (" --local" ));
1433
1463
1434
- Results.Reset ();
1435
- bResult &= RunLFSCommand (TEXT (" locks" ), InRepositoryRoot, GitBinaryFallback, Params, FGitSourceControlModule::GetEmptyStringArray (), Results, OutErrorMessages);
1436
- for (const FString& Result : Results)
1437
- {
1438
- FGitLfsLocksParser LockFile (InRepositoryRoot, Result);
1439
- #if UE_BUILD_DEBUG && GIT_DEBUG_STATUS
1440
- UE_LOG (LogSourceControl, Log, TEXT (" LockedFile(%s, %s)" ), *LockFile.LocalFilename , *LockFile.LockUser );
1441
- #endif
1442
- // Only update local locks
1443
- if (LockFile.LockUser == LockUser)
1464
+ Results.Reset ();
1465
+ bResult &= RunLFSCommand (TEXT (" locks" ), InRepositoryRoot, GitBinaryFallback, Params, FGitSourceControlModule::GetEmptyStringArray (), Results, OutErrorMessages);
1466
+ for (const FString& Result : Results)
1444
1467
{
1445
- OutLocks.Add (MoveTemp (LockFile.LocalFilename ), MoveTemp (LockFile.LockUser ));
1468
+ FGitLfsLocksParser LockFile (InRepositoryRoot, Result);
1469
+ #if UE_BUILD_DEBUG && GIT_DEBUG_STATUS
1470
+ UE_LOG (LogSourceControl, Log, TEXT (" LockedFile(%s, %s)" ), *LockFile.LocalFilename , *LockFile.LockUser );
1471
+ #endif
1472
+ // Only update local locks
1473
+ if (LockFile.LockUser == LockUser)
1474
+ {
1475
+ OutLocks.Add (MoveTemp (LockFile.LocalFilename ), MoveTemp (LockFile.LockUser ));
1476
+ }
1446
1477
}
1447
1478
}
1448
1479
}
1449
- else
1480
+ if (!bResult)
1450
1481
{
1451
1482
// We can use our internally tracked local lock cache (an effective combination of --cached and --local)
1452
1483
OutLocks = FGitLockedFilesCache::LockedFiles;
@@ -1917,9 +1948,13 @@ bool UpdateCachedStates(const TMap<const FString, FGitState>& InResults)
1917
1948
{
1918
1949
return false ;
1919
1950
}
1920
-
1921
- FGitSourceControlModule& GitSourceControl = FGitSourceControlModule::Get ();
1922
- FGitSourceControlProvider& Provider = GitSourceControl.GetProvider ();
1951
+
1952
+ FGitSourceControlModule* GitSourceControl = FGitSourceControlModule::GetThreadSafe ();
1953
+ if (!GitSourceControl)
1954
+ {
1955
+ return false ;
1956
+ }
1957
+ FGitSourceControlProvider& Provider = GitSourceControl->GetProvider ();
1923
1958
const bool bUsingGitLfsLocking = Provider.UsesCheckout ();
1924
1959
1925
1960
// TODO without LFS : Workaround a bug with the Source Control Module not updating file state after a simple "Save" with no "Checkout" (when not using File Lock)
0 commit comments