Git and Submodules

We were looking at using submodules to store all of Windchill code. Currently it is around 10 million lines of code in over 400+ modules. It seems to make sense to have every module a git repo even though some modules are quite small.

I was curious though if when using git submodules we could still have a quick response to the question, “What did I change?”. If you ran “git status” in the super module it responds rather quickly with the modified submodules. Unfortunately it does not respond with the names of the files changed. It wouldn’t be performant to do a git status in each submodule, especially when you know right away which submodules changed. So that is where this script comes in handy.

1
alias cdv="cd /f/Git_Module/git_super_module"
1
2
3
4
5
username@localhost /f/Git_Module/git_super_module (master)
$ function sstat { cdv; for m in $( git status -s | grep -E '^ M' | cut -c4- );
do if [ -e $m/.git ]; then cd $m; ( git diff --name-status HEAD; git ls-files
-o --exclude-standard | sed -e 's/^/A /' ) | sed -e "s,\s, $m/,"; cdv; else ech
o $m; fi; done; }
1
2
3
username@localhost /f/Git_Module/git_super_module (master)
$ sstat
M Folder/Where/File/src/loadFiles/customization/fileModified.xml

Awesome! So now we can see which files were modified in a few seconds (on linux this is less then a second). That is pretty sweet.

Until next time.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>