Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create_file.go « commit « command « gitaly-git2go « cmd - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 62bc6f61b4415939c78369261ab1cbd134c87979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// +build static,system_libgit2

package commit

import (
	git "github.com/libgit2/git2go/v30"
	"gitlab.com/gitlab-org/gitaly/internal/git2go"
)

func applyCreateFile(action git2go.CreateFile, index *git.Index) error {
	if err := validateFileDoesNotExist(index, action.Path); err != nil {
		return err
	}

	oid, err := git.NewOid(action.OID)
	if err != nil {
		return err
	}

	mode := git.FilemodeBlob
	if action.ExecutableMode {
		mode = git.FilemodeBlobExecutable
	}

	return index.Add(&git.IndexEntry{
		Path: action.Path,
		Mode: mode,
		Id:   oid,
	})
}