Skip to content

Commit ec31ee1

Browse files
typelesslafriks
authored andcommitted
Make sure .git/info is created before generating .git/info/sparse-che… (#5825)
* Make sure .git/info is created before generating .git/info/sparse-checkout * fix permissions
1 parent 88aa70b commit ec31ee1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

models/pull.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,11 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
447447
return fmt.Errorf("getDiffTree: %v", err)
448448
}
449449

450-
sparseCheckoutListPath := filepath.Join(tmpBasePath, ".git", "info", "sparse-checkout")
450+
infoPath := filepath.Join(tmpBasePath, ".git", "info")
451+
if err := os.MkdirAll(infoPath, 0700); err != nil {
452+
return fmt.Errorf("creating directory failed [%s]: %v", infoPath, err)
453+
}
454+
sparseCheckoutListPath := filepath.Join(infoPath, "sparse-checkout")
451455
if err := ioutil.WriteFile(sparseCheckoutListPath, []byte(sparseCheckoutList), 0600); err != nil {
452456
return fmt.Errorf("Writing sparse-checkout file to %s: %v", sparseCheckoutListPath, err)
453457
}

0 commit comments

Comments
 (0)