Permalink
Please
sign in to comment.
Browse files
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.
- Loading branch information...
Showing
with
33 additions
and 0 deletions.
- +15 −0 tools/filetools.go
- +11 −0 tools/umask_nix.go
- +7 −0 tools/umask_windows.go
| @@ -0,0 +1,11 @@ | |||
| // +build !windows | |||
|
|
|||
| package tools | |||
|
|
|||
| import "syscall" | |||
|
|
|||
| func doWithUmask(mask int, f func() error) error { | |||
| mask = syscall.Umask(mask) | |||
| defer syscall.Umask(mask) | |||
| return f() | |||
| } | |||
| @@ -0,0 +1,7 @@ | |||
| // +build windows | |||
|
|
|||
| package tools | |||
|
|
|||
| func doWithUmask(mask int, f func() error) error { | |||
| return f() | |||
| } | |||
0 comments on commit
f5d5f48