diff options
author | zeripath <art27@cantab.net> | 2021-12-23 13:44:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-23 21:44:00 +0800 |
commit | ffc08c1914fbe6a5a5ebe9c8571b790ac6024d71 (patch) | |
tree | 78e95e6dbf82d25e0fa9c534cab61fb8d266cc9f /routers | |
parent | e0cf3d86c44fde99b49f12c7a1386cbf433a0207 (diff) | |
download | gitea-ffc08c1914fbe6a5a5ebe9c8571b790ac6024d71.tar.gz gitea-ffc08c1914fbe6a5a5ebe9c8571b790ac6024d71.zip |
Do not read or write git reference files directly (#18079)
Git will and can pack references into packfiles and therefore if you write/read the
files directly you will get false results. Instead you should use update-ref and
show-ref. To that end I have created three new functions in git/repo_commit.go that
will do this correctly.
Related #17191
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/pull.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index ba775d761b..1a6a5e55e6 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -325,13 +325,13 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) *git.C if pull.MergeBase == "" { var commitSHA, parentCommit string // If there is a head or a patch file, and it is readable, grab info - commitSHA, err := ctx.Repo.GitRepo.ReadPullHead(pull.Index) + commitSHA, err := ctx.Repo.GitRepo.GetRefCommitID(pull.GetGitRefName()) if err != nil { // Head File does not exist, try the patch commitSHA, err = ctx.Repo.GitRepo.ReadPatchCommit(pull.Index) if err == nil { // Recreate pull head in files for next time - if err := ctx.Repo.GitRepo.WritePullHead(pull.Index, commitSHA); err != nil { + if err := ctx.Repo.GitRepo.SetReference(pull.GetGitRefName(), commitSHA); err != nil { log.Error("Could not write head file", err) } } else { |