summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author无闻 <u@gogs.io>2015-09-06 18:17:58 -0400
committer无闻 <u@gogs.io>2015-09-06 18:17:58 -0400
commitd504ee04170551f9140526379963a35fb73298aa (patch)
tree71387e40099e910c945bbf09e7df8d20c4bfd06e
parentc38754d432c4244a884ccf2576397eb15552b495 (diff)
parentae1650824cd50890837d04b310d8ab0f54d46912 (diff)
downloadgitea-d504ee04170551f9140526379963a35fb73298aa.tar.gz
gitea-d504ee04170551f9140526379963a35fb73298aa.zip
Merge pull request #1589 from siadat/migrating-empty-repository
Set IsBare true if migrated repo is empty
-rw-r--r--models/repo.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go
index 2835b6f9e3..06c97baf24 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -470,6 +470,12 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str
return repo, fmt.Errorf("create update hook: %v", err)
}
+ // Check if repository is empty.
+ _, stderr, err = com.ExecCmdDir(repoPath, "git", "log", "-1")
+ if err != nil && strings.Contains(stderr, "fatal: bad default revision 'HEAD'") {
+ repo.IsBare = true
+ }
+
// Check if repository has master branch, if so set it to default branch.
gitRepo, err := git.OpenRepository(repoPath)
if err != nil {