From 8eef5e465c670e2c9f387b180c5c2128beefa5ec Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sun, 22 Aug 2021 16:56:27 +0200 Subject: [PATCH] Fix creation of .keep files when umask is 002 --- internal/chezmoi/sourcestate.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go index 303766ec28a..daca3eb4698 100644 --- a/internal/chezmoi/sourcestate.go +++ b/internal/chezmoi/sourcestate.go @@ -258,23 +258,21 @@ DESTABSPATH: if _, ok := newSourceStateEntry.(*SourceStateDir); ok { dotKeepFileRelPath := sourceEntryRelPath.Join(NewSourceRelPath(".keep")) - dotKeepFileTargetStateEntry := &TargetStateFile{ - empty: true, - perm: 0o666, - } - dotKeepFileEntryState, err := dotKeepFileTargetStateEntry.EntryState(s.umask) - if err != nil { - return err - } dotKeepFileSourceUpdate := sourceUpdate{ - entryState: dotKeepFileEntryState, + entryState: &EntryState{ + Type: EntryStateTypeFile, + Mode: 0o666 &^ s.umask, + }, sourceRelPaths: []SourceRelPath{dotKeepFileRelPath}, } sourceUpdates = append(sourceUpdates, dotKeepFileSourceUpdate) newSourceStateEntries[dotKeepFileRelPath] = &SourceStateFile{ - targetStateEntry: dotKeepFileTargetStateEntry, + targetStateEntry: &TargetStateFile{ + empty: true, + perm: 0o666 &^ s.umask, + }, } } }