Skip to content

Commit

Permalink
Make sure .git/info is created before generating .git/info/sparse-che… (
Browse files Browse the repository at this point in the history
go-gitea#5825)

* Make sure .git/info is created before generating .git/info/sparse-checkout

* fix permissions
  • Loading branch information
typeless authored and bmackinney committed Jan 27, 2019
1 parent 0205cc6 commit cde6d90
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
return fmt.Errorf("getDiffTree: %v", err)
}

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

0 comments on commit cde6d90

Please sign in to comment.