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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/gitaly-git2go/commit/update_file.go')
-rw-r--r--cmd/gitaly-git2go/commit/update_file.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/cmd/gitaly-git2go/commit/update_file.go b/cmd/gitaly-git2go/commit/update_file.go
new file mode 100644
index 000000000..cea5d629b
--- /dev/null
+++ b/cmd/gitaly-git2go/commit/update_file.go
@@ -0,0 +1,30 @@
+//go:build static && system_libgit2
+
+package commit
+
+import (
+ git "github.com/libgit2/git2go/v33"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git2go"
+)
+
+func applyUpdateFile(action git2go.UpdateFile, index *git.Index) error {
+ entry, err := index.EntryByPath(action.Path, 0)
+ if err != nil {
+ if git.IsErrorCode(err, git.ErrorCodeNotFound) {
+ return git2go.FileNotFoundError(action.Path)
+ }
+
+ return err
+ }
+
+ oid, err := git.NewOid(action.OID)
+ if err != nil {
+ return err
+ }
+
+ return index.Add(&git.IndexEntry{
+ Path: action.Path,
+ Mode: entry.Mode,
+ Id: oid,
+ })
+}