git-lfs/tools/umask_nix.go
brian m. carlson f5d5f487eb
tools: add function to make directories honoring core.sharedRepository
Add a function to make a directory and intervening directories, honoring
core.sharedRepository.

To do so, add a utility function to perform an operation with the umask
set to a certain value. This is required because os.MkdirAll honors the
umask and is potentially recursive (so we can't fix things after
creating them). Without temporarily setting the umask, it isn't possible
to create directories with the right permissions if those permissions
are looser than the original umask.
2018-12-13 17:51:02 +00:00

12 lines
173 B
Go

// +build !windows
package tools
import "syscall"
func doWithUmask(mask int, f func() error) error {
mask = syscall.Umask(mask)
defer syscall.Umask(mask)
return f()
}