Skip to content

Commit 635273c

Browse files
authored
Merge pull request #1829 from ethantkoenig/no_branches
Commitless repos should be bare
2 parents b5d2780 + c85ff53 commit 635273c

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
@@ -390,6 +390,10 @@ func RepoRef() macaron.Handler {
390390
if err != nil {
391391
ctx.Handle(500, "GetBranches", err)
392392
return
393+
} else if len(brs) == 0 {
394+
err = fmt.Errorf("No branches in non-bare repository %s",
395+
ctx.Repo.GitRepo.Path)
396+
ctx.Handle(500, "GetBranches", err)
393397
}
394398
refName = brs[0]
395399
}

0 commit comments

Comments
 (0)