diff options
author | Mura Li <typeless@users.noreply.github.com> | 2019-01-24 15:43:37 +0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-01-24 09:43:37 +0200 |
commit | ec31ee1c1cd028dc59292e19d4b1c9dd954ba364 (patch) | |
tree | 555d311f656a130fd40ad3abc93665ec7fba50ef /models/pull.go | |
parent | 88aa70bab93dc612881448af0d3ea6f4c3199361 (diff) | |
download | gitea-ec31ee1c1cd028dc59292e19d4b1c9dd954ba364.tar.gz gitea-ec31ee1c1cd028dc59292e19d4b1c9dd954ba364.zip |
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
Diffstat (limited to 'models/pull.go')
-rw-r--r-- | models/pull.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/models/pull.go b/models/pull.go index e1a69ad2fc..b2cf4b1f44 100644 --- a/models/pull.go +++ b/models/pull.go @@ -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) } |