Skip to content

Conversation

@lunny
Copy link
Member

@lunny lunny commented Dec 5, 2025

  1. Move the submodule cache from git.Commit to git.Tree. Submodule information is parsed from the .submodule file located in the commit’s tree.
  2. Rename CommitSubmoduleFile to SubmoduleFile.
  3. Remove TemplateSubmoduleCommit and replace it with SubmoduleFile.
    • Rename GetTemplateSubmoduleCommits to GetRepoSubmoduleFiles.
    • Rename AddTemplateSubmoduleIndexes to AddSubmodulesToRepoIndex.

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Dec 5, 2025
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 5, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Dec 5, 2025
@wxiaoguang
Copy link
Contributor

SubmoduleFile is a wrong name.

It is indeed a "commit"

@lunny
Copy link
Member Author

lunny commented Dec 5, 2025

SubmoduleFile is a wrong name.

It is indeed a "commit"

A commit should not directly contain any files or path. Files belong to trees, and a submodule is represented as a special type of entry within a tree. A submodule could point to a commit.

         Commit
       /         \
      /           \
(parent SHA)     Tree
(author)         /   \
(committer)   Blob   Blob
(timestamps)
(etc)

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 5, 2025

Files belong to trees, and a submodule is represented as a special type of entry within a tree. A submodule could point to a commit.

Yes, "files" belong to trees, but "submodule" is not a file. It is an entry pointing to a commit.

So SubmoduleFile is a wrong name: it is not a file.


Old name CommitSubmoduleFile is not right either, it was just a temp change for old SubModuleFile + NewSubModuleFile from 1ebb35b (even earlier from an external package) to clarify it is only for displaying the submodule commit on the UI.

@lunny
Copy link
Member Author

lunny commented Dec 5, 2025

I can rename it to Submodule or gitlink. I can only find the two official names from git documentation.

@wxiaoguang
Copy link
Contributor

  1. Move the submodule cache from git.Commit to git.Tree. Submodule information is parsed from the .submodule file located in the commit’s tree.

Also, I don't think the proposed relation is right.

tree can also be a sub-tree.

But the submodules only belong to the commit's root tree, so belonging to the commit is right.

@wxiaoguang wxiaoguang marked this pull request as draft December 5, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code type/refactoring Existing code has been cleaned up. There should be no new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants