aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/commit.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/commit.go')
-rw-r--r--modules/git/commit.go27
1 files changed, 9 insertions, 18 deletions
diff --git a/modules/git/commit.go b/modules/git/commit.go
index 99fbbd0cfc..82b5e0b25d 100644
--- a/modules/git/commit.go
+++ b/modules/git/commit.go
@@ -206,26 +206,17 @@ func (c *Commit) HasPreviousCommit(commitHash SHA1) (bool, error) {
return false, nil
}
- if err := CheckGitVersionAtLeast("1.8"); err == nil {
- _, _, err := NewCommand(c.repo.Ctx, "merge-base", "--is-ancestor", that, this).RunStdString(&RunOpts{Dir: c.repo.Path})
- if err == nil {
- return true, nil
+ _, _, err := NewCommand(c.repo.Ctx, "merge-base", "--is-ancestor", that, this).RunStdString(&RunOpts{Dir: c.repo.Path})
+ if err == nil {
+ return true, nil
+ }
+ var exitError *exec.ExitError
+ if errors.As(err, &exitError) {
+ if exitError.ProcessState.ExitCode() == 1 && len(exitError.Stderr) == 0 {
+ return false, nil
}
- var exitError *exec.ExitError
- if errors.As(err, &exitError) {
- if exitError.ProcessState.ExitCode() == 1 && len(exitError.Stderr) == 0 {
- return false, nil
- }
- }
- return false, err
- }
-
- result, _, err := NewCommand(c.repo.Ctx, "rev-list", "--ancestry-path", "-n1", that+".."+this, "--").RunStdString(&RunOpts{Dir: c.repo.Path})
- if err != nil {
- return false, err
}
-
- return len(strings.TrimSpace(result)) > 0, nil
+ return false, err
}
// CommitsBeforeLimit returns num commits before current revision