@@ -469,11 +469,17 @@ func (repo *Repository) LocalCopyPath() string {
469
469
}
470
470
471
471
// UpdateLocalCopy fetches latest changes of given branch from repoPath to localPath.
472
- // It creates a new clone if local copy does not exist.
473
- // This function checks out target branch by default, it is safe to assume subsequent
474
- // operations are operating against target branch when caller has confidence for no race condition.
475
- func UpdateLocalCopyBranch (repoPath , localPath , branch string ) (err error ) {
472
+ // It creates a new clone if local copy does not exist, but does not checks out to a
473
+ // specific branch if the local copy belongs to a wiki.
474
+ // For existing local copy, it checks out to target branch by default, and safe to
475
+ // assume subsequent operations are against target branch when caller has confidence
476
+ // about no race condition.
477
+ func UpdateLocalCopyBranch (repoPath , localPath , branch string , isWiki bool ) (err error ) {
476
478
if ! com .IsExist (localPath ) {
479
+ // Checkout to a specific branch fails when wiki is an empty repository.
480
+ if isWiki {
481
+ branch = ""
482
+ }
477
483
if err = git .Clone (repoPath , localPath , git.CloneRepoOptions {
478
484
Timeout : time .Duration (setting .Git .Timeout .Clone ) * time .Second ,
479
485
Branch : branch ,
@@ -502,7 +508,7 @@ func UpdateLocalCopyBranch(repoPath, localPath, branch string) (err error) {
502
508
503
509
// UpdateLocalCopyBranch makes sure local copy of repository in given branch is up-to-date.
504
510
func (repo * Repository ) UpdateLocalCopyBranch (branch string ) error {
505
- return UpdateLocalCopyBranch (repo .RepoPath (), repo .LocalCopyPath (), branch )
511
+ return UpdateLocalCopyBranch (repo .RepoPath (), repo .LocalCopyPath (), branch , false )
506
512
}
507
513
508
514
// PatchPath returns corresponding patch file path of repository by given issue ID.
0 commit comments