Submodules#907
Conversation
Thanks for opening this PR! We'll review it soon.I'm a bot that checks for some common problems. I'll update this comment with anything I find. Here are some minor issues, that might need fixing:
|
|
Not a good idea, subtrees were added due to the problems submodules were causing. Besides submodules were very limited and i ended up removing the widepix submodule even before than gzdoom and that created a duplicate folder xD. Y wenas. |
Does that imply that there are other subtrees in the repo that we don't know about? The ones that are being removed are fairly new, and were replacing copypasted code (not submodules).
Fair. They both have their limitations. Seeing as we pull in changes frequently from these repo, and the code basically only moves in one direction, these are perfect candidates for submodules.
That's a good example of what probably shouldn't be a submodule. Honestly, they should just be copypasted assets, since they basically never change and just get moved around. The reason for this pr is that the subtrees are causing problems, and have branching limitation that is a bit of a blocker. I believe the benefits of using submodules well outway the annoyance of having to use and hello :D |
|
I'll be keeping an eye on this; I'm also a little weary of the ttf pr adding 850,000 lines because of external libraries :P |
|
I mean the subtrees were added instead of submodules AFAIK. Just my two cents nobody asked for but submodules were a mess xD. BTW wasn't this discussed on discord? I think i remember reading about adding the subtrees mentioning submodules. |
This is correct. I suggested submodules, but was told the man with veto power hated them, so I suggested subtrees as a compromise
It was, but months ago. It was specifically discussed when adding zmusic to gzdoom. I was told that there was absolutely no way that submodules would be added. Now it's a different project, and submodules are a more appropriate tool, so I figured I'd pitch it again. They both have their pros and cons, I'll edit this comment later with as many as I can think of. |
|
GZDoom originally used submodules, but nobody liked them because they were a constant pain point when checking out or updating the repo. You had to remember to manually initialize the submodules (it doesn't happen automatically when cloning a repo), and know to update them (it doesn't happen automatically when rebasing/resetting/merging/switching branches/etc), and even if you did know to, it wasn't always a smooth experience. Like drfrag666 says, we switched from submodules to subtrees to avoid those problems, and I can't say I'd like to go back. |
|
Pretty late but a lot of the extra work that submodules introduce can be addressed by adding a CMake option to automatically run the relevant git commands during building. I personally think this would be the best of both worlds. (The diff's hard to check from the site so not sure if this branch already does this) |
|
Looking at the commit history, there was exactly one submodule that was kept around for a couple months. That's really not enough time for people to learn how to work with anything. I feel the benefits of using the correct tool for a job, vastly outweighs any annoyance you might have from using submodules. Submodules are a well-established git feature used in countless projects. If you have trouble remembering to update them, I feel that is more of a tooling issue on the user's end. I'm pretty suspicious of any claim that a feature should outright not be used. That being said there are plenty of programmers that would not have any reservations about using submodules. I honestly think that this is one of those vocal minority things, where people are resistant to change. But I'm only one voice here, so ultimately this needs to be a group decision. I'm not too worried about it either way.
That's a great idea, and no it does not. I've never set up cmake to do that. What does this look like for windows users that only ever run cmake once to generate the vs project? |
Submodules aren't new. They've existed in Git for a long time so people have learned how they work, how to use them and the issues that arise. They're pretty widely maligned in general, not just in GZDoom's codebase.
CMake is the build system, which is orthogonal to Git being the version control system. CMake shouldn't handle VCS functionality like that, e.g. if I want to switch branches, I'd run git checkout, not some custom cmake command to do a checkout and update submodules. CMake wouldn't know what (if any) git submodule commands need to be run on its own, since a checkout may or may not need to update submodules depending on the checked out branch. Similar for updating a submodule target in a given branch. So you'd end up still needing to manually run things, but using less familiar custom cmake targets, instead of the documented git commands. |
(for the record, i agree wtih kcat, i don't think we should switch to submodules + cmake either, but) Visual Studio itself runs cmake on every compilation, so if it's part of the build step it should Just Work™ |
You missed the part where I said "Submodules are a well-established git feature used in countless projects." What I am saying is that the gzdoom devs did not have time to get used to it. I know you use Linux. How many people have decided Linux is bad, because they used it for a tiny bit, and made up there mind that they don't want to change their workflow?
I can only find a handful of rant-y blogposts and a couple forum threads where people say "submodules are bad", and other people promptly tell them it's a skill issue. Submodules are not for splitting up a monorepo, they're for managing dependancies where you are not modifying the code. This is precisely our use-case
I mean, in my head it would just be a message "yo, your submodules are out of date". We already run plenty of git commands during the build process. But again, I'm not too worried about things either way. What I see in the short discussion here is 3 devs saying "yep, this is a useful tool", and 3 other devs passionately arguing against it. Unless I'm missing something, the arguments against them boil down to "we don't like them". I'm not trying to be rude or dismissive, it's just that the only issues brought up are that remembering to update them is annoying. I'm pretty sure whatever git client you use can be configured to do that automagically, since I know the my system can.
If you have a solution for the above issues, I'm very open to discussing. I also find submodules annoying (I've used them a lot in professional contexts. I'm pretty used to the issues they can cause.), but in my opinion, they are the correct solution in this case. |
Sure, but that's presuming the only time we've had to get used to them is with GZDoom. I remember there being a rather immediate negative response to GZDoom starting to use them, since some of us already had negative experiences with them in other projects, with the response being "let's just try it for a bit". We did that, with the expected problems cropping up, resulting in us ditching them.
Conceptually, the idea of submodules isn't bad. They do seem useful, which is why they were added and people started using them. But in practice, people find them difficult to use, being more trouble than they're worth, hence the rant-y blogposts. I wouldn't put much stock in the responses of "skill issue"/"get gud" since these aren't unseasoned developers that dislike like them.
I don't think there's a way to detect submodules being "out of date". If it was easy to know when submodules need to be updated or to detect issues from them being set up wrong, I'd have expected them to improve, or at least a clearer understanding of how to properly manage them to emerge for projects that want to use them. Instead, we get features like subtrees as an alternative to submodules, suggesting that's just how they are and you need something different if you want to address the issues people have with them. |
Sure, I'll give you that. Thing is, the "we" then is a fairly different group of people than the "we" now.
That's a strange thing to say, since you're asking me to blindly trust that submodules are bad and should just not be used. I, as someone who has used them for most of my time as a developer, think they're fine.
This is why I have issues with discussions like this. You're just telling me you've never checked. It's You have way more experience than me as a developer, and I trust you know what you're talking about. Just this specific topic, I'm having trouble taking what you're saying in good faith. The last reply you sent were two nuh-uh's followed by something false. I'm not really sure what to do with that. If you're against submodules, what alternative do you suggest that fixes the issues I've outlined? |
I'm not sure I'd say they're wholly "bad" per-se, or else they would've been removed or deprecated, just that they're more of a maintenance and usage burden than you may expect or want, such that subtrees are probably a better fit for more use-cases.
To be fair, I haven't used submodules that much. I have used them in a couple other projects though, and I do remember having issues where builds would just start failing because the submodules got out of sync, and it wasn't clear that that's what the issue was. I also remember a point when GZDoom had them, and I thought I was handling them correctly from my experience in past projects, but I would still get unexplained build errors and not know how to properly fix it. It could be that I personally was just "skill issue"ing it, but I also think it's fair to ask, if enough people are having trouble with them like this, how much is really the user's fault for not being good enough, vs it being a less-well-designed feature? There's a couple other points worth bringing up. First, like Second, scripting anything through cmake is really only useful when running cmake. I can only speak for myself, but I don't actually run cmake directly that often. I'll use git to change branches or merge my local changes, but I'll run make or ninja to do the build and let the build re-run cmake only as needed (whenever Regarding your points:
Developers need to pull those lines regardless. Whether its part of the UZDoom repo, or with submodules, those sources need to get on the system for the build. Submodules just add an extra step to getting the UZDoom source tree into a buildable state.
For my part, I don't even bother with subtrees in my projects. For OpenAL Soft, I just pull in a raw copy of fmtlib, for example, and
Would submodules really change anything? If you can't update asmjit because it requires too many changes to the code using it, that would mean you equally couldn't update its submodule target to a newer version without that same work. Or do you mean we can't update asmjit because of custom changes that would need to be applied to an updated version, and there's not enough manpower to do it? In that case, that really highlights a previously mentioned issue with submodules; those changes couldn't have been made in the first place, making it harder or impossible to use. I honestly don't know what the ideal solution would be. I don't think any programming language or development environment has licked the issue of dependency management, as everything comes with its own problems and trade-offs. Keeping local copies of dependencies helps ensure everything can be locally managed, that there's nothing extra beyond the development environment itself that developers need and there's no unnecessary reliance or trust put on external repositories that are out of our control. |
|
also, submodules don't stop people from modifying them, it just excludes the modifications from the PR |
|
though if i had to say one, i think the only thing that'd really benefit from submodules as opposed to subtrees, it would be the translations (but NOT zmusic/zwidget/zvulkan) |
that way the submodule can always just point at trunk, not at one particular commit |
Description
Removes the subtrees we currently have, and replaces them with submodules.
The primary motivation is when I noticed
+4,398,894 −28,220 | Files changed 300+in a recent pr that adds an external library.Subtrees are nice, since as a developer you can treat the code in them as any other file in the repo. But this causes a number of problems, such as how easy it becomes to diverge from upstream, making updates difficult. In addition to this, every time a subtree requires an update, we need to go through a big rigmarole to keep the commit history linear. This involves a squash, in which any context of the update is lost.
Submodules are nice, since they are just a pointer to another repo. An update is as simple as checking out a different commit. Submodules can be annoying, though. When checking out a commit in the main repo, if a submodule was modified you need to remember to update it, too. If it's your first time working with submodules this can be confusing, but it is easily automated.
One other interesting benefit of submodules, is that they can be selectively included. Say for instance a library is windows-only. If it is a submodule, it can be pulled in only for windows builds.
Checklist