How to determine sub-module SHA-1 with gitweb?
I want to determine the associated SHA-1 of a submodule without cloning anything - i.e. remotely. git-ls-remote doesn't show this information, so my initial approach was to scrape the XHTML from gitweb and pull the SHA-1 out of there.
Unfortunately, gitweb seems to have pretty poor support for submodules, showing 404 and 500 "unknown object" errors when trying to view history for the associated path. Therefore it does not seem possible to me to determine the associated SHA-1 of a submodule unless I can identify the exact commit that modified the git-link and then parse the diff for something like:
-Subproject commit 706187649544cb029b617548771fe96c1693be39
+Subproject commit f05b9854fca9a2e1f47449e563a33156c1085646
Unfortunately gitweb is so broken with submodules that I can't find a way to determine which commit contains this diff, so unless I do an exhaustive search b开发者_如何学运维ack through each commit, it's a no-go.
I've tried with gitweb bundled with git 1.6.4.2 and 1.6.6.1 (latest stable).
Can anyone think of a solution, or perhaps an alternative way to do this without having to clone each repository. You see, I want to do this for all repositories in our organisation, and for every branch within each repository, and that's a lot of branches. I'm doing this to get a list of all submodule commits and determine if any are out-of-date.
If the only solution is to individually clone each repository and run queries within, then that will have to be it. Unfortunately some of our repositories are quite large so this will make the entire operation very slow.
I'm not sure if it would give you the answer you want:
Take a look at 'tree' view in gitweb1 for a directory that contains submodule (this might be top dir of your repository). You can recognize submodule by the fact that it has m---------
as mode string. For each submodule you should have 'history' link, where you would have list of all commits that changed given submodule. (This requires gitweb at least from git version 1.5.3).
The lack of better submodule support in gitweb is, I think, caused by the fact that it is hard to detect where repository (the git_dir) for a submodule is.
HTH
Footnotes:
1. It would help if you have provided link to gitweb installation, if it could be made public.
精彩评论