Make a file called .gitmodules. In it, list the paths containing a submodule. Add that file to the index. This addition to the pre-commit hook finds that file and pulls the HEAD hash out of each of the listed submodule repositories. That hash is then listed to the .gitmodules file along with the submodule name and .gitmodules is added back to the repository. You've now got poor-man's submodule support. Any commits to the submodule will change the hash and hence the .gitmodules file will be different and therefore will show up as "modified" to git. It's not got any nice UI for checking out (obviously) or merging; but it does at least record the state of a project with a bit of manual work to check out the right commit in the submodule. Problems: - git-prune in the submodule could destroy supermodule-referenced commits - no checkout support - no merge support (other than what git provides for the .gitmodule file) - no check for dirty submodule before commit Signed-off-by: Andy Parkins <andyparkins@xxxxxxxxx> --- templates/hooks--pre-commit | 31 ++++++++++++++++++++++++++++++- 1 files changed, 30 insertions(+), 1 deletions(-) diff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit index 723a9ef..7a71d81 100644 --- a/templates/hooks--pre-commit +++ b/templates/hooks--pre-commit @@ -67,5 +67,34 @@ perl -e ' } } exit($found_bad); -' +' || exit 1 + +# Enable poor-man's submodule support when .gitmodules is present +# Simply create a .gitmodules file listing the paths in your repository +# that contain other git repositories; each line will be replaced with the +# path followed by the hash of the current HEAD of the submodule. +# When the submodule changes hash this file will be different from the +# version in the repository and a change will be noted - voila, submodules. +# Of course there is no checkout support, but at least the current state +# will be accurately recorded +if [ -f .gitmodules ]; then + cat .gitmodules | + while read subdir hash + do + # XXX: check if the line is a comment + + # XXX: really need a check here and quit if the submodule is + # dirty + + echo "$subdir $(GIT_DIR=$subdir/.git git-rev-parse HEAD)" + done > .gitmodules + + # This relies on the .gitmodules file having already been added to + # the repository - perhaps this should be automated? + git-update-index .gitmodules || + ( + echo "Submodule tracker file is not tracked by this repository." >&2 + exit 1 + ) +fi -- 1.4.4.2.g95ee-dirty - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html