Skip to content

Commit c85ff53

Browse files
committed
Commitless repos should be bare
1 parent e67ece2 commit c85ff53

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

models/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
517517
}
518518

519519
// Change repository bare status and update last updated time.
520-
repo.IsBare = false
520+
repo.IsBare = repo.IsBare && opts.Commits.Len <= 0
521521
if err = UpdateRepository(repo, false); err != nil {
522522
return fmt.Errorf("UpdateRepository: %v", err)
523523
}

modules/context/repo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ func RepoRef() macaron.Handler {
392392
if err != nil {
393393
ctx.Handle(500, "GetBranches", err)
394394
return
395+
} else if len(brs) == 0 {
396+
err = fmt.Errorf("No branches in non-bare repository %s",
397+
ctx.Repo.GitRepo.Path)
398+
ctx.Handle(500, "GetBranches", err)
395399
}
396400
refName = brs[0]
397401
}

0 commit comments

Comments
 (0)