add reference option for all create and add commands #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When creating release repositories in my development environment I've found it helpful to pass the
--reference
option to git submodule 'add' and 'update' commands (see git documentation) to hard-link objects from a local clone of a sub-module, rather than recopying them from an origin. This makes things a lot more efficient than duplicating modules when I typically already have a clone on disk for local development.The git documentation cautions against referencing local clones where natural branch progression might result in garbage collection of referenced objects, however the general concept and usage of release repositories seems to preclude this.
I've come up with a
--reference_root
option to signify to git release commands that submodules should be referenced from a specified root directory. This pertains specifically to the following release "create" commands:The tests can verify this functionality by checking for the existence of a
.git/modules/<name>/objects/info/alternates
file as per the git documentation.Right now this functionality assumes the existence of the reference repository on disk (and that it is local, i.e. not mounted) and git will complain if otherwise. I could enhance the error handling to catch this earlier on (and possibly recover gracefully) but for now everything seems to work.