blob: 381ee3a4cc80b8775be9794ff49afa3bfad85ef7 (
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/v31"
"gitlab.com/gitlab-org/gitaly/v14/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,
})
}
|