@@ -43,7 +43,7 @@ public static void NormalizeGitDirectory(string gitDirectory, Authentication aut
43
43
}
44
44
45
45
Logger . WriteInfo ( string . Format ( "HEAD is detached and points at commit '{0}'." , headSha ) ) ;
46
- Logger . WriteInfo ( string . Format ( "Local Refs:\r \n " + string . Join ( Environment . NewLine , repo . Refs . FromGlob ( "*" ) . Select ( r => r . CanonicalName ) ) ) ) ;
46
+ Logger . WriteInfo ( string . Format ( "Local Refs:\r \n " + string . Join ( Environment . NewLine , repo . Refs . FromGlob ( "*" ) . Select ( r => string . Format ( "{0} ({1})" , r . CanonicalName , r . TargetIdentifier ) ) ) ) ) ;
47
47
48
48
// In order to decide whether a fake branch is required or not, first check to see if any local branches have the same commit SHA of the head SHA.
49
49
// If they do, go ahead and checkout that branch
@@ -56,7 +56,7 @@ public static void NormalizeGitDirectory(string gitDirectory, Authentication aut
56
56
if ( matchingCurrentBranch != null )
57
57
{
58
58
Logger . WriteInfo ( string . Format ( "Checking out local branch '{0}'." , currentBranch ) ) ;
59
- matchingCurrentBranch . Checkout ( ) ;
59
+ repo . Checkout ( matchingCurrentBranch ) ;
60
60
}
61
61
else if ( localBranchesWhereCommitShaIsHead . Count > 1 )
62
62
{
@@ -69,7 +69,7 @@ public static void NormalizeGitDirectory(string gitDirectory, Authentication aut
69
69
if ( master != null )
70
70
{
71
71
Logger . WriteWarning ( "Because one of the branches is 'master', will build master." + moveBranchMsg ) ;
72
- master . Checkout ( ) ;
72
+ repo . Checkout ( master ) ;
73
73
}
74
74
else
75
75
{
@@ -78,7 +78,7 @@ public static void NormalizeGitDirectory(string gitDirectory, Authentication aut
78
78
{
79
79
var branchWithoutSeparator = branchesWithoutSeparators [ 0 ] ;
80
80
Logger . WriteWarning ( string . Format ( "Choosing {0} as it is the only branch without / or - in it. " + moveBranchMsg , branchWithoutSeparator . CanonicalName ) ) ;
81
- branchWithoutSeparator . Checkout ( ) ;
81
+ repo . Checkout ( branchWithoutSeparator ) ;
82
82
}
83
83
else
84
84
{
@@ -94,7 +94,7 @@ public static void NormalizeGitDirectory(string gitDirectory, Authentication aut
94
94
else
95
95
{
96
96
Logger . WriteInfo ( string . Format ( "Checking out local branch 'refs/heads/{0}'." , localBranchesWhereCommitShaIsHead [ 0 ] . Name ) ) ;
97
- repo . Branches [ localBranchesWhereCommitShaIsHead [ 0 ] . Name ] . Checkout ( ) ;
97
+ repo . Checkout ( repo . Branches [ localBranchesWhereCommitShaIsHead [ 0 ] . Name ] ) ;
98
98
}
99
99
}
100
100
}
@@ -111,7 +111,7 @@ static void EnsureLocalBranchExistsForCurrentBranch(Repository repo, string curr
111
111
{
112
112
Logger . WriteInfo ( isBranch ?
113
113
string . Format ( "Creating local branch {0}" , localCanonicalName ) :
114
- string . Format ( "Creating local branch {0} from ref {1}" , localCanonicalName , currentBranch ) ) ;
114
+ string . Format ( "Creating local branch {0} pointing at {1}" , localCanonicalName , repoTipId ) ) ;
115
115
repo . Refs . Add ( localCanonicalName , repoTipId ) ;
116
116
}
117
117
else
@@ -273,21 +273,14 @@ static void CreateOrUpdateLocalBranchesFromRemoteTrackingOnes(Repository repo, s
273
273
continue ;
274
274
}
275
275
var remoteRefTipId = remotedirectReference . Target . Id ;
276
- Logger . WriteInfo ( string . Format ( "Updating local ref '{0}' to point at {1}." , remoteTrackingReference . CanonicalName , remoteRefTipId ) ) ;
276
+ Logger . WriteInfo ( string . Format ( "Updating local ref '{0}' to point at {1}." , localRef . CanonicalName , remoteRefTipId ) ) ;
277
277
repo . Refs . UpdateTarget ( localRef , remoteRefTipId ) ;
278
+ repo . Checkout ( branchName ) ;
278
279
continue ;
279
280
}
280
- Logger . WriteInfo ( string . Format ( "Creating local branch from remote tracking '{0}'." , remoteTrackingReference . CanonicalName ) ) ;
281
281
282
- var symbolicReference = remoteTrackingReference as SymbolicReference ;
283
- if ( symbolicReference == null )
284
- {
285
- repo . Refs . Add ( localCanonicalName , new ObjectId ( remoteTrackingReference . TargetIdentifier ) , true ) ;
286
- }
287
- else
288
- {
289
- repo . Refs . Add ( localCanonicalName , new ObjectId ( symbolicReference . ResolveToDirectReference ( ) . TargetIdentifier ) , true ) ;
290
- }
282
+ Logger . WriteInfo ( string . Format ( "Creating local branch from remote tracking '{0}'." , remoteTrackingReference . CanonicalName ) ) ;
283
+ repo . Refs . Add ( localCanonicalName , new ObjectId ( remoteTrackingReference . ResolveToDirectReference ( ) . TargetIdentifier ) , true ) ;
291
284
292
285
var branch = repo . Branches [ branchName ] ;
293
286
repo . Branches . Update ( branch , b => b . TrackedBranch = remoteTrackingReferenceName ) ;
0 commit comments