1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-02 08:57:32 -04:00

Avoid ambiguity of branch/directory names for the git-diff-tree command (#8066) (#8070)

This commit is contained in:
Mura Li 2019-09-04 03:58:19 +08:00 committed by Lauris BH
parent 7727f84fe8
commit e7f6da386f

View File

@ -299,8 +299,7 @@ func getDiffTree(repoPath, baseBranch, headBranch string) (string, error) {
getDiffTreeFromBranch := func(repoPath, baseBranch, headBranch string) (string, error) { getDiffTreeFromBranch := func(repoPath, baseBranch, headBranch string) (string, error) {
var outbuf, errbuf strings.Builder var outbuf, errbuf strings.Builder
// Compute the diff-tree for sparse-checkout // Compute the diff-tree for sparse-checkout
// The branch argument must be enclosed with double-quotes ("") in case it contains slashes (e.g "feature/test") if err := git.NewCommand("diff-tree", "--no-commit-id", "--name-only", "-r", "--root", baseBranch, headBranch, "--").RunInDirPipeline(repoPath, &outbuf, &errbuf); err != nil {
if err := git.NewCommand("diff-tree", "--no-commit-id", "--name-only", "-r", "--root", baseBranch, headBranch).RunInDirPipeline(repoPath, &outbuf, &errbuf); err != nil {
return "", fmt.Errorf("git diff-tree [%s base:%s head:%s]: %s", repoPath, baseBranch, headBranch, errbuf.String()) return "", fmt.Errorf("git diff-tree [%s base:%s head:%s]: %s", repoPath, baseBranch, headBranch, errbuf.String())
} }
return outbuf.String(), nil return outbuf.String(), nil