Re: [PATCH] git-submodule - allow a relative path as the subproject url
- From
- Michael Smith <msmith@cbnco.com>
- Date
- Sep 24, 2007, 00:21 UTC
- Message-ID
- <loom.20070924T002011-331@post.gmane.org>
- In-Reply-To
- <11904936042891-git-send-email-mdl123@verizon.net>
Mark Levedahl <mdl123 <at> verizon.net> writes:
> This allows a subproject's location to be specified and stored as relative > to the parent project's location (e.g., ./foo, or ../foo). This url is > stored in .gitmodules as given.
> This allows cloning of the project to work "as expected" if the project > is hosted on a different server than when the subprojects were added.
Hi Mark,
I have a use case where this would be very handy -- two teams geographically separated. But in the end I think I disagree with it: it's not up to me, as the person creating a superproject, to decide that anyone who forks or clones it also has to clone all the submodules.
Instead they can decide themselves by editing .git/config between "git submodule init" and "git submodule update", or by branching .gitmodules.
By the way:
Show 12 quoted lines
> +# Get parent project's url
> +get_parent_url ()
> +{
> + # need to append this on parent project's url
> + branch="$(git branch --no-color | sed -ne 's/^\* //p')"
> + test -n "$branch" || die "I do not know what branch you are on: $branch"
> + upstream="$(git config branch.$branch.remote)"
> + test -n "$upstream" || die "Cannot find upstream repo for branch $branch"
> + uprepo="$(git config remote.$upstream.url)"
> + test -n "$upstream" || die "Cannot find url for repo $uprepo"
> + echo "$uprepo"
> +}...
> + case $repo in > + .*) > + realrepo="$(get_parent_url)/$repo" ;;
If you source git-parse-remote, you can use
realrepo="$(get_remote_url "$(get_default_remote)")$repo"
Mike