summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2018-01-28 04:27:42 -0700
committerLauris BH <lauris@nix.lv>2018-01-28 13:27:42 +0200
commitc55a027da3fd71359bc6b622652a22fdeb280a80 (patch)
treec0c65fa603f7047d6de3977a208432120dbb1f5f
parent36a94da8dab112f47ee1774f2ae9a8fd7ca21a1c (diff)
downloadgitea-c55a027da3fd71359bc6b622652a22fdeb280a80.tar.gz
gitea-c55a027da3fd71359bc6b622652a22fdeb280a80.zip
Fix empty checkout bug (#3419)
-rw-r--r--models/repo.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/models/repo.go b/models/repo.go
index 59d2336781..4214198567 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -774,17 +774,17 @@ func UpdateLocalCopyBranch(repoPath, localPath, branch string) error {
return fmt.Errorf("git clone %s: %v", branch, err)
}
} else {
- if err := git.Checkout(localPath, git.CheckoutOptions{
- Branch: branch,
- }); err != nil {
- return fmt.Errorf("git checkout %s: %v", branch, err)
- }
-
_, err := git.NewCommand("fetch", "origin").RunInDir(localPath)
if err != nil {
return fmt.Errorf("git fetch origin: %v", err)
}
if len(branch) > 0 {
+ if err := git.Checkout(localPath, git.CheckoutOptions{
+ Branch: branch,
+ }); err != nil {
+ return fmt.Errorf("git checkout %s: %v", branch, err)
+ }
+
if err := git.ResetHEAD(localPath, true, "origin/"+branch); err != nil {
return fmt.Errorf("git reset --hard origin/%s: %v", branch, err)
}