Skip to content

Gitea server should not checkout on upload #5600

Closed
@zeripath

Description

@zeripath
  • Gitea version (or commit ref): master

Description

When performing an upload, the UpdateRepoFile function in models/repo_editor.go actually checkout's a copy of the target repository, moves the uploaded files to the correct places, commits and pushes back to the repository.git.

This is very wasteful (and I suspect possibly dangerous, especially on Windows but I don't know). Clearer it would be better to just push (or at least commit) directly to the repository.git

I know of two approaches that are likely to be better:

The most complete appears to be the approach taken in bozaro/git-as-svn which is a Java bridge presenting git repos as SVN. This doesn't checkout a copy of the repo but rather appears to create objects and trees directly in the repository.git by having a deep understanding of the git repository layout thus simulating a commit. It even knows how to manage LFS. I don't quite understand what it's doing but it may be possible to use our current go git libraries to do something similar directly.

A less do it your own way appears to be to use git fast-import. This is a well documented git-core tool for importing data from other software. You simply use the protocol defined in the help file to commit the whole modified files, git will then do the diffs and store the objects. Unfortunately this doesn't appear run any hooks, so it appears that if the object should be in LFS that needs dealing with first. Similarly the post-receive etc hooks would need to be dealt with first/afterwards - although this is likely to be less difficult to deal with.

I will do some more basic testing with git fast-import which I think should be quite easy to pull in. I might also contact the git-as-svn maintainer to see if they can enlighten me more on how their solution works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementAn improvement of existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions