Refactor submodule related code
- Move the submodule cache from
git.Committogit.Tree. Submodule information is parsed from the.submodulefile located in the commit’s tree. - Rename
CommitSubmoduleFiletoSubmoduleFile. - Remove
TemplateSubmoduleCommitand replace it withSubmoduleFile. • RenameGetTemplateSubmoduleCommitstoGetRepoSubmoduleFiles. • RenameAddTemplateSubmoduleIndexestoAddSubmodulesToRepoIndex.
SubmoduleFile is a wrong name.
It is indeed a "commit"
SubmoduleFileis 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)
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 1ebb35b9 (even earlier from an external package) to clarify it is only for displaying the submodule commit on the UI.
I can rename it to Submodule or gitlink. I can only find the two official names from git documentation.
- Move the submodule cache from
git.Committogit.Tree. Submodule information is parsed from the.submodulefile 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.