ned14 / pcpp

A C99 preprocessor written in pure Python
Other
215 stars 39 forks source link

Proposal: use submodule with relative path #76

Closed assarbad closed 1 year ago

assarbad commented 1 year ago

Hi,

hope I am not overstepping with this proposal, if so please take my apologies. Currently the path pcpp/ply is a submodule pointing to the absolute URL https://github.com/ned14/ply.git ...

Have you considered using a relative URL here instead? It would make it easier to mirror and fork the project as a whole. Personally I am not so much interested in forking (as in deviating) and would rather have PRs upstreamed, but mirroring is something I'd love to do. Alas, with absolute URLs the (unchanged) master branch will always point to a GitHub URL. By using something along the lines of url = ./ply.git inside the .gitmodules you would still get the same UX from GitHub all the while allowing other (GitHub) organizations or users to clone both repos side-by-side elsewhere. You can see this in action over here.

NB: doing it this way has one "downside" and I want to be clear about this so you can consider all sides. If you aren't ready to edit the .gitmodules manually, the submodule has to exist at the relative path on your disk prior to the change. And for any operation related to that submodule you will equally have to have it sit next to your worktree, i.e.:

.
├── pcpp
│   ├── .git
│   ├── .github
│   ├── doc
│   ├── pcpp
│   │   └── ply
│   └── tests
│       ├── issue0017
│       ├── issue0025
│       ├── issue0030
│       ├── issue0037
│       └── test-c
└── ply.git

In this case ply.git being a bare clone. This means a little extra work indeed, but on the other hand in my opinion the benefits outweigh this.

Best regards,

Oliver

PS: this is akin to SVN externals which allow to point to another location within the same repo (Git has no such notion with submodules), another repo on the same server or (absolute URL) on another server. From experience not using absolute URLs creates the least pain in the long run. PPS: the change would be:

diff --git a/.gitmodules b/.gitmodules
index e30979e..e0e6db4 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,5 +1,5 @@
 [submodule "pcpp/ply"]
        path = pcpp/ply
-       url = https://github.com/ned14/ply.git
+       url = ../ply.git
        branch = master
        ignore = untracked
ned14 commented 1 year ago

Historically I've not gone for relative submodule urls because url rewriting is very easy in git, and a fully qualified url is much easier to match in the rewriter than a relative url. I could be convinced if this situation were exceptional however.

assarbad commented 1 year ago

Fair enough, I can live with that, too.