-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcmd_unix.go
45 lines (40 loc) · 946 Bytes
/
cmd_unix.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package main
import (
"os"
"os/signal"
"strconv"
"strings"
"github.com/git-lfs/git-lfs/v3/git"
"golang.org/x/sys/unix"
)
func setPermissions(path string) os.FileMode {
var config *git.Configuration
if strings.HasSuffix(path, ".git") {
config = git.NewReadOnlyConfig(path, path)
} else {
config = git.NewReadOnlyConfig(path, "")
}
var val int
sr := config.Find("core.sharedrepository")
switch sr {
case "true", "group":
val = 0660
case "all", "world", "everybody":
val = 0664
case "false", "umask":
default:
v, _ := strconv.ParseUint(sr, 8, 32)
val = int(v)
}
umask := unix.Umask(0)
unix.Umask(umask)
if val != 0 {
umask = 0777 &^ val
}
return os.FileMode(umask)
}
func setup(c chan os.Signal) {
signal.Notify(c, os.Interrupt, unix.SIGTERM, unix.SIGPIPE)
}