diff options
Diffstat (limited to 'cmd/gitaly-git2go/command/commit/change_file_mode.go')
-rw-r--r-- | cmd/gitaly-git2go/command/commit/change_file_mode.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cmd/gitaly-git2go/command/commit/change_file_mode.go b/cmd/gitaly-git2go/command/commit/change_file_mode.go new file mode 100644 index 000000000..17200ee37 --- /dev/null +++ b/cmd/gitaly-git2go/command/commit/change_file_mode.go @@ -0,0 +1,30 @@ +// +build static,system_libgit2 + +package commit + +import ( + git "github.com/libgit2/git2go/v30" + "gitlab.com/gitlab-org/gitaly/internal/git2go" +) + +func applyChangeFileMode(action git2go.ChangeFileMode, index *git.Index) error { + entry, err := index.EntryByPath(action.Path, 0) + if err != nil { + if git.IsErrorCode(err, git.ErrNotFound) { + return git2go.FileNotFoundError(action.Path) + } + + return err + } + + mode := git.FilemodeBlob + if action.ExecutableMode { + mode = git.FilemodeBlobExecutable + } + + return index.Add(&git.IndexEntry{ + Path: action.Path, + Mode: mode, + Id: entry.Id, + }) +} |