1// +build static,system_libgit2
2
3package commit
4
5import (
6	git "github.com/libgit2/git2go/v31"
7	"gitlab.com/gitlab-org/gitaly/v14/internal/git2go"
8)
9
10func applyCreateFile(action git2go.CreateFile, index *git.Index) error {
11	if err := validateFileDoesNotExist(index, action.Path); err != nil {
12		return err
13	}
14
15	oid, err := git.NewOid(action.OID)
16	if err != nil {
17		return err
18	}
19
20	mode := git.FilemodeBlob
21	if action.ExecutableMode {
22		mode = git.FilemodeBlobExecutable
23	}
24
25	return index.Add(&git.IndexEntry{
26		Path: action.Path,
27		Mode: mode,
28		Id:   oid,
29	})
30}
31