From caef9f950334c95c4b6e2f362fa6766c317419ea Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 2 Oct 2023 22:05:21 +0800 Subject: [PATCH] Fix git 2.11 error when checking IsEmpty (#27393) Fix #27389 --- modules/git/repo.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/git/repo.go b/modules/git/repo.go index 5681d39c3b71..b216ecce3d3b 100644 --- a/modules/git/repo.go +++ b/modules/git/repo.go @@ -86,7 +86,8 @@ func (repo *Repository) IsEmpty() (bool, error) { Stdout: &output, Stderr: &errbuf, }); err != nil { - if err.Error() == "exit status 1" && errbuf.String() == "" { + if (err.Error() == "exit status 1" || err.Error() == "exit status 129") && strings.TrimSpace(errbuf.String()) == "" { + // git 2.11 exits with 129 if the repo is empty return true, nil } return true, fmt.Errorf("check empty: %w - %s", err, errbuf.String())