]> source.dussan.org Git - gitea.git/commitdiff
improve force push detect when push (#2798)
authorLunny Xiao <xiaolunwen@gmail.com>
Sat, 28 Oct 2017 19:36:20 +0000 (03:36 +0800)
committerLauris BH <lauris@nix.lv>
Sat, 28 Oct 2017 19:36:20 +0000 (22:36 +0300)
cmd/hook.go

index 0ddbb36f901180951dbd6f20cb796d5c782a3a14..9d805e4ef5edc8b82ddbc26be1bd2cf05cb7e9fa 100644 (file)
@@ -118,7 +118,7 @@ func runHookPreReceive(c *cli.Context) error {
                if protectBranch != nil && protectBranch.IsProtected() {
                        // detect force push
                        if git.EmptySHA != oldCommitID {
-                               output, err := git.NewCommand("rev-list", oldCommitID, "^"+newCommitID).RunInDir(repoPath)
+                               output, err := git.NewCommand("rev-list", "--max-count=1", oldCommitID, "^"+newCommitID).RunInDir(repoPath)
                                if err != nil {
                                        fail("Internal error", "Fail to detect force push: %v", err)
                                } else if len(output) > 0 {